NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name ээээ // @namespace http://tampermonkey.net/ // @version 0.1 // @description - // @author ssssl1 // @collaborator ivushka // @copyright - // @updateURL https://openuserjs.org/meta/ssssl1/My_Script.meta.js // @license MIT; https://opensource.org/licenses/MIT // @match https://catwar.su/cw3/ // @grant none // ==/UserScript== (function() { let currentRotation = 0; let timerStartTime = null; let keyHeld = false; let arrowNumber = null; let startRotation = null; const rotationBuffer = 1; arrowNumber = prompt("ID:"); document.addEventListener('keydown', function(event) { if (((event.key === 'j' || event.key === 'о') || (event.key === 'l' || event.key === 'д')) && !keyHeld) { keyHeld = true; const arrowElement = document.getElementById(`arrow${arrowNumber}`); const rotationStyle = arrowElement.style.transform; const rotationMatch = rotationStyle.match(/rotate\(([\d.]+)deg\)/); if (rotationMatch) { startRotation = parseFloat(rotationMatch[1]); } if (timerStartTime === null && startRotation !== null) { timerStartTime = performance.now(); requestAnimationFrame(checkRotationValue); console.log('Таймер запущен.'); } } }); function checkRotationValue(timestamp) { const arrowElement = document.getElementById(`arrow${arrowNumber}`); const rotationStyle = arrowElement.style.transform; const rotationMatch = rotationStyle.match(/rotate\(([\d.]+)deg\)/); if (rotationMatch) { const rotationValue = parseFloat(rotationMatch[1]); if (Math.abs(rotationValue - startRotation) <= rotationBuffer) { const timerEndTime = performance.now(); const elapsedTime = timerEndTime - timerStartTime; console.log(`Полный оборот стрелы занял ${elapsedTime.toFixed(2)} миллисекунд.`); timerStartTime = null; keyHeld = false; startRotation = null; } else { requestAnimationFrame(checkRotationValue); } } } document.addEventListener('keyup', function(event) { if (((event.key === 'j' || event.key === 'о') || (event.key === 'l' || event.key === 'д')) && keyHeld) { keyHeld = false; } }); })();