简体   繁体   English

油脂猴脚本在 FaceBook 上不起作用

[英]greasemonkey script won't work on FaceBook

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?谁能告诉我我的错误在哪里?

Your code looks fine and works for me on FF 4.0.1 with GM 0.9.2.您的代码看起来不错,适用于我在 FF 4.0.1 和 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.您尚未指定您正在使用的 Firefox 或 GM 版本 - 但我想我记得遇到了无法加载外部脚本的问题。 You might try copying and pasting the entire minified source of jQuery into your GM userscript, just after the header, before your code.您可以尝试将 jQuery 的整个缩小源代码复制并粘贴到您的 GM 用户脚本中,就在 header 之后,在您的代码之前。

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.您可能还想通过放入一些日志/警报语句来确保您的代码确实被加载 - 我建议至少$().jquery以确保您已加载 jQuery 并检查它的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM