From cb5d8d5285a1b82b2dadd9094dcec2337ac66546 Mon Sep 17 00:00:00 2001 From: elisspace Date: Sat, 26 Nov 2022 15:20:22 -0500 Subject: [PATCH] can't stop the signal --- script_foreground.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/script_foreground.js b/script_foreground.js index 3283ac9..10a5c9a 100644 --- a/script_foreground.js +++ b/script_foreground.js @@ -166,20 +166,13 @@ function appendTool(html) { toolbarDiv.classList = "watching"; waitBrach.style.display = "none"; watchBrach.style.display = "inline"; - timer = setInterval(function () { - let refresh_btn = document.querySelector('[data-qa-action-id="refresh-queue"]'); - if (newQuestion()) { - sendAlert(); - }; - refresh_btn.click(); - }, state["watch-frequency"] * 1000); - return timer; + clickDaButton(); }); watching.addEventListener('click', function () { toolbarDiv.classList = "waiting"; waitBrach.style.display = "inline"; watchBrach.style.display = "none"; - clearInterval(timer); + // clearInterval(timer); }); volume.addEventListener('click', function (e) { if (state['volume'] >= 5) { @@ -205,6 +198,20 @@ function appendTool(html) { }); }; +// click refresh button +function clickDaButton() { + var min = 61, + max = 566; + var rand = Math.floor(Math.random() * (max - min + 1) + min); + console.log('Wait for ' + rand + ' seconds'); + + if (newQuestion()) { + sendAlert(); + }; + document.querySelector("[id^='refresh-queue']").click(); + setTimeout(clickDaButton, rand * 1000); +} + // Returns TRUE if 'AVAILABLE QUESTIONS' or 'IN CLASS ACTIVITY QUESTIONS' are found in the HTML function newQuestion() { console.log('searching for new question...')