diff --git a/drivers/bookmarklet/js/wappalyzer.js b/drivers/bookmarklet/js/wappalyzer.js
index fe5a50767..299fbe6c3 100644
--- a/drivers/bookmarklet/js/wappalyzer.js
+++ b/drivers/bookmarklet/js/wappalyzer.js
@@ -19,7 +19,7 @@ var wappalyzer = wappalyzer || (function() {
return;
}
- if ( func != 'log' ) w.log('w.driver.' + func);
+ if ( func !== 'log' ) { w.log('w.driver.' + func); }
return w.driver[func](args);
};
@@ -51,7 +51,7 @@ var wappalyzer = wappalyzer || (function() {
*/
log: function(message, type) {
if ( w.config.environment === 'dev' ) {
- if ( type == null ) type = 'debug';
+ if ( type == null ) { type = 'debug'; }
driver('log', { message: '[wappalyzer ' + type + '] ' + message, type: type });
}
@@ -78,8 +78,17 @@ var wappalyzer = wappalyzer || (function() {
// Initialize driver
driver('init', function() {
- if ( w.config.firstRun ) driver('goToURL', { url: w.config.websiteURL + 'installed' });
- if ( w.config.upgraded ) driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
+ if ( w.config.firstRun ) {
+ driver('goToURL', { url: w.config.websiteURL + 'installed' });
+
+ w.config.firstRun = false;
+ }
+
+ if ( w.config.upgraded ) {
+ driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
+
+ w.config.upgraded = false;
+ }
});
},
@@ -89,29 +98,29 @@ var wappalyzer = wappalyzer || (function() {
analyze: function(hostname, url, data) {
w.log('w.analyze');
- var apps = new Array();
+ var app, type, apps = [];
- if ( w.history[hostname] == null ) w.history[hostname] = new Array();
- if ( w.detected[url] == null ) w.detected[url] = new Array();
+ if ( w.history[hostname] == null ) { w.history[hostname] = []; }
+ if ( w.detected[url] == null ) { w.detected[url] = []; }
if ( data ) {
- for ( var app in w.apps ) {
- for ( var type in w.apps[app] ) {
- if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) continue; // Skip if the app has already been detected
+ for ( app in w.apps ) {
+ for ( type in w.apps[app] ) {
+ if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) { continue; } // Skip if the app has already been detected
switch ( type ) {
case 'url':
- if ( w.apps[app].url.test(url) ) apps.push(app);
+ if ( w.apps[app].url.test(url) ) { apps.push(app); }
break;
case 'html':
- if ( data[type] == null ) break;
+ if ( data[type] == null ) { break; }
- if ( w.apps[app][type].test(data[type]) ) apps.push(app);
+ if ( w.apps[app][type].test(data[type]) ) { apps.push(app); }
break;
case 'script':
- if ( data['html'] == null ) break;
+ if ( data['html'] == null ) { break; }
var
regex = /
+
diff --git a/drivers/chrome/css/popup.css b/drivers/chrome/css/popup.css
index fe24e1703..586728fff 100644
--- a/drivers/chrome/css/popup.css
+++ b/drivers/chrome/css/popup.css
@@ -69,7 +69,7 @@ img {
}
#analyze-headers.pending {
- background: url('images/pending.gif') center center no-repeat;
+ background: url('../images/pending.gif') center center no-repeat;
color: #999;
text-indent: -999px;
- }
\ No newline at end of file
+ }
diff --git a/drivers/chrome/js/driver.js b/drivers/chrome/js/driver.js
index d792b1ae6..45442dcd7 100644
--- a/drivers/chrome/js/driver.js
+++ b/drivers/chrome/js/driver.js
@@ -5,12 +5,7 @@
(function() {
if ( wappalyzer == null ) { return; }
- var w = wappalyzer;
-
- var
- tab,
- tabCache = {}
- ;
+ var w = wappalyzer, tab, tabCache = {};
w.driver = {
/**
@@ -28,6 +23,24 @@
chrome.browserAction.setBadgeBackgroundColor({ color: [255, 102, 0, 255] });
+ // Version check
+ try {
+ var version = chrome.app.getDetails().version;
+
+ if ( localStorage['version'] == null ) {
+ w.config.firstRun = true;
+
+ // Set defaults
+ for ( option in defaults ) {
+ localStorage[option] = defaults[option];
+ }
+ } else if ( version !== localStorage['version'] ) {
+ w.config.upgraded = true;
+ }
+
+ localStorage['version'] = version;
+ } catch(e) { }
+
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
if ( typeof request.id != 'undefined' ) {
w.log('request: ' + request.id);
@@ -40,7 +53,13 @@
case 'analyze':
tab = sender.tab;
- w.analyze(tab.url, tab.url, request.subject);
+ var hostname, a = document.createElement('a');
+
+ a.href = tab.url;
+
+ hostname = a.hostname;
+
+ w.analyze(hostname, tab.url, request.subject);
for ( subject in request.subject ) {
tabCache[tab.id].analyzed.push(subject);
@@ -72,6 +91,12 @@
tabCache[tabId] = null;
});
+
+ callback();
+ },
+
+ goToURL: function(args) {
+ window.open(args.url);
},
/**
@@ -93,10 +118,12 @@
if ( count > 0 ) {
// Find the main application to display
- var found = false;
+ var i, appName, found = false;
w.driver.categoryOrder.map(function(match) {
- w.detected[tab.url].map(function(appName) {
+ for ( i in w.detected[tab.url] ) {
+ appName = w.detected[tab.url][i];
+
w.apps[appName].cats.map(function(cat) {
if ( cat === match && !found ) {
chrome.browserAction.setIcon({ tabId: tab.id, path: 'images/icons/' + appName + '.png' });
@@ -104,13 +131,59 @@
found = true;
}
});
- });
+ }
});
chrome.browserAction.setBadgeText({ tabId: tab.id, text: count });
};
},
+ /**
+ * Anonymously track detected applications
+ */
+ track: function() {
+ if ( localStorage['tracking'] ) {
+ var i, data, report = '';
+
+ if ( w.history ) {
+ for ( hostname in w.history ) {
+ report += '[' + hostname;
+
+ w.history[hostname].map(function(data) {
+ report += '|' + data.app + ':' + data.hits;
+ });
+
+ report += ']';
+ }
+
+ // Make POST request
+ var request = new XMLHttpRequest();
+
+ request.open('POST', w.config.websiteURL + '_track.php', true);
+
+ request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+
+ request.onreadystatechange = function(e) {
+ if ( request.readyState == 4 ) {
+ if ( request.status == 200 ) {
+ w.history = [];
+
+ w.log('w.driver.track: ' + report);
+ }
+
+ report = '';
+
+ if ( request.close ) { request.close(); }
+
+ request = null;
+ }
+ };
+
+ request.send('d=' + encodeURIComponent(report));
+ }
+ }
+ },
+
categoryOrder: [ // Used to pick the main application
1, // CMS
11, // Blog
diff --git a/drivers/chrome/js/ga.js b/drivers/chrome/js/ga.js
index 1e5704eba..7890a76df 100644
--- a/drivers/chrome/js/ga.js
+++ b/drivers/chrome/js/ga.js
@@ -10,7 +10,7 @@ _gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script');
- ga.src = 'https://ssl.google-analytics.com/u/ga_debug.js';
+ ga.src = 'https://ssl.google-analytics.com/ga.js';
ga.async = true;
var s = document.getElementsByTagName('script')[0];
diff --git a/drivers/chrome/js/options.js b/drivers/chrome/js/options.js
index e2462cfbb..2f09cf75c 100644
--- a/drivers/chrome/js/options.js
+++ b/drivers/chrome/js/options.js
@@ -1,8 +1,6 @@
$(function() {
var options = {
- opts: {
- tracking: 1
- },
+ opts: defaults,
init: function() {
options.load();
diff --git a/drivers/chrome/js/wappalyzer.js b/drivers/chrome/js/wappalyzer.js
index fe5a50767..299fbe6c3 100644
--- a/drivers/chrome/js/wappalyzer.js
+++ b/drivers/chrome/js/wappalyzer.js
@@ -19,7 +19,7 @@ var wappalyzer = wappalyzer || (function() {
return;
}
- if ( func != 'log' ) w.log('w.driver.' + func);
+ if ( func !== 'log' ) { w.log('w.driver.' + func); }
return w.driver[func](args);
};
@@ -51,7 +51,7 @@ var wappalyzer = wappalyzer || (function() {
*/
log: function(message, type) {
if ( w.config.environment === 'dev' ) {
- if ( type == null ) type = 'debug';
+ if ( type == null ) { type = 'debug'; }
driver('log', { message: '[wappalyzer ' + type + '] ' + message, type: type });
}
@@ -78,8 +78,17 @@ var wappalyzer = wappalyzer || (function() {
// Initialize driver
driver('init', function() {
- if ( w.config.firstRun ) driver('goToURL', { url: w.config.websiteURL + 'installed' });
- if ( w.config.upgraded ) driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
+ if ( w.config.firstRun ) {
+ driver('goToURL', { url: w.config.websiteURL + 'installed' });
+
+ w.config.firstRun = false;
+ }
+
+ if ( w.config.upgraded ) {
+ driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
+
+ w.config.upgraded = false;
+ }
});
},
@@ -89,29 +98,29 @@ var wappalyzer = wappalyzer || (function() {
analyze: function(hostname, url, data) {
w.log('w.analyze');
- var apps = new Array();
+ var app, type, apps = [];
- if ( w.history[hostname] == null ) w.history[hostname] = new Array();
- if ( w.detected[url] == null ) w.detected[url] = new Array();
+ if ( w.history[hostname] == null ) { w.history[hostname] = []; }
+ if ( w.detected[url] == null ) { w.detected[url] = []; }
if ( data ) {
- for ( var app in w.apps ) {
- for ( var type in w.apps[app] ) {
- if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) continue; // Skip if the app has already been detected
+ for ( app in w.apps ) {
+ for ( type in w.apps[app] ) {
+ if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) { continue; } // Skip if the app has already been detected
switch ( type ) {
case 'url':
- if ( w.apps[app].url.test(url) ) apps.push(app);
+ if ( w.apps[app].url.test(url) ) { apps.push(app); }
break;
case 'html':
- if ( data[type] == null ) break;
+ if ( data[type] == null ) { break; }
- if ( w.apps[app][type].test(data[type]) ) apps.push(app);
+ if ( w.apps[app][type].test(data[type]) ) { apps.push(app); }
break;
case 'script':
- if ( data['html'] == null ) break;
+ if ( data['html'] == null ) { break; }
var
regex = /
+
diff --git a/drivers/firefox/content/js/driver.js b/drivers/firefox/content/js/driver.js
index 5ec1e1265..61e40d2a5 100644
--- a/drivers/firefox/content/js/driver.js
+++ b/drivers/firefox/content/js/driver.js
@@ -199,7 +199,7 @@
});
report += ']';
- };
+ }
// Make POST request
var request = new XMLHttpRequest();
@@ -213,16 +213,16 @@
request.onreadystatechange = function(e) {
if ( request.readyState == 4 ) {
if ( request.status == 200 ) {
- w.history = new Object();
+ w.history = [];
w.log('w.driver.track: ' + report);
}
report = '';
- if ( request.close ) request.close();
+ if ( request.close ) { request.close(); }
- request = false;
+ request = null;
}
};
diff --git a/drivers/firefox/content/js/wappalyzer.js b/drivers/firefox/content/js/wappalyzer.js
index fe5a50767..299fbe6c3 100644
--- a/drivers/firefox/content/js/wappalyzer.js
+++ b/drivers/firefox/content/js/wappalyzer.js
@@ -19,7 +19,7 @@ var wappalyzer = wappalyzer || (function() {
return;
}
- if ( func != 'log' ) w.log('w.driver.' + func);
+ if ( func !== 'log' ) { w.log('w.driver.' + func); }
return w.driver[func](args);
};
@@ -51,7 +51,7 @@ var wappalyzer = wappalyzer || (function() {
*/
log: function(message, type) {
if ( w.config.environment === 'dev' ) {
- if ( type == null ) type = 'debug';
+ if ( type == null ) { type = 'debug'; }
driver('log', { message: '[wappalyzer ' + type + '] ' + message, type: type });
}
@@ -78,8 +78,17 @@ var wappalyzer = wappalyzer || (function() {
// Initialize driver
driver('init', function() {
- if ( w.config.firstRun ) driver('goToURL', { url: w.config.websiteURL + 'installed' });
- if ( w.config.upgraded ) driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
+ if ( w.config.firstRun ) {
+ driver('goToURL', { url: w.config.websiteURL + 'installed' });
+
+ w.config.firstRun = false;
+ }
+
+ if ( w.config.upgraded ) {
+ driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
+
+ w.config.upgraded = false;
+ }
});
},
@@ -89,29 +98,29 @@ var wappalyzer = wappalyzer || (function() {
analyze: function(hostname, url, data) {
w.log('w.analyze');
- var apps = new Array();
+ var app, type, apps = [];
- if ( w.history[hostname] == null ) w.history[hostname] = new Array();
- if ( w.detected[url] == null ) w.detected[url] = new Array();
+ if ( w.history[hostname] == null ) { w.history[hostname] = []; }
+ if ( w.detected[url] == null ) { w.detected[url] = []; }
if ( data ) {
- for ( var app in w.apps ) {
- for ( var type in w.apps[app] ) {
- if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) continue; // Skip if the app has already been detected
+ for ( app in w.apps ) {
+ for ( type in w.apps[app] ) {
+ if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) { continue; } // Skip if the app has already been detected
switch ( type ) {
case 'url':
- if ( w.apps[app].url.test(url) ) apps.push(app);
+ if ( w.apps[app].url.test(url) ) { apps.push(app); }
break;
case 'html':
- if ( data[type] == null ) break;
+ if ( data[type] == null ) { break; }
- if ( w.apps[app][type].test(data[type]) ) apps.push(app);
+ if ( w.apps[app][type].test(data[type]) ) { apps.push(app); }
break;
case 'script':
- if ( data['html'] == null ) break;
+ if ( data['html'] == null ) { break; }
var
regex = /