阅读:6678回复:12
Greasemonkey 2.0 发布,可能会导致部分脚本失效
https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/versions/
http://www.greasespot.net/ 官方主页已发布,AMO上面还没审核通过,大家可以提前下载。其中有两个很大的变化,可能会导致部分脚本失效: 1、@grant 默认为 none,也就是脚本之前没有声明 @grant GM_xmlhttpRequest 之类的,默认都为 @grant none,如果你在脚本里面用到GM_xmlhttpRequest 之类都会失效。详见:https://greasyfork.org/forum/discussion/476/%E8%AF%B7%E5%8A%A0%E4%B8%8A-grant 2、unsafeWindow 不能直接使用,如果要访问 unsafewindow,必须使用 cloneInto(), exportFunction(), and/or createObjectIn() 这些 method,详见: https://blog.mozilla.org/addons/2014/04/10/changes-to-unsafewindow-for-the-add-on-sdk/ Backwards incompatible changes: |
|
|
1楼#
发布于:2014-06-19 12:23
只希望脚本作者能即使更新脚本了,免到时候又是说脚本失效的
|
|
2楼#
发布于:2014-06-19 13:24
|
|
|
3楼#
发布于:2014-06-19 13:54
|
|
4楼#
发布于:2014-06-19 14:25
unsafeWindow 好像可以直接使用,只是无法直接修改。
2.0 的 GM_xmlhttprequest 有一个明显的 bug,不知道作者什么时候修复。 先用 1.5 是最好的选择。 |
|
5楼#
发布于:2014-06-19 20:07
|
|
|
6楼#
发布于:2014-06-19 23:34
.难道是scriptish nightly不能修改unsafewindow也是因为这个?我还以为只有scriptish有问题。。。
|
|
7楼#
发布于:2014-06-20 07:43
简单测试了下,对 Google 搜索去除跳转的修改
还是有效 window.addEventListener('load', function(){ unsafeWindow.rwt = function() {}; }, false);有效 try { Object.defineProperty(unsafeWindow, 'rwt', { value: function() { return ''; }, }); } catch (e) {} 没明白哪里变了。。。。 求指点 添加下面代码,在控制台执行也能成功 unsafeWindow.mtest = function() { alert('hello, world'); }; |
|
8楼#
发布于:2014-06-20 16:32
aaaa007cn:不能直接修改……仔细对比 Greasemonkey 1.5 和 2.0 的源码,对 unsafeWindow 并未有改变,还是同样的方法: @grant none 直接是 window。 非 @grant none sandbox.unsafeWindow = aContentWin.wrappedJSObject;2.0 仅仅是增加了这3个方法: // Functions for interaction with unsafeWindow; see: http://goo.gl/C8Au16 sandbox.createObjectIn = Cu.createObjectIn; sandbox.cloneInto = Cu.cloneInto; sandbox.exportFunction = Cu.exportFunction;补充:上面的不正确。 原来我用的是 alice修改的临时可用版本,我还修改了下忽略 GM_httpRequest 的那个错误,http://bbs.kafan.cn/forum.php?mod=viewthread&tid=1747638&page=3#pid31777829。 alice 修改了这个地方就让 unsafeWindow 跟以前一样。 图片:2014-06-20_181450.png ![]() |
|
9楼#
发布于:2014-06-20 23:44
|
|
10楼#
发布于:2014-06-21 00:16
|
|
11楼#
发布于:2014-06-24 20:26
翻了手边的猴子脚本
大多数都设置过 @grant 不过之前没有的 不改动的话也没关系 http://www.greasespot.net/2014/06/greasemonkey-20-release.html Greasemonkey will only use explicit @grant metadata, it will no longer sniff for implicitly used APIs. (This change takes effect at install time. Currently installed scripts will continue to function as normal until they are updated/edited/reinstalled.) 至于 unsafeWindow 好像是可以直接读,不可直接写? cloneInto()、exportFunction()、createObjectIn() 也是有看没有懂 mozilla 那里说的是 addon 中的用法 油猴包装过之后又该怎么用? 我还是等 2.0 被正式放出来后再折腾好了 |
|
|
12楼#
发布于:2014-09-12 17:37
因为这个unsafeWindow的原因,网易右侧评论(http://userscripts-mirror.org/scripts/show/156627)失效了,我看不明官方说明是啥意思,完全不会改…………
|
|
|