harel486
harel486

Reputation: 183

Keep Javascript running after reload on chrome console

So, I want to check every 15 sec on some website if some words have been deleted. I have done this:

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

But becaue of the location.reload(); they script can only run once.

What do I do?

Upvotes: 2

Views: 2110

Answers (2)

Sanjay Choudhary
Sanjay Choudhary

Reputation: 349

call timer in window.load and remove reloading of location.

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");
        }

}

Upvotes: 2

vinith p
vinith p

Reputation: 53

I think tampermonkey is what you are looking for https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo

Upvotes: 0

Related Questions