我已经为 Greasemonkey 编写了我的第一个脚本,它工作得很好,除了它在它正在处理的每个页面中返回 exposedProps 错误。我已经修复了所有其他错误,但这个错误仍然存在,并且基于网络上的一些文章(如 this )它会在未来发布 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
我找到了这个 page ,它提供了解决此错误的方法,但老实说,我不知道如何在这里使用它!
非常感谢您提前提供的所有帮助... 感谢您的宝贵时间!
最佳答案
这是 Greasemonkey 本身的一个问题/潜在错误。见:
- Issue #1595, "Use exposedProps"
- Issue #1607, "GM_xmlhttpRequest response.responseText is undefined in Nightly17.0a1..."
您可能想要权衡并跟踪这些错误报告。
如果您链接到您的完整脚本,我们可能会提供解决方法,但很可能只能在 Greasemonkey 本身内修复。
关于javascript - 如何修复 Greasemonkey (GM_xmlhttpRequest) 上的 __exposedProps__ 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12187805/