简体   繁体   中英

Get JavaScript alert in case of specific words on web page

Is it possible to get a JavaScript alert when there is a given word (or words) on a currently visited web page? I have searched in all the Google extensions, but I haven't found it unfortunately.

Thank you in advance!

I created an extension for you. Just download and unzip the file then follow these instructions to install. (The load unpacked part)

Instructions for the plugin:

To change the words which it alerts for. You click on the details button in the extensions page and scroll down and click the Extension options button. You can also click the Extension icon in the web bar and click Options.

hopefully, this helps.

link to download on github

With help from stackoverflow I have found a script that works:

if ((document.documentElement.textContent || document.documentElement.innerText).indexOf('cows') > -1)
{
      alert("Hello");
}

The only problem is: it works only once. After saving the JS code, the current page refreshes and it works. But when I reload the page manually, the JS code isn't executed. BTW; I'm using the extentions "Custom Javascript for Websites 2"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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