Javascript 框架 (RightJS) 作为页面模块中的内容脚本
我是喷气背包世界的新手(以及 Firefox 扩展) 在对喷气背包的可能性进行一些研究时,我发现 有些奇怪的东西。我做了一个简单的测试项目,其中包括 pagemod 中的 javascript 框架 (RightJS)(本教程使用了 jQuery 这似乎工作正常),我收到以下错误:
错误:发生异常。
回溯(最近一次调用最后一次):
文件“/home/nic/Aptgeek/TestProjects/ff-extension/data/external/libs/right-src.js”,第 5979 行,位于
文件“/home/nic/Aptgeek/TestProjects/ff-extension/data/external/libs/right-src.js”,第 990 行,位于
TypeError:Array.include 不是函数
我的 main.js 脚本相当简单:
var pageMod = require("page-mod");
var self = require("self");
exports.main = function() {
pageMod.PageMod({
include: "*",
contentScriptWhen: 'ready',
contentScriptFile: [self.data.url('external/libs/right-src.js'),
self.data.url('test.js')],
onAttach: function onAttach(worker) {
worker.on('message', function(message) {
console.log(message);
});
}
});
}
看到讨论后: http://groups.google.com/group/mozilla-labs-jetpack /browse_thread/thr..., 我开始想知道 jetpack javascript 框架的支持。我是吗 错误地使用了 page-mod ?或者应该有效吗?在 page-mod 中使用 javascript 框架作为内容脚本是否有任何限制?
I'm new to the jetpack world (and firefox extension for that matter)
and while doing some research on the possibility of jetpack, I found
something strange. I did a simple test project that included a
javascript framework (RightJS) in a pagemod (the tutorial used jQuery
and that seemed to works fine) and I got the following error :
error: An exception occurred.
Traceback (most recent call last):
File "/home/nic/Aptgeek/TestProjects/ff-extension/data/external/libs/right-src.js", line 5979, in
File "/home/nic/Aptgeek/TestProjects/ff-extension/data/external/libs/right-src.js", line 990, in
TypeError: Array.include is not a function
My main.js script is fairly simple :
var pageMod = require("page-mod");
var self = require("self");
exports.main = function() {
pageMod.PageMod({
include: "*",
contentScriptWhen: 'ready',
contentScriptFile: [self.data.url('external/libs/right-src.js'),
self.data.url('test.js')],
onAttach: function onAttach(worker) {
worker.on('message', function(message) {
console.log(message);
});
}
});
}
After seeing that discussion :
http://groups.google.com/group/mozilla-labs-jetpack/browse_thread/thr...,
I began to wonder about the jetpack javascript framework support. Am I
using page-mod incorrectly ? Or should that work ? Is there any limitations concerning the use of javascript framework as content-script in a page-mod ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Firefox Add-on 在本地类型被沙箱化的环境中运行。 RightJS 中扩展这些原生类型的方式与沙盒环境发生冲突。对 RightJS 进行了一些更改,使其可以与 Firefox Add-on SDK (JetPack) 配合使用。
Firefox Add-on runs in an environnement where natives type are sandboxed. The way that those natives types were extended in RightJS conflicted with the sandboxed environnement. Some change have been made to RightJS to make it work with Firefox Add-on SDK (JetPack).
尝试使用 rightjs 的“安全模式”功能
http://rightjs.org/tutorials/safe-mode#安全
Try using "safe mode" feature from rightjs
http://rightjs.org/tutorials/safe-mode#safe