tiebaAllsign

贴吧集中签到

< Feedback on tiebaAllsign

Review: Bad - script does not work

§
Posted: 2014-06-18
Edited: 2014-06-18

请加上 @grant

Greasemonkey 2.0 如果没写 @grant,则默认为 @grant none,这样脚本就无法正常运行。

// @grant          GM_log
// @grant          GM_addStyle
// @grant          GM_setValue
// @grant          GM_getValue
// @grant          GM_xmlhttpRequest
// @grant          GM_deleteValue
§
Posted: 2014-06-18
http://tieba.baidu.com/f?ct=335675392&tn=baiduPostBrowser&z=3111654467&sc=52347697394#52347697394
说了
在 Firefox 32 中使用 Greasemonkey 的 GM_xmlhttpRequest_firefox吧_百度贴吧
顺便这个办法不错

我跟你说的并不是同一个问题,也不关 firefox 32 的事。

添加 @grant 后执行卡住,应该是 Greasemonkey 2.0 的 bug,并不是该脚本的问题,所以我并没有在这里反馈。

§
Posted: 2014-06-18

谁能稍微简化一下代码,以最少的代码复现你说的 GM 的那个错误吗?整个代码看起来太累了。而且这么把bug交过去,作者都没法复现……

§
Posted: 2014-06-18

GM 2.x 不是加上 @grant 就能修好了的(。
沙箱改了一堆东西,稍不注意就会提示权限不足 (如页面访问脚本访问、操作页面上的值)…

§
Posted: 2014-06-18
Edited: 2014-06-18
GM 2.x 不是加上 @grant 就能修好了的(。
沙箱改了一堆东西,稍不注意就会提示权限不足 (如页面访问脚本访问、操作页面上的值)…

是吗?它这个脚本添加 @grant 后就能运行。

但在执行过程中卡住,应该是 Greasemonkey 2.0 的问题,是 GM_xmlhttprequest 函数的错误,并不涉及到你说的页面访问、操作页面上的值。

你的 贴吧免跳转链 中的 @require 被删除了。。。

§
Posted: 2014-06-18
Edited: 2014-06-18
谁能稍微简化一下代码,以最少的代码复现你说的 GM 的那个错误吗?整个代码看起来太累了。而且这么把bug交过去,作者都没法复现……

是 Greasemonkey 2.0 新加入的 GM_xmlhttpRequest() can set the resposeType parameter on the request. 中 responseType 解析错误。

当这个脚本在执行下面代码时

GM_xmlhttpRequest({
    method: 'GET',
    synchronous: false,
    headers: {
        "cookie": document.cookie,
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
        "User-Agent": "Mozilla/5.0 (SymbianOS/9.3; Series60/3.2 NokiaE72-1/021.021; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/525 (KHTML, like Gecko) Version/3.0 BrowserNG/7.1.16352"
    },
    url: 'http://tieba.baidu.com/mo/m?kw=totalcommander',
    onload: function(responseDetails) {
        
    }
});

发生错误 Argument 1 of Document.adoptNode is not an object.,其中的 Argument 1 指req.responseXML.documentElement

Greasemonkey 2.0 的 GM_xmlhttpRequest 新增的部分

try {
      responseState.responseText = req.responseText;
    } catch (e) {
      // Some response types don't have .responseText (but do have e.g. blob
      // .response).  Ignore.
    }

    if (req.responseXML) {
      // Adopt the XML object into a content-window-scoped document.
      var xmlDoc = wrappedContentWin.Document();
      xmlDoc.appendChild(xmlDoc.adoptNode(req.responseXML.documentElement));
      responseState.responseXML = xmlDoc;
    }

这个脚本接受到的 responseText 是这样开头的

§
Posted: 2014-06-18
Edited: 2014-06-18

最后的补充

在 Greasemonkey 2.0 的 xpi 的 modules\xmlhttprequester.js 文件,修改加入 try{} catch(e){} 就能正常工作。

try {
        var xmlDoc = wrappedContentWin.Document();
        xmlDoc.appendChild(xmlDoc.adoptNode(req.responseXML.documentElement));
        responseState.responseXML = xmlDoc;
      } catch(e) {}
§
Posted: 2014-06-18
GM 2.x 不是加上 @grant 就能修好了的(。
沙箱改了一堆东西,稍不注意就会提示权限不足 (如页面访问脚本访问、操作页面上的值)…
是吗?它这个脚本添加 @grant 后就能运行。

但在执行过程中卡住,应该是 Greasemonkey 2.0 的问题,是 GM_xmlhttprequest 函数的错误,并不涉及到你说的页面访问、操作页面上的值。

你的 贴吧免跳转链 中的 @require 被删除了。。。

那个啊… 反正准备抛弃了(泪
现在准备整个助手重写 ;w;

congxz6688Author
§
Posted: 2014-06-19

原来是要用这段try{} catch(e){}替换那段if{}才行。

§
Posted: 2014-06-19
Edited: 2014-06-19
原来是要用这段try{} catch(e){}替换那段if{}才行。

不是替换,是加上 try catch。这是我改好的版本 http://bbs.kafan.cn/forum.php?mod=viewthread&tid=1747638&page=3#pid31777829

congxz6688Author
§
Posted: 2014-06-20

不是替换,是加上 try catch。这是我改好的版本 http://bbs.kafan.cn/forum.php?mod=viewthread&tid=1747638&page=3#pid31777829

原来是添加到IF当中。

Post reply

Sign in to post a reply.