Skip to content

Instantly share code, notes, and snippets.

@peterwzhang
Created February 23, 2022 06:15
Show Gist options
  • Save peterwzhang/9b3e07c2c355c3402615d13177d8d217 to your computer and use it in GitHub Desktop.
Save peterwzhang/9b3e07c2c355c3402615d13177d8d217 to your computer and use it in GitHub Desktop.
Periodically check for a given text on a site
// ==UserScript==
// @name Checker
// @version 1
// @description Check all text on a site for a keyword.
// @author Peter Zhang
// @match !!!!!Put what site you want to check on!!!!!
// @grant none
// ==/UserScript==
const SEARCH_TEXT = "PUT TEXT HERE";
// create a function called reload that reloads the page
function reload() {
if (document.getElementsByClassName("changeme") == SEARCH_TEXT) { // change this to whatever class will have your text
window.alert("You found the text!")
window.focus()
}
else{
location.reload();
}
}
function setup() {
// check after 30 seconds
setTimeout(reload, 30000);
}
window.addEventListener("load", setup, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment