2
我想創建一個bootstrapped firefox擴展來獲取當前標籤的URL和標題。問題是,我想檢查一下標籤網址在其url中是否包含「about:」字樣。我建議的解決方案是使用瀏覽器本地string.substr()javascript函數來檢查require(「sdk/tabs」).activeTab.url「。是否有任何可能性使用瀏覽器原生javasript小部件或ToolbarButton onClick方法上的函數?獲取激活瀏覽器選項卡屬性在Firefox插件建設者
exports.main = function(options) {
var base64 = require("sdk/base64");
var panel = require("sdk/panel").Panel({
width: 700,
height: 470,
onHide: function()
{
panel.contentURL = "about:blank";
}
});
var tbb = require("toolbarbutton").ToolbarButton({
id: "extension-tbb-id",
label: "IFShare+",
image: "https://www.fasdfasd.es/factory/templates/templateforidkreader/favicon.ico",
panel: panel,
onClick: function()
{
windowPanel = require("sdk/tabs").activeTab;
title = windowPanel.title;
url = windowPanel.url;
// Is any posibility to do something like that ????
contentScript: "if("+url+".substring(0,5)=='about:'){"
{
url='';
title='';
}
contentScript: "}"
this.panel.contentURL = "https://www.fasdfasdf.es/factory/index2.php?option=com_idkreader&view=shareplus&task=window&Itemid=0&url="+base64.encode(url, "utf-8")+'&title='+base64.encode(title, "utf-8")+'&ref=ext';
},
});
// move the toolbar button to the navigation bar
if ("install" == options.loadReason) {
tbb.moveTo({toolbarID: "nav-bar"});
}
}
我很感激你的幫助,它真的很有用。或多或少你已經回答了我的關注。現在我更加了解插件創建和JavaScript。 – user2563541