繁体   English   中英

在 Chrome 控制台上重新加载后保持 Javascript 运行

[英]Keep Javascript running after reload on chrome console

因此,我想在某个网站上每 15 秒检查一次是否删除了某些单词。 我已经这样做了:

window.setInterval(myFunction, 15000)

function myFunction() 
{
    
    //Check that "words" are not on web anymore
    if ((document.documentElement.textContent || document.documentElement.innerText).indexOf('words') > -1)
        {
            alert("They still here");
        }
    else
        {
            alert("They are gone");
        }
    location.reload();
}

但是由于location.reload(); 他们的脚本只能运行一次。

我该怎么办?

在 window.load 中调用计时器并删除位置的重新加载。

window.onload = function() {window.setInterval(myFunction, 15000)};
function myFunction() 
{
    
    //Check that "words" are not on web anymore
    if ((document.documentElement.textContent || document.documentElement.innerText).indexOf('words') < -1)
        {
            alert("They are gone");
        }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM