Plugins 通过附加模块调用插件

Plugins 通过附加模块调用插件,plugins,firefox-addon,firefox-addon-sdk,message-passing,Plugins,Firefox Addon,Firefox Addon Sdk,Message Passing,场景: 我开发了一个firefox插件。我想让我的插件调用firefox中的另一个插件 问题: 我无法理解如何调用插件。在chrome中,扩展可以通过消息传递调用插件。Can消息传递可以用于firefox插件。如果可以,任何人都可以提供指导。 代码如下: 下面是main.js文件: var {data} = require("sdk/self"); var pageMod = require("sdk/page-mod"); pageMod.PageMod({ include: "*", att

场景: 我开发了一个firefox插件。我想让我的插件调用firefox中的另一个插件

问题: 我无法理解如何调用插件。在chrome中,扩展可以通过消息传递调用插件。Can消息传递可以用于firefox插件。如果可以,任何人都可以提供指导。 代码如下: 下面是
main.js
文件:

var {data} = require("sdk/self");
var pageMod = require("sdk/page-mod");
pageMod.PageMod({
include: "*",
attachTo: ["top"],
contentScriptFile: [data.url("jquery-2.1.0.js"),data.url("cwic.js"), data.url("my-  script.js")]
});
//MAIN REGEX
var regex = /\+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}/g; 

var text = $("body:first").html();

var textNodes = $("body:first").find('*').contents().filter(function(){

if(this.nodeType == 3 && regex.test(this.nodeValue) && this.parentElement.tagName !== "A"){
    var anchor = document.createElement('a');
    //alert(this.nodeValue.match(regex)[0]);
    //anchor.setAttribute('href', this.nodeValue);

    anchor.setAttribute('href', this.nodeValue.match(regex)[0]);

    anchor.appendChild(document.createTextNode(this.nodeValue.match(regex)[0]));

    //alert(this.nodeValue.match(regex));


    if(this.nextSibling)
        this.parentElement.insertBefore(anchor, this.nextSibling);


    else
        this.parentElement.appendChild(anchor);


    this.nodeValue = this.nodeValue.replace(regex, '');
}

return this.nodeType === 3;


});
$('a').click(function() {
    // When user clicks on the number it should call another plug-in to initiate    communication
});
下面是
my_script.js
文件:

var {data} = require("sdk/self");
var pageMod = require("sdk/page-mod");
pageMod.PageMod({
include: "*",
attachTo: ["top"],
contentScriptFile: [data.url("jquery-2.1.0.js"),data.url("cwic.js"), data.url("my-  script.js")]
});
//MAIN REGEX
var regex = /\+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}/g; 

var text = $("body:first").html();

var textNodes = $("body:first").find('*').contents().filter(function(){

if(this.nodeType == 3 && regex.test(this.nodeValue) && this.parentElement.tagName !== "A"){
    var anchor = document.createElement('a');
    //alert(this.nodeValue.match(regex)[0]);
    //anchor.setAttribute('href', this.nodeValue);

    anchor.setAttribute('href', this.nodeValue.match(regex)[0]);

    anchor.appendChild(document.createTextNode(this.nodeValue.match(regex)[0]));

    //alert(this.nodeValue.match(regex));


    if(this.nextSibling)
        this.parentElement.insertBefore(anchor, this.nextSibling);


    else
        this.parentElement.appendChild(anchor);


    this.nodeValue = this.nodeValue.replace(regex, '');
}

return this.nodeType === 3;


});
$('a').click(function() {
    // When user clicks on the number it should call another plug-in to initiate    communication
});

抓取窗口并使用
chromeWindow.gBrowser.selectedTab.linkedBrowser.contentWindow.wrappedJSObject.$


wrappedJSObject允许您访问该窗口中的所有js

@Chris:谢谢链接。我已经理解了消息传递背后的概念,但我无法理解如何调用插件。由于该插件可以检测网页上的电话号码,因此用户可以单击该号码以提供点击通话功能。以上是我的代码我不明白你的意思,因为我是开发附加组件的初学者。你能帮我翻译一下吗?提前谢谢。我不知道如何把它放在插件sdk中,也许有人能帮我把它翻译成sdk。