Greasemonkey 脚本无法在 Facebook 上运行
我有这个代码:
==UserScript==
// @name name
// @namespace url
// @description desc
// @include http://www.facebook.com/*
// @require http://code.jquery.com/jquery-1.5.2.min.js
// ==/UserScript==
$(document).ready(function() {
$("a").click(function(){
alert(1);
return false;
});
});
但是当我安装它并单击某个链接时,我只是转到该地址,这意味着该脚本不起作用。
谁能告诉我我的错误在哪里?
i have this code:
==UserScript==
// @name name
// @namespace url
// @description desc
// @include http://www.facebook.com/*
// @require http://code.jquery.com/jquery-1.5.2.min.js
// ==/UserScript==
$(document).ready(function() {
$("a").click(function(){
alert(1);
return false;
});
});
but when i install it, and click on some link i'm just taken to the adress, which means the script doesn't work.
can anyone tell me where's my mistake?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码看起来不错,并且适用于 FF 4.0.1 和 GM 0.9.2。您还没有指定您正在使用的 Firefox 或 GM 版本 - 但我想我记得遇到了一个无法加载外部脚本的问题。您可以尝试将整个缩小的 jQuery 源代码复制并粘贴到您的 GM 用户脚本中,就在标题之后、代码之前。
您可能还想通过放入一些日志/警报语句来确保您的代码确实被加载 - 我建议
$().jquery
至少确保您已加载 jQuery 并检查它的版本。Your code looks fine and works for me on FF 4.0.1 with GM 0.9.2. You haven't specified the Firefox or GM version that you're working with - but I think I remember running into a problem where the external scripts would not get loaded. You might try copying and pasting the entire minified source of jQuery into your GM userscript, just after the header, before your code.
You might also want to make sure your code actually does get loaded by putting in some log/alert statements - I'd suggest
$().jquery
at least to ensure you have jQuery loaded and check it's version.