UserScript - Opera 中的空错误控制台
我正在编写一个 UserScript (=Greasemonkey),它是在 FireFox 中开发的,但可以在 Opera、FF 和 Chrome 中使用。我在 Firefox 中更改了整个脚本,用变量替换所有文本,以便能够轻松地将脚本移植到其他语言。现在它不再在 Opera 中运行,并且在控制台 (Dragonfly) 中不会显示任何错误。该脚本根本不执行任何操作,因此肯定存在一些 Firefox 可以处理但 Opera 不能处理的语法错误。
我不使用任何特定的 FireFox 功能 (GM_*),正如我所说:我只用新的“翻译”数组中定义的变量替换脚本中的字符串。
插入脚本的代码:
(
function()
{
var script = document.createElement("script");
script.textContent = "(" + myFunctionName + ")()";
document.body.appendChild(script);
}
)();
那么...
是否有一些 JavaScript 内容 Firefox 可以处理但 Opera 不能?
或者我可以让错误控制台适用于用户脚本吗?
我做了一些谷歌搜索并搜索了这些论坛,但找不到任何有用的东西...
PS:我首先将其发布在 Opera 论坛上,但我认为我有更好的机会找到一种方法来找到“调试解决方法”特种部队。
PPS:与此同时,我也尝试使用 JS Lint 来定位问题,但是当你打喷嚏时,它就会给出错误。
I'm writing a UserScript (=Greasemonkey) which I am developing in FireFox but works in Opera, FF and Chrome. I changed my entire script in Firefox, replacing all texts with variables as to be able to port the script easily to other languages. Now it no longer runs in Opera and it doesn't show any errors in the console (Dragonfly). The script does nothing at all, so there must be some syntax error that Firefox can handle but Opera not.
I do not use any specific FireFox features (GM_*), as I said: I only replaced strings in the scripts with variables defined in a new "translation" array.
Code to insert my script:
(
function()
{
var script = document.createElement("script");
script.textContent = "(" + myFunctionName + ")()";
document.body.appendChild(script);
}
)();
So...
Is there some JavaScript stuff that Firefox can handle but Opera not?
Or can I get the error console to work for a UserScript?
I did some googling and searched these forums but couldn't find anything that worked...
PS: I posted this on the Opera forums first but figured I have a much better chance getting a way to find a "debugging work-around" on SOF.
PPS: In the meanwhile I also tried locating the problem with JS Lint but that one gives an error when you as much as sneeze.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
消息控制台 (Ctrl+Shift+O) 应包含来自用户脚本的错误。或者,您可以尝试将脚本打包到扩展中并使用 Dragonfly 进行调试: http://dev.opera.com/articles/view/converting-userjs-to-extensions/
The message console (Ctrl+Shift+O) should contain errors from UserScripts. Alternatively, you could try packaging your script into an extension and use Dragonfly for debugging: http://dev.opera.com/articles/view/converting-userjs-to-extensions/