chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { if (request.action === "sendToContent") { const parts = request.data.split('|'); window.timeInput = parts[0]; window.whichButton = parts[1]; window.timeInterval = parts[2]; console.log("Data:", request.data); } }); function test() { if (window.timeInput && typeof window.timeInput === 'string') { const [hours, minutes, secondsAndHundredths] = window.timeInput.split(':'); const [seconds, hundredths] = secondsAndHundredths.split('.'); const targetTime = new Date(); targetTime.setHours(parseInt(hours, 10), parseInt(minutes, 10), parseInt(seconds, 10), parseInt(hundredths, 10) * 10); window.timeInput = targetTime; } const tolerance = 9; const now = new Date(); const diff = Math.abs(now - window.timeInput); if (diff <= tolerance) { const formattedTime = now.toLocaleTimeString() + '.' + now.getMilliseconds().toString(); console.log(formattedTime); window.timeInput = new Date(window.timeInput.getTime() + parseFloat(window.timeInterval) * 1000); console.log("Current time is within tolerance of window.timeInput"); console.log("testing") // const btn=Array.from(document.querySelectorAll('.ng-star-inserted button')).filter(el => el.textContent.trim() === 'تثبيت')[window.whichButton-1]; // if (btn) {btn.click()} } setTimeout(test, 10); } test();