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 script header...
// @grant GM_log
Use this in your code...
GM_log('<my debug message>');
Apparently, Twitter overrides console.log. The "solution" is to put console.log = console.__proto__.log
at the top of my functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With