From feb08b5186b6d8261f81a9838afa641d62b454dc Mon Sep 17 00:00:00 2001 From: Elbert Alias Date: Sun, 16 Feb 2014 11:32:46 +1100 Subject: [PATCH] Added URL bar icons --- drivers/firefox-sdk/lib/driver.js | 87 +++++++++++++++++++-- drivers/firefox-sdk/locale/de-DE.properties | 10 +-- drivers/firefox-sdk/locale/en-GB.properties | 10 +-- drivers/firefox-sdk/locale/en-US.properties | 10 +-- drivers/firefox-sdk/locale/es-ES.properties | 10 +-- drivers/firefox-sdk/locale/fr-FR.properties | 10 +-- drivers/firefox-sdk/locale/nl-NL.properties | 10 +-- drivers/firefox-sdk/package.json | 5 ++ drivers/firefox-sdk/test/test-main.js | 12 --- 9 files changed, 93 insertions(+), 71 deletions(-) delete mode 100644 drivers/firefox-sdk/test/test-main.js diff --git a/drivers/firefox-sdk/lib/driver.js b/drivers/firefox-sdk/lib/driver.js index 87964c6b0..b9589613b 100644 --- a/drivers/firefox-sdk/lib/driver.js +++ b/drivers/firefox-sdk/lib/driver.js @@ -5,6 +5,9 @@ {Cc, Ci} = require('chrome'), main = require('wappalyzer'), w = main.wappalyzer, + mediator = Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator), + doc = mediator.getMostRecentWindow('navigator:browser').document, + urlBar = doc.getElementById('urlbar-icons'), tabCache = {}, headersCache = {}, categoryNames = {}, @@ -16,7 +19,8 @@ width: 250, height: 50, contentURL: data.url('panel.html'), - contentScriptFile: data.url('js/panel.js') + contentScriptFile: data.url('js/panel.js'), + position: { right: 30, top: 30 } }), widget = require('sdk/widget').Widget({ id: 'wappalyzer', @@ -24,7 +28,9 @@ contentURL: data.url('images/icon32.png'), panel: panel }), - initTab; + initTab, + addIcon, + removeIcons; initTab = function(tab) { tabCache[tab.id] = { count: 0, appsDetected: [] }; @@ -48,7 +54,7 @@ w.log('[ tab.js ] ' + message); }); }); - } + }; tabs.on('open', initTab); @@ -64,6 +70,57 @@ panel.height = height; }); + addIcon = function(url) { + var + icon = doc.createElement('image'), + show = true; + + + icon.setAttribute('src', data.url(url)); + icon.setAttribute('class', 'wappalyzer-icon'); + icon.setAttribute('width', '16'); + icon.setAttribute('height', '16'); + icon.setAttribute('style', 'cursor: pointer; margin-right: 2px;'); + + icon.addEventListener('mouseover', function() { + if ( panel.isShowing ) { + show = false; + } + }); + + icon.addEventListener('mouseout', function() { + show = true; + }); + + icon.addEventListener('click', function() { + if ( show ) { + panel.show(); + + show = false; + } else { + panel.hide(); + + show = true; + } + }, false); + + urlBar.appendChild(icon); + + return icon; + }; + + removeIcons = function() { + var icons; + + do { + icons = urlBar.getElementsByClassName('wappalyzer-icon'); + + if ( icons.length ) { + urlBar.removeChild(icons[0]); + } + } while ( icons.length ); + }; + w.driver = { /** * Log messages to console @@ -101,6 +158,13 @@ initTab(tab); } + sp.on('urlbar', function() { + console.log('x'); + if ( !sp.prefs.urlbar ) { + removeIcons(); + } + }); + var httpRequestObserver = { init: function() { var observerService = Cc['@mozilla.org/observer-service;1'].getService(Ci.nsIObserverService); @@ -146,8 +210,8 @@ displayApps: function() { var - url = tabs.activeTab.url.replace(/#.*$/, ''), - count = w.detected[url] ? Object.keys(w.detected[url]).length.toString() : '0'; + url = tabs.activeTab.url.replace(/#.*$/, ''), + count = w.detected[url] ? Object.keys(w.detected[url]).length : 0; w.log('display apps'); @@ -158,6 +222,19 @@ tabCache[tabs.activeTab.id].count = count; tabCache[tabs.activeTab.id].appsDetected = w.detected[url]; + if ( sp.prefs.urlbar ) { + removeIcons(); + + // Add icons + if ( count ) { + for ( appName in tabCache[tabs.activeTab.id].appsDetected ) { + addIcon('images/icons/' + appName + '.png'); + } + } else { + addIcon('images/icon32.png'); + } + } + widget.contentURL = data.url('images/icon32.png'); if ( count > 0 ) { diff --git a/drivers/firefox-sdk/locale/de-DE.properties b/drivers/firefox-sdk/locale/de-DE.properties index 9269fedd1..f3851f4b3 100755 --- a/drivers/firefox-sdk/locale/de-DE.properties +++ b/drivers/firefox-sdk/locale/de-DE.properties @@ -1,19 +1,11 @@ name = Wappalyzer noAppsDetected = Keine Applikationen erkannt -addonBar = Wappalyzer has been placed in the add-on bar.\n\nTo show the add-on bar, close this window and press Ctrl+/. -help = Wappalyzer - klicken für Details und Einstellungen -showIcons = Applikations-Icons zeigen preferences = Weitere Optionen ... -addonBar = In Addon-Leiste platzieren (Ctrl+/ oder Cmd+/) categories = Kategorienverwaltung -performance = Performance -interface = Interface tracking_title = Tracken tracking_description = Sende anonyme Reports über gefundene Applikationen zu Forschungszwecken an wappalyzer.com -analyzeHeaders = Analyze response headers -analyzeJavaScript = Analyze JavaScript -analyzeOnload = Analyze onLoad events +urlbar_title = Display icons in URL bar feedback = Feedback github = Github diff --git a/drivers/firefox-sdk/locale/en-GB.properties b/drivers/firefox-sdk/locale/en-GB.properties index ec9648a1e..2bc0ee937 100755 --- a/drivers/firefox-sdk/locale/en-GB.properties +++ b/drivers/firefox-sdk/locale/en-GB.properties @@ -1,19 +1,11 @@ name = Wappalyzer noAppsDetected = No applications detected -addonBar = Wappalyzer has been placed in the add-on bar.\n\nTo show the add-on bar, close this window and press Ctrl+/. -help = Wappalyzer - Click for more detail and settings -showIcons = Show application icons preferences = Options -addonBar = Place in addon-bar (press Ctrl+/ or Cmd+/ to toggle) categories = Categories -performance = Performance -interface = Interface tracking_title = Tracking tracking_description = Anonymously send reports on detected applications to wappalyzer.com for analysis -analyzeHeaders = Analyze response headers -analyzeJavaScript = Analyze JavaScript -analyzeOnload = Analyze onLoad events +urlbar_title = Display icons in URL bar feedback = Feedback github = Github diff --git a/drivers/firefox-sdk/locale/en-US.properties b/drivers/firefox-sdk/locale/en-US.properties index 2b5f958a4..2692e2ae6 100755 --- a/drivers/firefox-sdk/locale/en-US.properties +++ b/drivers/firefox-sdk/locale/en-US.properties @@ -1,19 +1,11 @@ name = Wappalyzer noAppsDetected = No applications detected -addonBar = Wappalyzer has been placed in the add-on bar.\n\nTo show the add-on bar, close this window and press Ctrl+/. -help = Wappalyzer - Click for more detail and settings -showIcons = Show application icons preferences = Options -addonBar = Place in addon-bar (press Ctrl+/ or Cmd+/ to toggle) categories = Categories -performance = Performance -interface = Interface tracking_title = Tracking research_description = Anonymously send reports on detected applications to wappalyzer.com for analysis -analyzeHeaders = Analyze response headers -analyzeJavaScript = Analyze JavaScript -analyzeOnload = Analyze onLoad events +urlbar_title = Display icons in URL bar feedback = Feedback github = Github diff --git a/drivers/firefox-sdk/locale/es-ES.properties b/drivers/firefox-sdk/locale/es-ES.properties index f206eee3b..e215f0227 100755 --- a/drivers/firefox-sdk/locale/es-ES.properties +++ b/drivers/firefox-sdk/locale/es-ES.properties @@ -1,19 +1,11 @@ name = Wappalyzer noAppsDetected = Aplicaciones no detectadas -addonBar = Wappalyzer se ha colocado en la barra de complementos.\n\nPara mostrar la barra de complementos, cierra esta ventana y pulsa Ctrl+/. -help = Wappalyzer - Clic para mas detalles y configuración -showIcons = Mostrar iconos de aplicaciones preferences = Opciones -addonBar = Colocar en barra de complementos (pulsa Ctrl+/ o Cmd+/ para alternar) categories = Categorías -performance = Rendimiento -interface = Interfaz tracking_title = Seguimiento tracking_description = Enviar informes anónimos sobre las aplicaciones detectadas a wappalyzer.com para análisis -analyzeHeaders = Analizar cabeceras de respuesta -analyzeJavaScript = Analizar JavaScript -analyzeOnload = Analizar eventos onLoad +urlbar_title = Display icons in URL bar feedback = Opinión github = Github diff --git a/drivers/firefox-sdk/locale/fr-FR.properties b/drivers/firefox-sdk/locale/fr-FR.properties index 1737a8eeb..aa8b9827b 100644 --- a/drivers/firefox-sdk/locale/fr-FR.properties +++ b/drivers/firefox-sdk/locale/fr-FR.properties @@ -1,19 +1,11 @@ name = Wappalyzer noAppsDetected = Pas d'applications détectées -addonBar = Wappalyzer a été placé dans la barre des modules.\n\n Pour voir la barre des modules pressez Ctrl+/ ou Cmd+/. -help = Wappalyzer - Cliquer pour plus de détails et options -showIcons = Montrer les icônes des applications preferences = Plus d'options... -addonBar = Placer dans la barre des modules (Ctrl+/) categories = Gérer les catégories -performance = Performance -interface = Interface tracking_title = Traçage tracking_description = Envoyer anonymement des rapports sur les applications détectées à wappalyzer.com pour la recherche -analyzeHeaders = Analyser les headers -analyzeJavaScript = Analyser le JavaScript -analyzeOnload = Analyser les évènements au chargement +urlbar_title = Display icons in URL bar feedback = Donner votre avis github = Github diff --git a/drivers/firefox-sdk/locale/nl-NL.properties b/drivers/firefox-sdk/locale/nl-NL.properties index 548359e93..6907ed06d 100755 --- a/drivers/firefox-sdk/locale/nl-NL.properties +++ b/drivers/firefox-sdk/locale/nl-NL.properties @@ -1,19 +1,11 @@ name = Wappalyzer noAppsDetected = Geen applications gedetecteerd -addonBar = Wappalyzer is in de add-on balk geplaatst. Om de add-on te laten zien, sluit dit bericht en druk Ctrl+/. -help = Wappalyzer - Klik voor meer informatie -showIcons = Iconen zichtbaar preferences = Meer opties... -addonBar = Plaats in addon-bar (klik Ctrl+/ of Cmd+/) categories = Beheer categorien -performance = Performance -interface = Interface tracking_title = Tracking tracking_description = Verzend anonieme informatie over applicaties naar wappalyzer.com voor onderzoek -analyzeHeaders = Analiseer response headers -analyzeJavaScript = Analiseer JavaScript -analyzeOnload = Analiseer onLoad events +urlbar_title = Display icons in URL bar feedback = Feedback github = Github diff --git a/drivers/firefox-sdk/package.json b/drivers/firefox-sdk/package.json index 6c7b96144..3a477e8ef 100644 --- a/drivers/firefox-sdk/package.json +++ b/drivers/firefox-sdk/package.json @@ -15,5 +15,10 @@ "description": "Anonymously send reports on detected applications to wappalyzer.com for analysis", "type": "bool", "value": true + }, { + "name": "urlbar", + "title": "Display icons in URL bar", + "type": "bool", + "value": true }] } diff --git a/drivers/firefox-sdk/test/test-main.js b/drivers/firefox-sdk/test/test-main.js deleted file mode 100644 index 147f98adf..000000000 --- a/drivers/firefox-sdk/test/test-main.js +++ /dev/null @@ -1,12 +0,0 @@ -var main = require("./main"); - -exports["test main"] = function(assert) { - assert.pass("Unit test running!"); -}; - -exports["test main async"] = function(assert, done) { - assert.pass("async Unit test running!"); - done(); -}; - -require("sdk/test").run(exports);