How do you go about using console.log
in greasemonkey scripts? I don't get any output.
// ==UserScript==
// @name test
// @namespace test
// @descr开发者_开发技巧iption test
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js
// @version 1.2
// ==/UserScript==
console.log('test');
I get the impression that you can use console.log
normally in Chrome. Is there a nice wrapper so you can log to console in both Firefox and Chrome?
console.log
will appear in the Error Console in Firefox (Tools -> Error Console OR CTRL+SHIFT+J)
Changing it to unsafeWindow.console.log
will make the log appear in Firebug. Make sure you read up on security concerns of unsafeWindow before using it.
The other option to get the log to appear in Firebug, as you said, is to leave it as console.log but turn on extensions.firebug.showChromeErrors
AND extensions.firebug.showChromeMessages
. This can be done by typing about:config in the Firefox address bar. Then filter for Chrome. Find the two options and double click them to turn them on.
All Firefox examples are for Firefox 5.0
It seems that console.log
does in fact work in both Chrome and Firefox.
In Firefox you need to have Show Chrome messages
and Show Chrome errors
enabled in Firebug to be able to see messages produced by your greasemonkey script.
精彩评论