I've been working on this user script to hunt for a specific string in an HTML webpage with the goal of finding the time at which it appeared. This feels needlessly complicated and I would like advice on how too condense and upgrade the code to more simply find the time.
// ==UserScript==
// @name Magma Time Finder
// @namespace Will.GG
// @description Refreshes the page until target string is found
// @include *www.website.com
// @include http://www.website.com
// @grant metadata
// ==/UserScript==
var strHTML = document.body.innerHTML;
var yourTime = new Date();
var count = 1;
if(strHTML.indexOf("Text to find here") < 0){
alert(yourTime);
} else {
var lastCheck = document.createElement("div");
lastCheck.innerHTML = "Last Check: " + yourTime.toString();
console.log('Iteration: ' + count);
count++;
var parent = document.getElementsByClassName("content")[0];
parent.insertBefore(lastCheck, parent.children[1]);
window.setTimeout(function(){window.location.reload() ;},300000) ;
}
return;