Firefox附加SDK和js-ctypes [英] Firefox Add-on SDK and js-ctypes
本文介绍了Firefox附加SDK和js-ctypes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用js-ctypes的Firefox附加组件来访问本地DLL的方法,但是它不起作用。
main.js代码:
var data = require SDK /自)数据;
var pageMod = require(sdk / page-mod);
pageMod.PageMod({
include:mysite.com,
contentScriptFile:data.url(myjs.js)
});
myjs.js代码只是:
Components.utils.import( 资源://gre/modules/ctypes.jsm);
alert(hello world);
在Firefox的控制台上,我收到了这些消息:
Components对象已被弃用。它很快就会被删除。
TypeError:Components.utils未定义
没有hello world警报被触发。 / p>
有什么问题?谢谢!
解决方案
不能从内容脚本使用js-ctypes - 内容脚本没有特权。你必须通过 chrome权限:
$ b
var {Cu} = require(chrome);
var {ctypes} = Cu.import(resource://gre/modules/ctypes.jsm,null);
var lib = ctypes.open(...);
I'm trying to use Firefox Add-on SDK with js-ctypes to access the methods of a local DLL, but it isn't working.
The main.js code:
var data = require("sdk/self").data;
var pageMod = require("sdk/page-mod");
pageMod.PageMod({
include: "mysite.com",
contentScriptFile: data.url("myjs.js")
});
The myjs.js code is just:
Components.utils.import("resource://gre/modules/ctypes.jsm");
alert("hello world");
On Firefox's console I got those messages:
The Components object is deprecated. It will soon be removed.
TypeError: Components.utils is undefined
No "hello world" alert is fired.
What's the problem? Thanks!
解决方案
You cannot use js-ctypes from a content script - content scripts have no privileges. You have to do that in the extension itself, via chrome authority:
var {Cu} = require("chrome");
var {ctypes} = Cu.import("resource://gre/modules/ctypes.jsm", null);
var lib = ctypes.open(...);
这篇关于Firefox附加SDK和js-ctypes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文