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");
}
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");
}
Share
Improve this question
edited Mar 7, 2015 at 21:42
AstroCB
12.4k20 gold badges58 silver badges74 bronze badges
asked Mar 7, 2015 at 16:59
Christopher WirtChristopher Wirt
1,1171 gold badge10 silver badges21 bronze badges
7
|
Show 2 more comments
3 Answers
Reset to default 18The 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>');
Apparently, Twitter overrides console.log. The "solution" is to put console.log = console.__proto__.log
at the top of my functions.
To your tamermonkey script header add
// @grant GM_log
then console.log("hello world");
should work
console.log("Started!")
would be firing (just) before that happens, if that is your case. – Brock Adams Commented Mar 7, 2015 at 21:21console.log = console.__proto__.log
at the start of my functions and it works just fine now. – Christopher Wirt Commented Mar 7, 2015 at 22:00