[英]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();
他们的脚本只能运行一次。
我该怎么办?
我认为 tampermonkey 是您正在寻找的https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo
在 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.