diff --git a/drivers/firefox/lib/driver.js b/drivers/firefox/lib/driver.js
index 9bc09539e..140c47f29 100644
--- a/drivers/firefox/lib/driver.js
+++ b/drivers/firefox/lib/driver.js
@@ -13,15 +13,35 @@
ss = require('sdk/simple-storage'),
sp = require("sdk/simple-prefs"),
tabs = require('sdk/tabs'),
+ initTab,
+ Panel,
panel,
+ Widget,
widget,
- initTab,
- addIcon,
- removeIcons,
- createPanel,
- createWidget,
- getUrlBar,
- getDocument;
+ UrlBar,
+ urlBar;
+
+ exports.main = function(options, callbacks) {
+ w.log('main: ' + options.loadReason);
+
+ w.init();
+ };
+
+ exports.onUnload = function(reason) {
+ w.log('unload: ' + reason);
+
+ if ( urlBar ) {
+ urlBar.destroy();
+ }
+
+ if ( widget ) {
+ widget.destroy();
+ }
+
+ if ( panel ) {
+ panel.destroy();
+ }
+ };
initTab = function(tab) {
tabCache[tab.id] = { count: 0, appsDetected: [] };
@@ -34,7 +54,7 @@
worker.port.on('analyze', function(message) {
var url = message.url.replace(/#.*$/, '');
- if ( headersCache[url] !== undefined ) {
+ if ( typeof headersCache[url] !== 'undefined' ) {
message.analyze.headers = headersCache[url];
}
@@ -57,42 +77,10 @@
w.driver.displayApps();
});
- addIcon = function(appName) {
- var
- icon = getDocument().createElement('image'),
- url = appName !== undefined ? 'images/icons/' + appName + '.png' : 'images/icon32.png',
- tooltipText = ( appName !== undefined ? appName + ' - ' + require('sdk/l10n').get('clickForDetails') + ' - ' : '' ) + require('sdk/l10n').get('name');
-
- icon.setAttribute('src', data.url(url));
- icon.setAttribute('class', 'wappalyzer-icon');
- icon.setAttribute('width', '16');
- icon.setAttribute('height', '16');
- icon.setAttribute('style', 'margin: 0 1px;');
- icon.setAttribute('tooltiptext', tooltipText);
+ Panel = function() {
+ var self = this;
- getUrlBar().appendChild(icon);
-
- return icon;
- };
-
- removeIcons = function() {
- var icons;
-
- do {
- icons = getUrlBar().getElementsByClassName('wappalyzer-icon');
-
- if ( icons.length ) {
- getUrlBar().removeChild(icons[0]);
- }
- } while ( icons.length );
- };
-
- createPanel = function() {
- if ( panel ) {
- panel.destroy();
- }
-
- panel = require('sdk/panel').Panel({
+ this.panel = require('sdk/panel').Panel({
width: 250,
height: 50,
contentURL: data.url('panel.html'),
@@ -100,70 +88,106 @@
position: { right: 30, top: 30 }
});
- panel.port.on('resize', function(height) {
- panel.height = height;
+ this.panel.port.on('resize', function(height) {
+ self.panel.height = height;
});
- panel.port.on('goToUrl', function(url) {
- panel.hide();
+ this.panel.port.on('goToUrl', function(url) {
+ self.panel.hide();
w.driver.goToURL({ url: w.config.websiteURL + url, medium: 'panel' });
});
- }
+ };
- createWidget = function() {
- createPanel();
+ Panel.prototype.get = function() {
+ return this.panel;
+ };
- widget = require('sdk/widget').Widget({
+ Panel.prototype.destroy = function() {
+ this.panel.destroy();
+ };
+
+ Widget = function(panel) {
+ this.widget = require('sdk/widget').Widget({
id: 'wappalyzer',
label: 'Wappalyzer',
contentURL: data.url('images/icon32.png'),
- panel: panel
+ panel: panel.get()
});
- }
+ };
+
+ Widget.prototype.get = function() {
+ return this.widget;
+ };
+
+ Widget.prototype.destroy = function() {
+ this.widget.destroy();
+ };
+
+ UrlBar = function(panel) {
+ var self = this;
+
+ this.panel = panel;
+
+ this.onClick = function() {
+ self.panel.get().show();
+ }
+
+ this.document = mediator.getMostRecentWindow('navigator:browser').document;
+
+ this.urlBar = this.document.createElement('hbox');
+
+ this.urlBar.setAttribute('id', 'wappalyzer-urlbar');
+ this.urlBar.setAttribute('style', 'cursor: pointer; margin: 0 2px;');
+ this.urlBar.setAttribute('tooltiptext', require('sdk/l10n').get('name'));
- getUrlBar = function() {
+ this.urlBar.addEventListener('click', this.onClick);
+
+ this.document.getElementById('urlbar-icons').appendChild(this.urlBar);
+ };
+
+ UrlBar.prototype.get = function() {
+ return this.urlBar;
+ };
+
+ UrlBar.prototype.addIcon = function(appName) {
var
- urlBar = getDocument().getElementById('wappalyzer-urlbar'),
- show = true;
+ icon = this.document.createElement('image'),
+ url = typeof appName !== 'undefined' ? 'images/icons/' + appName + '.png' : 'images/icon32.png',
+ tooltipText = ( typeof appName !== 'undefined' ? appName + ' - ' + require('sdk/l10n').get('clickForDetails') + ' - ' : '' ) + require('sdk/l10n').get('name');
- if ( !urlBar ) {
- urlBar = getDocument().createElement('hbox');
+ icon.setAttribute('src', data.url(url));
+ icon.setAttribute('class', 'wappalyzer-icon');
+ icon.setAttribute('width', '16');
+ icon.setAttribute('height', '16');
+ icon.setAttribute('style', 'margin: 0 1px;');
+ icon.setAttribute('tooltiptext', tooltipText);
- urlBar.setAttribute('id', 'wappalyzer-urlbar');
- urlBar.setAttribute('style', 'cursor: pointer; margin: 0 2px;');
- urlBar.setAttribute('tooltiptext', require('sdk/l10n').get('name'));
+ this.get().appendChild(icon);
- urlBar.addEventListener('mouseover', function() {
- if ( panel.isShowing ) {
- show = false;
- }
- });
+ return this;
+ };
- urlBar.addEventListener('mouseout', function() {
- show = true;
- });
+ UrlBar.prototype.clear = function() {
+ var icons;
- urlBar.addEventListener('click', function() {
- if ( show ) {
- panel.show();
+ do {
+ icons = this.get().getElementsByClassName('wappalyzer-icon');
- show = false;
- } else {
- panel.hide();
+ if ( icons.length ) {
+ urlBar.get().removeChild(icons[0]);
+ }
+ } while ( icons.length );
- show = true;
- }
- }, false);
+ return this;
+ };
- getDocument().getElementById('urlbar-icons').appendChild(urlBar);
- }
+ UrlBar.prototype.destroy = function() {
+ this.urlBar.removeEventListener('click', this.onClick);
- return urlBar;
- }
+ this.urlBar.remove();
- getDocument = function() {
- return mediator.getMostRecentWindow('navigator:browser').document;
+ return this;
}
w.driver = {
@@ -180,10 +204,14 @@
init: function(callback) {
var json = JSON.parse(data.load('apps.json'));
+ w.log('driver.init');
+
+ panel = new Panel();
+
if ( sp.prefs.urlbar ) {
- createPanel();
+ urlBar = new UrlBar(panel);
} else {
- createWidget();
+ widget = new Widget(panel);
}
try {
@@ -210,14 +238,16 @@
}
sp.on('urlbar', function() {
+ panel = new Panel();
+
if ( !sp.prefs.urlbar ) {
- removeIcons();
+ urlBar.destroy();
- createWidget();
+ widget = new Widget(panel);
} else {
- widget.destroy();
+ urlBar = new UrlBar(panel);
- createPanel();
+ widget.get().destroy();
}
w.driver.displayApps();
@@ -246,7 +276,7 @@
}
if ( subject.contentType === 'text/html' ) {
- if ( headersCache[uri] === undefined ) {
+ if ( typeof headersCache[uri] === 'undefined' ) {
headersCache[uri] = {};
}
@@ -258,12 +288,14 @@
};
httpRequestObserver.init();
+
+ w.driver.displayApps();
},
goToURL: function(args) {
var url = args.url + ( typeof args.medium === 'undefined' ? '' : '?pk_campaign=firefox&pk_kwd=' + args.medium);
- tabs.open({ url: url, inBackground: args.background !== undefined && args.background });
+ tabs.open({ url: url, inBackground: typeof args.background !== 'undefined' && args.background });
},
displayApps: function() {
@@ -273,15 +305,17 @@
w.log('display apps');
- if ( panel === undefined ) {
+ if ( !panel.get() ) {
+ panel = new Panel();
+
if ( sp.prefs.urlbar ) {
- createPanel();
+ urlBar = new UrlBar(panel);
} else {
- createWidget();
+ widget = new Widget(panel);
}
}
- if ( tabCache[tabs.activeTab.id] === undefined ) {
+ if ( typeof tabCache[tabs.activeTab.id] === 'undefined' ) {
initTab(tabs.activeTab);
}
@@ -289,18 +323,18 @@
tabCache[tabs.activeTab.id].appsDetected = w.detected[url];
if ( sp.prefs.urlbar ) {
- removeIcons();
+ urlBar.clear();
// Add icons
if ( count ) {
for ( appName in tabCache[tabs.activeTab.id].appsDetected ) {
- addIcon(appName);
+ urlBar.addIcon(appName);
}
} else {
- addIcon();
+ urlBar.addIcon();
}
} else {
- widget.contentURL = data.url('images/icon32_hot.png');
+ widget.get().contentURL = data.url('images/icon32_hot.png');
if ( count ) {
// Find the main application to display
@@ -312,7 +346,7 @@
for ( appName in w.detected[url] ) {
w.apps[appName].cats.forEach(function(cat) {
if ( cat == match && !found ) {
- widget.contentURL = data.url('images/icons/' + appName + '.png'),
+ widget.get().contentURL = data.url('images/icons/' + appName + '.png'),
found = true;
}
@@ -322,7 +356,7 @@
}
}
- panel.port.emit('displayApps', { tabCache: tabCache[tabs.activeTab.id], apps: w.apps, categories: w.categories, categoryNames: categoryNames });
+ panel.get().port.emit('displayApps', { tabCache: tabCache[tabs.activeTab.id], apps: w.apps, categories: w.categories, categoryNames: categoryNames });
},
ping: function() {
@@ -386,7 +420,5 @@
36, // Advertising Network
19 // Miscellaneous
]
- }
-
- w.init();
+ };
}());
diff --git a/drivers/firefox/package.json b/drivers/firefox/package.json
index bc27918d4..e22f5fb91 100644
--- a/drivers/firefox/package.json
+++ b/drivers/firefox/package.json
@@ -8,7 +8,7 @@
"description": "Identifies software on the web",
"author": "Elbert Alias",
"license": "GPLv3",
- "version": "3.0.5",
+ "version": "3.0.8",
"main": "driver",
"preferences": [{
"name": "tracking",
diff --git a/package.json b/package.json
deleted file mode 100644
index d5d5a4b18..000000000
--- a/package.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "name": "Wappalyzer",
- "version": "1.1.2",
- "description": "Wappalyzer is a cross-platform utility that uncovers the technologies used on websites. It detects content management systems, web shops, web servers, JavaScript frameworks, analytics tools and many more.",
- "main": "./share/js/wappalyzer.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/ElbertF/Wappalyzer"
- },
- "author": "ElbertF",
- "license": "GNU GPL",
- "bugs": {
- "url": "https://github.com/ElbertF/Wappalyzer/issues"
- },
- "homepage": "https://wappalyzer.com/"
-}
diff --git a/share/apps.json b/share/apps.json
index 83b2abf90..a1e65aaf3 100644
--- a/share/apps.json
+++ b/share/apps.json
@@ -790,7 +790,7 @@
"DTG": {
"website": "www.dtg.nl",
"cats": [ 1 ],
- "html": [ "Site Powered by DTG", "var u=\\(\\('https:' == d\\.location\\.protocol\\) \\? 'https://resellerstat\\.mono\\.net/dtg/' : 'http://resellerstat\\.mono\\.net/dtg/'\\);" ],
+ "html": [ "]+>Site Powered by DTG", "var u=\\(\\('https:' == d\\.location\\.protocol\\) \\? 'https://resellerstat\\.mono\\.net/dtg/' : 'http://resellerstat\\.mono\\.net/dtg/'\\);" ],
"implies": "Mono.net"
},
"DreamWeaver": {