我刚开始使用 FireFox Builder 来构建一个简单的插件。我意识到我无法直接访问窗口对象。
我想要做的是获取窗口对象并用一些类和函数污染它,以便我可以从页面本身调用它们。
以下是当前代码:
// This is an active module of the ritcoder Add-on
require("widget").Widget({
id: "widgetID1",
label: "My Mozilla Widget",
contentURL: "http://www.mozilla.org/favicon.ico",
onClick: function(evt){
var tabs = require("tabs");
var activeTab = tabs.activeTab;
var notifications = require("notifications");
notifications.notify({
title: "Jabberwocky",
text: "'Twas brillig, and the slithy toves",
data: "did gyre and gimble in the wabe",
onClick: function (data) {
console.log(data);
// console.log(this.data) would produce the same result.
}
});
activeTab.window.a=20; //this fails
context.alert('yesx');
}
});
我该怎么做呢?将一些代码注入活动页面,以便可以调用它。
问候,