I've used setInterval()
plenty of times in typical scripts, but not with userscripts. For some reason, console.log()
isn't working, but only inside of the setInterval. The alert, however, is working. Any ideas..? Should I not be using console.log?
To clarify, the first console.log("Started!");
does in fact print started.
(function() {
console.log("Started!");
setInterval(function(){ findAndReplace();}, 3000);
})();
function findAndReplace() {
alert("hi");
console.log("Hey");
}
The answer supplied by OPer didn't work for me, it seems that's no longer an option. Grant GM_log
to your script and use the GM_log
function as a substitute for console.log
.
Add this to the userscript header:
// @grant GM_log
Use this in your code:
GM_log('<my debug message>');