如何将chrome扩展函数移植到firefox扩展函数

时间:2013-03-09 11:11:17

标签: google-chrome-extension firefox-addon

我有一个chrome扩展名,其代码行如下:

chrome.tabs.executeScript(null, {allFrames:true, file:"myscript.js"});

和以下功能:

chrome.extension.onRequest.addListener

chrome.extension.sendRequest

如何使这些函数适用于firefox扩展?

另外,如何实现选项(弹出)页面和后台页面之间的通信相同的功能?

1 个答案:

答案 0 :(得分:-1)

https://addons.mozilla.org/en-US/developers/docs/sdk/1.14/dev-guide/tutorials/modifying-web-pages-url.html

// Import the page-mod API
var pageMod = require("sdk/page-mod");
// Import the self API
var self = require("sdk/self");

// Create a page mod
// It will run a script whenever a ".org" URL is loaded
// The script replaces the page contents with a message
pageMod.PageMod({
  include: "*.org",
  contentScriptFile: self.data.url("my-script.js")
});
相关问题