so I managed to my script work even when when popup is closed but the script doesnt react on button it keeps refreshing the site, could you guys help me and tell me what is wrong in this background.js? I have separate content.js and html file.
function startref() {
let intervalId = setInterval(function () {
chrome.tabs.query({ active: true, currentWindow: true }, function (arrayOfTabs) {
var code = 'window.location.reload();';
chrome.tabs.executeScript(arrayOfTabs[0].id, { code: code });
});
}, 3000);
localStorage.setItem('refresh', intervalId);
}
function stop() {
const intervalId = localStorage.getItem("refresh");
clearInterval(intervalId);
}
window.onload = function () {
var sta = document.getElementById("startbtn");
var sto = document.getElementById("stopbtn");
document.addEventListener('DOMContentLoaded', function () {
sta.addEventListener('click', startref);
});
document.addEventListener('DOMContentLoaded', function () {
sto.addEventListener('click', stop);
});
if (localStorage.getItem("refresh")) {
startref();
}
};