Hide toolbar button by default, toggle between button and URL bar

main
Elbert Alias 11 years ago
parent 31f69f3429
commit 109b67e978

@ -15,26 +15,21 @@
ss = require('sdk/simple-storage'), ss = require('sdk/simple-storage'),
sp = require("sdk/simple-prefs"), sp = require("sdk/simple-prefs"),
tabs = require('sdk/tabs'), tabs = require('sdk/tabs'),
panel = require('sdk/panel').Panel({ panel,
width: 250, widget,
height: 50,
contentURL: data.url('panel.html'),
contentScriptFile: data.url('js/panel.js'),
position: { right: 30, top: 30 }
}),
widget = require('sdk/widget').Widget({
id: 'wappalyzer',
label: 'Wappalyzer',
contentURL: data.url('images/icon32.png'),
panel: panel
}),
initTab, initTab,
addIcon, addIcon,
removeIcons; removeIcons,
createPanel,
createWidget;
initTab = function(tab) { initTab = function(tab) {
tabCache[tab.id] = { count: 0, appsDetected: [] }; tabCache[tab.id] = { count: 0, appsDetected: [] };
if ( !sp.prefs.urlbar ) {
createWidget();
}
tab.on('ready', function(tab) { tab.on('ready', function(tab) {
var worker = tab.attach({ var worker = tab.attach({
contentScriptFile: data.url('js/tab.js') contentScriptFile: data.url('js/tab.js')
@ -66,10 +61,6 @@
w.driver.displayApps(); w.driver.displayApps();
}); });
panel.port.on('resize', function(height) {
panel.height = height;
});
addIcon = function(url) { addIcon = function(url) {
var var
icon = doc.createElement('image'), icon = doc.createElement('image'),
@ -121,6 +112,35 @@
} while ( icons.length ); } while ( icons.length );
}; };
createPanel = function() {
if ( panel ) {
panel.destroy();
}
panel = require('sdk/panel').Panel({
width: 250,
height: 50,
contentURL: data.url('panel.html'),
contentScriptFile: data.url('js/panel.js'),
position: { right: 30, top: 30 }
});
panel.port.on('resize', function(height) {
panel.height = height;
});
}
createWidget = function() {
createPanel();
widget = require('sdk/widget').Widget({
id: 'wappalyzer',
label: 'Wappalyzer',
contentURL: data.url('images/icon32.png'),
panel: panel
});
}
w.driver = { w.driver = {
/** /**
* Log messages to console * Log messages to console
@ -135,6 +155,12 @@
init: function(callback) { init: function(callback) {
var json = JSON.parse(data.load('apps.json')); var json = JSON.parse(data.load('apps.json'));
if ( sp.prefs.urlbar ) {
createPanel();
} else {
createWidget();
}
try { try {
var version = require('sdk/self').version; var version = require('sdk/self').version;
@ -161,6 +187,14 @@
sp.on('urlbar', function() { sp.on('urlbar', function() {
if ( !sp.prefs.urlbar ) { if ( !sp.prefs.urlbar ) {
removeIcons(); removeIcons();
createWidget();
} else {
widget.destroy();
createPanel();
w.driver.displayApps();
} }
}); });
@ -215,6 +249,7 @@
w.log('display apps'); w.log('display apps');
if ( tabCache[tabs.activeTab.id] === undefined ) { if ( tabCache[tabs.activeTab.id] === undefined ) {
console.log(tabs);
initTab(tabs.activeTab); initTab(tabs.activeTab);
} }
@ -234,13 +269,13 @@
} }
} }
widget.contentURL = data.url('images/icon32.png');
if ( count > 0 ) { if ( count > 0 ) {
// Find the main application to display // Find the main application to display
var i, appName, found = false; var i, appName, found = false;
widget.contentURL = data.url('images/icon32_hot.png'), if ( !sp.prefs.urlbar ) {
widget.contentURL = data.url('images/icon32_hot.png');
}
w.driver.categoryOrder.forEach(function(match) { w.driver.categoryOrder.forEach(function(match) {
for ( appName in w.detected[url] ) { for ( appName in w.detected[url] ) {

@ -6,6 +6,7 @@ categories = Kategorienverwaltung
tracking_title = Tracken tracking_title = Tracken
tracking_description = Sende anonyme Reports über gefundene Applikationen zu Forschungszwecken an wappalyzer.com tracking_description = Sende anonyme Reports über gefundene Applikationen zu Forschungszwecken an wappalyzer.com
urlbar_title = Display icons in URL bar urlbar_title = Display icons in URL bar
urlbar_description = Uncheck to display toolbar button.
feedback = Feedback feedback = Feedback
github = Github github = Github

@ -6,6 +6,7 @@ categories = Categories
tracking_title = Tracking tracking_title = Tracking
tracking_description = Anonymously send reports on detected applications to wappalyzer.com for analysis tracking_description = Anonymously send reports on detected applications to wappalyzer.com for analysis
urlbar_title = Display icons in URL bar urlbar_title = Display icons in URL bar
urlbar_description = Uncheck to display toolbar button.
feedback = Feedback feedback = Feedback
github = Github github = Github

@ -6,6 +6,7 @@ categories = Categories
tracking_title = Tracking tracking_title = Tracking
research_description = Anonymously send reports on detected applications to wappalyzer.com for analysis research_description = Anonymously send reports on detected applications to wappalyzer.com for analysis
urlbar_title = Display icons in URL bar urlbar_title = Display icons in URL bar
urlbar_description = Uncheck to display toolbar button.
feedback = Feedback feedback = Feedback
github = Github github = Github

@ -6,6 +6,7 @@ categories = Categorías
tracking_title = Seguimiento tracking_title = Seguimiento
tracking_description = Enviar informes anónimos sobre las aplicaciones detectadas a wappalyzer.com para análisis tracking_description = Enviar informes anónimos sobre las aplicaciones detectadas a wappalyzer.com para análisis
urlbar_title = Display icons in URL bar urlbar_title = Display icons in URL bar
urlbar_description = Uncheck to display toolbar button.
feedback = Opinión feedback = Opinión
github = Github github = Github

@ -6,6 +6,7 @@ categories = Gérer les catégories
tracking_title = Traçage tracking_title = Traçage
tracking_description = Envoyer anonymement des rapports sur les applications détectées à wappalyzer.com pour la recherche tracking_description = Envoyer anonymement des rapports sur les applications détectées à wappalyzer.com pour la recherche
urlbar_title = Display icons in URL bar urlbar_title = Display icons in URL bar
urlbar_description = Uncheck to display toolbar button.
feedback = Donner votre avis feedback = Donner votre avis
github = Github github = Github

@ -6,6 +6,7 @@ categories = Beheer categorien
tracking_title = Tracking tracking_title = Tracking
tracking_description = Verzend anonieme informatie over applicaties naar wappalyzer.com voor onderzoek tracking_description = Verzend anonieme informatie over applicaties naar wappalyzer.com voor onderzoek
urlbar_title = Display icons in URL bar urlbar_title = Display icons in URL bar
urlbar_description = Uncheck to display toolbar button.
feedback = Feedback feedback = Feedback
github = Github github = Github

@ -18,6 +18,7 @@
}, { }, {
"name": "urlbar", "name": "urlbar",
"title": "Display icons in URL bar", "title": "Display icons in URL bar",
"description": "Uncheck to display toolbar button.",
"type": "bool", "type": "bool",
"value": true "value": true
}] }]