Greasemonkey jQuery干扰? [英] Greasemonkey Jquery interference?

查看:77
本文介绍了Greasemonkey jQuery干扰?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
Greasemonkey 1.0中的jQuery与使用jQuery的网站冲突

Possible Duplicate:
jQuery in Greasemonkey 1.0 conflicts with websites using jQuery

看来,如果我的油脂猴子脚本中的任何一条都具有如下所示的内容,则在包含jquery的网站上会出现错误.我不知道为什么,但是我确实注意到一些JavaScript事件没有触发. (例如,我无法添加评论.)

It appears that if any of my greasemonkey scripts have the line like the below i get errors on sites that include jquery. I'm not sure why but i do notice some javascript events outright not firing. (For example on SO i cant add a comment).

我可以在脚本中排除SO,但是有更好的解决方案吗?也许我应该在测试是否存在jquery之后动态添加jquery.如何解决此问题以及如何在不使用jquery的情况下将jquery脚本标签添加到主体?

I could exclude SO in the script but is there a nicer solution? Maybe i should dynamically add jquery after testing if jquery exist. How do I solve this problem and how do I add the jquery script tags to a body without using jquery?

// @require         http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js

推荐答案

Greasemonkey 1.0,从根本上改变了沙盒有效,破坏了数千个脚本.另请参见, Greasemonkey 1.0中的jQuery与使用jQuery的网站冲突.

Greasemonkey 1.0, radically changed the way the sandbox works, busting thousands of scripts. See also, jQuery in Greasemonkey 1.0 conflicts with websites using jQuery.

这是一个巨大的问题,Greasemonkey的首席开发人员表示完全不愿意以明智的方式解决该问题.

This is a huge problem, and the lead developer of Greasemonkey has expressed a complete unwillingness to resolve it in a sensible way.

要解决此问题,请通过编辑您的

To work around it, restore the sandbox to your script, and resolve the $ conflict, by editing your Metadata Block to end with the following lines:

// @grant       GM_addStyle
// ==/UserScript==
/*- The @grant directive is needed to work around a major design change introduced in GM 1.0,
    It restores the sandbox.
*/


指定@grant值(none除外)会重新激活沙箱.


Specifying a @grant value (other than none) reactivates the sandbox.

您还可以考虑切换到 Scriptish ,它过去提供了卓越的功能和性能,并且不受新的沙箱行为的影响.

You might also consider switching to Scriptish, which has offered superior features and performance in the past, and does not suffer from this new sandbox behavior.

Scriptish 也没有发布会破坏其大部分安装基础的更新.

Scriptish, so far, hasn't posted updates that destroy a large portion of its install base, either.

这篇关于Greasemonkey jQuery干扰?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆