Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
Script run in background without waiting for input

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();
        

    }
    
};
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda