【发布时间】:2010-02-04 05:24:39
【问题描述】:
我在这里看到了一个问题和许多关于让 jquery 进入greasemonkey 的博客文章,但是我什么也做不了。
这是我的脚本:
// ==UserScript==
// @name Hello jQuery
// @namespace http://foo.bar
// @description jQuery test script
// @include *
// ==/UserScript==
#{contents of jquery.latest.js pasted in}
unsafeWindow.jQuery = jQuery;
$(document).ready(function() {
alert('Hello world!');
});
我希望在刷新页面时看到警报,这样我就可以开始实际编程了。我已经尝试了很多其他的东西,但到目前为止没有任何效果。该脚本在小猴子菜单中启用...
编辑:脚本部分现在看起来像这样:
foo();
function foo() {
$ = unsafeWindow.jQuery;
$('tr td.row2:nth-child(4)').css("background-color", "#999");
}
它不起作用。我知道 jQuery 很好,因为我可以从greasemonkey 之外运行它。 如果不是 jQuery 函数,而是说 alert('hello');效果很好;我在页面加载时收到警报。
【问题讨论】:
标签: javascript jquery greasemonkey