开发者

userscript chrome vs. firefox

i have written开发者_StackOverflow中文版 a big userscript for greasemonkey which works just fine in firefox, but in chrome nothing happens :(

// ==UserScript==
// @name           Name
// @description    Desc.
// @author         chiefwrigley
// @version        7.3
// @license        (CC) chiefwrigley
// @namespace      http://userscripts.org/scripts/show/103899
// @include        *
// @require        http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js
// ==/UserScript==

which functions can i use and which not? e.g. GM_setvalue... are there equal functions?


Use Tampermonkey. It allows almost all GM scripts to run on Chrome.

For a somewhat dated matrix of what Chrome userscripts allow, otherwise, start with this table (which needs updating).


You can check out the Greasemonkey Wiki to find out about cross browser compatibility. A good rule of thumb though is that other browsers don't really support any GM_* functionality.

For Chrome specifically, it looks like it doesn't support "@require, @resource, unsafeWindow, GM_registerMenuCommand, GM_setValue, or GM_getValue." and "GM_xmlhttpRequest is same-origin only." [Source]


If nothing is happening, and you're depending on jQuery, the likely cause is that chrome doesn't use @require, so jQuery isn't present... meaning your $(document).ready() is doing nothing, so the script never starts.

I've written a userscript/Greasemonkey pattern which will let you get jQuery (and UI, and whatever else you need) working, in both Chrome and FF, as well as Opera. http://userscripts.org/scripts/show/123588

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜