For this test Greasemonkey UserScript, the alerts pop up but nothing is logged to the Firebug console.
This is with Greasemonkey 0.9.18 and Firebug 1.9.1 in Firefox 12.0.
// ==UserScript==
// @name test
// @namespace tester12354
// @include *
// @require http://code.jquery.com/jquery-latest.min.js
// ==/UserScript==
(function($) {
$.fn.tester1 = function(test) {
alert(test);
console.log(test);
}
}(jQuery));
$.extend({
tester2: function(test) {
alert(test);
console.log(test);
}
});
alert($().jquery)
console.log($().jquery)
$().tester1('from tester1');
$.tester2('from tester2');
As it is explained in the GreaseMonkey manual , in GreaseMonkey scripts, the global context for the script is not the Browser's real window object (unlike in actual scripts that execute on the page) but a dummy version of the window object with the same APIs.
The console
object is a global variable on the real window and is thus not accessible from GreaseMonkey (or at least from jQuery on GreaseMonkey).
See this page for explanation on what's up with console
under GreaseMonkey and how you should log messages from GreaseMonkey.
如果页面本身没有任何<script>
标签,那可能是因为Firebug注入控制台对象的愚蠢方式 。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.