如何修复Greasemonkey上的__exposedProps_错误(GM_xmlhttpRequest)

How to fix __exposedProps__ error on Greasemonkey (GM_xmlhttpRequest)?

本文关键字:GM xmlhttpRequest 错误 exposedProps 何修复 Greasemonkey 上的      更新时间:2023-09-26

我已经为Greasemonkey编写了我的第一个脚本,它运行得很好,只是它在处理的每个页面中都返回了exposedProps错误。我已经修复了所有其他错误,但这个错误仍然存在,并且基于网络上的一些文章(比如这样),它将在未来Firefox 17发布时破坏我的脚本。(现在我使用的是Firefox 15.0,幸运的是它只返回了一个警告错误!)

我在脚本中使用GM_xmlhttpRequest:

function doProcess(id, in_process_type){
    var set_id = GM_getValue("pid"+id);
    GM_xmlhttpRequest({
        method: "POST",
        url: "https://website_address/return_params.php",
        data: "pid="+set_id,
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        onload: function(response) {
    --->    var params = response.responseText;
            params = params.replace(/('r'n|'n|'r|'s)/gm,"");
            ..........
        }
    });
}

这是一条错误消息,指的是我在它前面放了一个箭头的行:

Error: Exposing chrome JS objects to content without __exposedProps__ is insecure and deprecated. See https://developer.mozilla.org/en/XPConnect_wrappers for more information.
Source File: file:///Users/Mona/Library/Application%20Support/Firefox/Profiles/tonfd656.default/gm_scripts/MonaTest/MonaTest.user.js
Line: 133 

我找到了这个页面,它为这个错误提供了解决方案,但老实说,我不知道如何在这里使用它!

我真的很感谢你提前提供的帮助。。。感谢您抽出时间!

这是Greasemonkey内部的一个问题/潜在错误。参见:

  • 问题#1595,"使用exposedProps"
  • Issue#1607,"GM_xmlhttpRequest response.responseText在Nightly17.0a1中未定义…"

您可能需要权衡并跟踪这些错误报告。

如果您链接到完整脚本,我们可能会帮助您解决问题,但很可能,它只能在Greasemonkey内部修复。