Improved environment variable detection

main
ElbertF 14 years ago
parent 3cdb11e0b2
commit 9f18b3dec6

@ -1,8 +1,4 @@
if ( typeof(wappalyzer) == 'undefined' )
{
var wappalyzer = {};
}
if ( typeof wappalyzer != 'undefined' ) {
wappalyzer.cats = {
1: { name: 'CMS', plural: 'CMS' },
2: { name: 'Message Board', plural: 'Message Boards' },
@ -224,3 +220,4 @@ wappalyzer.apps = {
'Zen Cart': { cats: { 1: 6 }, html: /<meta name=("|')generator("|') [^>]+Zen Cart/i },
'Zend': { cats: { 1: 18 }, headers: { 'X-Powered-By': /Zend/ } }
};
}

@ -1,68 +1,53 @@
var wappalyzer = {};
wappalyzer =
{
(function() {
self = {
prevUrl: '',
init: function()
{
wappalyzer.log('init');
init: function() {
self.log('init');
addEventListener('DOMContentLoaded', wappalyzer.onPageLoad, false);
addEventListener('DOMContentLoaded', self.onPageLoad, false);
},
log: function(message)
{
log: function(message) {
var consoleService = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
consoleService.logStringMessage("Wappalyzer content.js: " + message);
},
onPageLoad: function(e)
{
wappalyzer.log('onPageLoad');
onPageLoad: function(e) {
self.log('onPageLoad');
sendAsyncMessage('wappalyzer:onPageLoad', {
href: content.document.location.href,
html: content.document.documentElement.innerHTML,
headers: [],
environmentVars: wappalyzer.getEnvironmentVars()
});
self.getEnvironmentVars();
},
onUrlChange: function(request)
{
wappalyzer.log('onUrlChange');
onUrlChange: function(request) {
self.log('onUrlChange');
self.getEnvironmentVars();
},
urlChange:
{
QueryInterface: function(iid)
{
urlChange: {
QueryInterface: function(iid) {
if ( iid.equals(Components.interfaces.nsIWebProgressListener) ||
iid.equals(Components.interfaces.nsISupportsWeakReference) ||
iid.equals(Components.interfaces.nsISupports) )
{
iid.equals(Components.interfaces.nsISupports) ) {
return this;
}
throw Components.results.NS_NOINTERFACE;
},
onLocationChange: function(progress, request, url)
{
if ( !url )
{
wappalyzer.prevUrl = '';
onLocationChange: function(progress, request, url) {
if ( !url ) {
self.prevUrl = '';
return;
}
if ( url.spec != wappalyzer.prevUrl )
{
wappalyzer.prevUrl = url.spec;
if ( url.spec != self.prevUrl ) {
self.prevUrl = url.spec;
wappalyzer.onUrlChange(request);
self.onUrlChange(request);
}
},
@ -72,28 +57,52 @@ wappalyzer =
onSecurityChange: function(a, b, c) {}
},
getEnvironmentVars: function()
{
getEnvironmentVars: function() {
self.log('getEnvironmentVars');
var environmentVars = '';
try {
var element = content.document.createElement('wappalyzerData');
element.setAttribute('id', 'wappalyzer-data');
element.setAttribute('style', 'display: none;');
element.setAttribute('id', 'wappalyzerData');
content.document.documentElement.appendChild(element);
element.addEventListener('wappalyzerEvent', (function(event) {
environmentVars = event.target.innerHTML.split(' ');
self.log('getEnvironmentVars: ' + environmentVars);
var script = content.document.createElement('script');
element.parentNode.removeChild(element);
script.innerHTML = 'for ( i in window ) document.getElementById("wappalyzer-data").innerHTML += i + " ";';
sendAsyncMessage('wappalyzer:onPageLoad', {
href: content.document.location.href,
html: content.document.documentElement.innerHTML,
headers: [],
environmentVars: environmentVars
});
}), true);
content.document.documentElement.appendChild(script);
content.document.documentElement.appendChild(element);
var environmentVars = content.document.getElementById('wappalyzer-data').innerHTML.split(' ');
content.location.href = 'javascript:' +
'(function() {' +
'try {' +
'for ( i in window ) {' +
'window.document.getElementById("wappalyzerData").innerHTML += i + " ";' +
'}' +
element.parentNode.removeChild(element);
script .parentNode.removeChild(script);
'var event = document.createEvent("Events");' + 'event.initEvent("wappalyzerEvent", true, false);' +
'document.getElementById("wappalyzerData").dispatchEvent(event);' +
'}' +
'catch(e) { }' +
'})();';
}
catch(e) { }
return environmentVars;
}
};
}
wappalyzer.init();
self.init();
})();

@ -1,80 +1,62 @@
if ( typeof('wappalyzer') != 'undefined' )
{
var wappalyzer = {};
}
wappalyzer.evaluateCustomApps = function(feedback)
{
if ( typeof 'wappalyzer' != 'undefined' ) {
wappalyzer.evaluateCustomApps = function(feedback) {
wappalyzer.log('evaluateCustomApps');
if ( wappalyzer.customApps )
{
try
{
if ( wappalyzer.customApps ) {
try {
var customAppsJSON = JSON.parse(wappalyzer.customApps);
for ( appName in customAppsJSON )
{
for ( appName in customAppsJSON ) {
wappalyzer.apps[appName] = {};
// Icon
if ( typeof(customAppsJSON[appName].icon) == 'string' )
{
if ( typeof(customAppsJSON[appName].icon) == 'string' ) {
wappalyzer.apps[appName].icon = customAppsJSON[appName].icon;
}
else
{
else {
wappalyzer.apps[appName].icon = 'chrome://wappalyzer/skin/app_icons/_placeholder.ico';
}
// Categories
if ( typeof(customAppsJSON[appName].categories) == 'object' )
{
if ( typeof(customAppsJSON[appName].categories) == 'object' ) {
wappalyzer.apps[appName].cats = {};
for ( i in customAppsJSON[appName].categories )
{
for ( i in customAppsJSON[appName].categories ) {
wappalyzer.apps[appName].cats[i] = parseInt(customAppsJSON[appName].categories[i]);
}
}
// HTML
if ( typeof(customAppsJSON[appName].html) == 'string' )
{
if ( typeof(customAppsJSON[appName].html) == 'string' ) {
wappalyzer.apps[appName].html = new RegExp(customAppsJSON[appName].html, 'i');
}
// URL
if ( typeof(customAppsJSON[appName].url) == 'string' )
{
if ( typeof(customAppsJSON[appName].url) == 'string' ) {
wappalyzer.apps[appName].url = new RegExp(customAppsJSON[appName].url, 'i');
}
// Headers
if ( typeof(customAppsJSON[appName].headers) == 'object' )
{
if ( typeof(customAppsJSON[appName].headers) == 'object' ) {
wappalyzer.apps[appName].headers = {};
for ( headerName in customAppsJSON[appName].headers )
{
for ( headerName in customAppsJSON[appName].headers ) {
wappalyzer.apps[appName].headers[headerName] = new RegExp(customAppsJSON[appName].headers[headerName], 'i');
}
}
}
if ( feedback )
{
if ( feedback ) {
alert('Ok');
}
}
catch(e)
{
catch(e) {
wappalyzer.log('JSON error in custom applications');
if ( feedback )
{
if ( feedback ) {
alert('Error: malformed JSON');
}
}
}
};
}

@ -1,12 +1,7 @@
// Wappalyzer by ElbertF 2009 http://elbertf.com
var wappalyzer = {};
addEventListener('load', function() { wappalyzer.init(); }, false);
addEventListener('unload', function() { wappalyzer.sendReport(); }, false);
wappalyzer =
{
var wappalyzer = (function() {
self = {
apps: {},
appsDetected: 0,
autoDetect: true,
@ -33,164 +28,151 @@ wappalyzer =
strings: {},
version: '',
init: function()
{
wappalyzer.log('init');
init: function() {
self.log('init');
wappalyzer.browser = gBrowser;
self.browser = gBrowser;
wappalyzer.strings = document.getElementById('wappalyzer-strings');
self.strings = document.getElementById('wappalyzer-strings');
// Preferences
wappalyzer.prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService).getBranch('wappalyzer.');
self.prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService).getBranch('wappalyzer.');
wappalyzer.prefs.QueryInterface(Components.interfaces.nsIPrefBranch2);
wappalyzer.prefs.addObserver('', wappalyzer, false);
self.prefs.QueryInterface(Components.interfaces.nsIPrefBranch2);
self.prefs.addObserver('', wappalyzer, false);
wappalyzer.showApps = wappalyzer.prefs.getIntPref('showApps');
wappalyzer.autoDetect = wappalyzer.prefs.getBoolPref('autoDetect');
wappalyzer.customApps = wappalyzer.prefs.getCharPref('customApps');
wappalyzer.debug = wappalyzer.prefs.getBoolPref('debug');
wappalyzer.enableTracking = wappalyzer.prefs.getBoolPref('enableTracking');
wappalyzer.newInstall = wappalyzer.prefs.getBoolPref('newInstall');
wappalyzer.version = wappalyzer.prefs.getCharPref('version');
self.showApps = self.prefs.getIntPref( 'showApps');
self.autoDetect = self.prefs.getBoolPref('autoDetect');
self.customApps = self.prefs.getCharPref('customApps');
self.debug = self.prefs.getBoolPref('debug');
self.enableTracking = self.prefs.getBoolPref('enableTracking');
self.newInstall = self.prefs.getBoolPref('newInstall');
self.version = self.prefs.getCharPref('version');
for ( var i = 1; i <= 23; i ++ )
{
wappalyzer.showCats[i] = wappalyzer.prefs.getBoolPref('cat' + i);
for ( var i = 1; i <= 23; i ++ ) {
self.showCats[i] = self.prefs.getBoolPref('cat' + i);
}
var locationPref = wappalyzer.prefs.getIntPref('location');
var locationPref = self.prefs.getIntPref('location');
wappalyzer.moveLocation(locationPref);
self.moveLocation(locationPref);
// Open page after upgrade
try
{
try {
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var enabledItems = prefs.getCharPref('extensions.enabledItems');
var enabledItems = prefs.getCharPref('extensions.enabledAddons');
var version = enabledItems.replace(/(^.*wappalyzer[^:]+:)([^,]+),.*$/, '$2');
if ( version && wappalyzer.version != version )
{
wappalyzer.browser.addEventListener('load', wappalyzer.upgradeSuccess, false);
if ( version && self.version != version ) {
self.browser.addEventListener('load', self.upgradeSuccess, false);
wappalyzer.version = version;
self.version = version;
wappalyzer.prefs.setCharPref('version', wappalyzer.version);
}
self.prefs.setCharPref('version', self.version);
}
catch(e)
{
}
catch(e) { }
// Open page after installation
if ( wappalyzer.newInstall )
{
wappalyzer.prefs.setBoolPref('newInstall', false);
if ( self.newInstall ) {
self.prefs.setBoolPref('newInstall', false);
wappalyzer.browser.addEventListener('load', wappalyzer.installSuccess, false);
self.browser.addEventListener('load', self.installSuccess, false);
}
if ( typeof messageManager != 'undefined' )
{
// Listen messages sent from the content process
messageManager.addMessageListener('wappalyzer:onPageLoad', wappalyzer.onContentPageLoad);
if ( typeof messageManager != 'undefined' ) {
messageManager.addMessageListener('wappalyzer:onPageLoad', self.onContentPageLoad);
messageManager.loadFrameScript('chrome://wappalyzer/content/content.js', true);
}
// Listen for URL changes
wappalyzer.browser.addProgressListener(wappalyzer.urlChange, Components.interfaces.nsIWebProgress.NOTIFY_LOCATION);
self.browser.addProgressListener(self.urlChange, Components.interfaces.nsIWebProgress.NOTIFY_LOCATION);
// Listen for page loads
wappalyzer.browser.addEventListener('DOMContentLoaded', wappalyzer.onPageLoad, true);
self.browser.addEventListener('DOMContentLoaded', self.onPageLoad, true);
wappalyzer.evaluateCustomApps();
self.evaluateCustomApps();
},
log: function(message)
{
if ( wappalyzer.debug && message )
{
// Log messages to console
log: function(message) {
if ( self.debug && message ) {
var consoleService = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
consoleService.logStringMessage("Wappalyzer: " + message);
}
},
observe: function(subject, topic, data)
{
if ( topic != 'nsPref:changed' )
{
// Listen for preference changes
observe: function(subject, topic, data) {
if ( topic != 'nsPref:changed' ) {
return;
}
switch(data)
{
switch(data) {
case 'autoDetect':
wappalyzer.autoDetect = wappalyzer.prefs.getBoolPref('autoDetect');
self.autoDetect = self.prefs.getBoolPref('autoDetect');
break;
case 'customApps':
wappalyzer.customApps = wappalyzer.prefs.getCharPref('customApps');
self.customApps = self.prefs.getCharPref('customApps');
break;
case 'debug':
wappalyzer.debug = wappalyzer.prefs.getBoolPref('debug');
self.debug = self.prefs.getBoolPref('debug');
break;
case 'enableTracking':
wappalyzer.enableTracking = wappalyzer.prefs.getBoolPref('enableTracking');
self.enableTracking = self.prefs.getBoolPref('enableTracking');
break;
case 'showApps':
wappalyzer.showApps = wappalyzer.prefs.getIntPref('showApps');
self.showApps = self.prefs.getIntPref('showApps');
break;
case 'location':
var locationPref = wappalyzer.prefs.getIntPref('location');
var locationPref = self.prefs.getIntPref('location');
wappalyzer.moveLocation(locationPref);
self.moveLocation(locationPref);
break;
case 'cat1': wappalyzer.showCats[1] = wappalyzer.prefs.getIntPref('cat1'); break;
case 'cat2': wappalyzer.showCats[2] = wappalyzer.prefs.getIntPref('cat2'); break;
case 'cat3': wappalyzer.showCats[3] = wappalyzer.prefs.getIntPref('cat3'); break;
case 'cat4': wappalyzer.showCats[4] = wappalyzer.prefs.getIntPref('cat4'); break;
case 'cat5': wappalyzer.showCats[5] = wappalyzer.prefs.getIntPref('cat5'); break;
case 'cat6': wappalyzer.showCats[6] = wappalyzer.prefs.getIntPref('cat6'); break;
case 'cat7': wappalyzer.showCats[7] = wappalyzer.prefs.getIntPref('cat7'); break;
case 'cat8': wappalyzer.showCats[8] = wappalyzer.prefs.getIntPref('cat8'); break;
case 'cat9': wappalyzer.showCats[9] = wappalyzer.prefs.getIntPref('cat9'); break;
case 'cat10': wappalyzer.showCats[10] = wappalyzer.prefs.getIntPref('cat10'); break;
case 'cat11': wappalyzer.showCats[11] = wappalyzer.prefs.getIntPref('cat11'); break;
case 'cat12': wappalyzer.showCats[12] = wappalyzer.prefs.getIntPref('cat12'); break;
case 'cat13': wappalyzer.showCats[13] = wappalyzer.prefs.getIntPref('cat13'); break;
case 'cat14': wappalyzer.showCats[14] = wappalyzer.prefs.getIntPref('cat14'); break;
case 'cat15': wappalyzer.showCats[15] = wappalyzer.prefs.getIntPref('cat15'); break;
case 'cat16': wappalyzer.showCats[16] = wappalyzer.prefs.getIntPref('cat16'); break;
case 'cat17': wappalyzer.showCats[17] = wappalyzer.prefs.getIntPref('cat17'); break;
case 'cat18': wappalyzer.showCats[18] = wappalyzer.prefs.getIntPref('cat18'); break;
case 'cat19': wappalyzer.showCats[19] = wappalyzer.prefs.getIntPref('cat19'); break;
case 'cat20': wappalyzer.showCats[20] = wappalyzer.prefs.getIntPref('cat20'); break;
case 'cat21': wappalyzer.showCats[21] = wappalyzer.prefs.getIntPref('cat21'); break;
case 'cat22': wappalyzer.showCats[22] = wappalyzer.prefs.getIntPref('cat22'); break;
case 'cat23': wappalyzer.showCats[23] = wappalyzer.prefs.getIntPref('cat23'); break;
case 'cat1': self.showCats[ 1] = self.prefs.getIntPref( 'cat1'); break;
case 'cat2': self.showCats[ 2] = self.prefs.getIntPref( 'cat2'); break;
case 'cat3': self.showCats[ 3] = self.prefs.getIntPref( 'cat3'); break;
case 'cat4': self.showCats[ 4] = self.prefs.getIntPref( 'cat4'); break;
case 'cat5': self.showCats[ 5] = self.prefs.getIntPref( 'cat5'); break;
case 'cat6': self.showCats[ 6] = self.prefs.getIntPref( 'cat6'); break;
case 'cat7': self.showCats[ 7] = self.prefs.getIntPref( 'cat7'); break;
case 'cat8': self.showCats[ 8] = self.prefs.getIntPref( 'cat8'); break;
case 'cat9': self.showCats[ 9] = self.prefs.getIntPref( 'cat9'); break;
case 'cat10': self.showCats[10] = self.prefs.getIntPref('cat10'); break;
case 'cat11': self.showCats[11] = self.prefs.getIntPref('cat11'); break;
case 'cat12': self.showCats[12] = self.prefs.getIntPref('cat12'); break;
case 'cat13': self.showCats[13] = self.prefs.getIntPref('cat13'); break;
case 'cat14': self.showCats[14] = self.prefs.getIntPref('cat14'); break;
case 'cat15': self.showCats[15] = self.prefs.getIntPref('cat15'); break;
case 'cat16': self.showCats[16] = self.prefs.getIntPref('cat16'); break;
case 'cat17': self.showCats[17] = self.prefs.getIntPref('cat17'); break;
case 'cat18': self.showCats[18] = self.prefs.getIntPref('cat18'); break;
case 'cat19': self.showCats[19] = self.prefs.getIntPref('cat19'); break;
case 'cat20': self.showCats[20] = self.prefs.getIntPref('cat20'); break;
case 'cat21': self.showCats[21] = self.prefs.getIntPref('cat21'); break;
case 'cat22': self.showCats[22] = self.prefs.getIntPref('cat22'); break;
case 'cat23': self.showCats[23] = self.prefs.getIntPref('cat23'); break;
}
},
openTab: function(url)
{
wappalyzer.browser.selectedTab = wappalyzer.browser.addTab(url);
openTab: function(url) {
self.browser.selectedTab = self.browser.addTab(url);
},
moveLocation: function(locationPref) {
wappalyzer.log('moveLocation');
self.log('moveLocation');
switch ( locationPref )
{
switch ( locationPref ) {
case 1:
var containerId = 'wappalyzer-statusbar';
@ -213,18 +195,17 @@ wappalyzer =
e.appendChild(container);
},
onPageLoad: function(event)
{
wappalyzer.log('onPageLoad');
onPageLoad: function(event) {
self.log('onPageLoad');
var target = event.originalTarget;
if ( !target.request )
{
wappalyzer.request = false;
if ( !target.request ) {
self.request = false;
}
wappalyzer.analyzePage(
self.analyzePage(
target.documentElement,
target.location.href,
target.documentElement.innerHTML,
[],
@ -234,11 +215,11 @@ wappalyzer =
);
},
onContentPageLoad: function(message)
{
wappalyzer.log('onContentPageLoad');
onContentPageLoad: function(message) {
self.log('onContentPageLoad');
wappalyzer.analyzePage(
self.analyzePage(
null,
message.json.href,
message.json.html,
message.json.headers,
@ -248,24 +229,19 @@ wappalyzer =
);
},
onUrlChange: function(request)
{
wappalyzer.log('onUrlChange');
onUrlChange: function(request) {
self.log('onUrlChange');
wappalyzer.clearDetectedApps();
self.clearDetectedApps();
var doc = wappalyzer.browser.contentDocument;
if ( !doc.request )
{
doc.request = request;
}
var doc = self.browser.contentDocument;
wappalyzer.request = doc.request;
self.request = doc.request ? doc.request : request;
wappalyzer.currentTab = false;
self.currentTab = false;
wappalyzer.analyzePage(
self.analyzePage(
doc,
doc.location.href ? doc.location.href : '',
doc.documentElement ? doc.documentElement.innerHTML : '',
[],
@ -275,36 +251,30 @@ wappalyzer =
);
},
urlChange:
{
QueryInterface: function(iid)
{
urlChange: {
QueryInterface: function(iid) {
if ( iid.equals(Components.interfaces.nsIWebProgressListener) ||
iid.equals(Components.interfaces.nsISupportsWeakReference) ||
iid.equals(Components.interfaces.nsISupports) )
{
iid.equals(Components.interfaces.nsISupports) ) {
return this;
}
throw Components.results.NS_NOINTERFACE;
},
onLocationChange: function(progress, request, url)
{
wappalyzer.log('urlChange.onLocationChange');
onLocationChange: function(progress, request, url) {
self.log('urlChange.onLocationChange');
if ( !url )
{
wappalyzer.prevUrl = '';
if ( !url ) {
self.prevUrl = '';
return;
}
if ( url.spec != wappalyzer.prevUrl )
{
wappalyzer.prevUrl = url.spec;
if ( url.spec != self.prevUrl ) {
self.prevUrl = url.spec;
wappalyzer.onUrlChange(request);
self.onUrlChange(request);
}
},
@ -314,113 +284,94 @@ wappalyzer =
onSecurityChange: function(a, b, c) {}
},
analyzePage: function(href, html, headers, environmentVars, doCount, manualDetect)
{
wappalyzer.log('analyzePage');
analyzePage: function(doc, href, html, headers, environmentVars, doCount, manualDetect) {
self.log('analyzePage');
wappalyzer.currentTab = false;
self.currentTab = false;
if ( href == wappalyzer.browser.contentDocument.location.href )
{
wappalyzer.currentTab = true;
if ( href == self.browser.contentDocument.location.href ) {
self.currentTab = true;
wappalyzer.clearDetectedApps();
if ( !doc ) {
doc = self.browser.contentDocument;
}
if ( typeof html == 'undefined' )
{
self.clearDetectedApps();
}
if ( typeof html == 'undefined' ) {
html = '';
}
if ( wappalyzer.autoDetect || ( !wappalyzer.autoDetect && manualDetect ) )
{
// Scan URL, domain and response headers for patterns
if ( html.length > 50000 ) // Prevent large documents from slowing things down
{
if ( self.autoDetect || ( !self.autoDetect && manualDetect ) ) {
// Prevent large documents from slowing things down
if ( html.length > 50000 ) {
html = html.substring(0, 25000) + html.substring(html.length - 25000, html.length);
}
if ( html )
{
// Scan URL, domain and response headers for patterns
if ( html ) {
// Check cached application names
if ( typeof wappalyzer.browser.contentDocument.wappalyzerApps != 'undefined' )
{
for ( i in wappalyzer.browser.contentDocument.wappalyzerApps )
{
var appName = wappalyzer.browser.contentDocument.wappalyzerApps[i];
if ( doc && typeof doc.detectedApps != 'undefined' ) {
for ( i in doc.detectedApps ) {
var appName = doc.detectedApps[i];
if ( typeof self.checkUnique[appName] == 'undefined' ) {
self.log('CACHE'); //
if ( typeof wappalyzer.checkUnique[appName] == 'undefined' )
{
wappalyzer.showApp(appName, href, doCount);
self.showApp(appName, doc, href, doCount);
wappalyzer.checkUnique[appName] = true;
self.checkUnique[appName] = true;
}
}
}
for ( var appName in wappalyzer.apps )
{
if ( typeof wappalyzer.checkUnique[appName] == 'undefined' ) // Don't scan for apps that have already been detected
{
for ( var appName in self.apps ) {
// Don't scan for apps that have already been detected
if ( typeof self.checkUnique[appName] == 'undefined' ) {
// Scan HTML
if ( typeof wappalyzer.apps[appName].html != 'undefined' )
{
var regex = wappalyzer.apps[appName].html;
if ( typeof self.apps[appName].html != 'undefined' ) {
var regex = self.apps[appName].html;
if ( regex.test(html) )
{
wappalyzer.showApp(appName, href, doCount);
if ( regex.test(html) ) {
self.showApp(appName, doc, href, doCount);
}
}
// Scan URL
if ( href && typeof wappalyzer.apps[appName].url != 'undefined' )
{
var regex = wappalyzer.apps[appName].url;
if ( href && typeof self.apps[appName].url != 'undefined' ) {
var regex = self.apps[appName].url;
if ( regex.test(href) )
{
wappalyzer.showApp(appName, href, doCount);
if ( regex.test(href) ) {
self.showApp(appName, doc, href, doCount);
}
}
// Scan response headers
if ( typeof wappalyzer.apps[appName].headers != 'undefined' && wappalyzer.request )
{
for ( var header in wappalyzer.apps[appName].headers )
{
var regex = wappalyzer.apps[appName].headers[header];
if ( typeof self.apps[appName].headers != 'undefined' && self.request ) {
for ( var header in self.apps[appName].headers ) {
var regex = self.apps[appName].headers[header];
try
{
if ( regex.test(wappalyzer.request.nsIHttpChannel.getResponseHeader(header)) )
{
wappalyzer.showApp(appName, href, doCount);
try {
if ( regex.test(self.request.nsIHttpChannel.getResponseHeader(header)) ) {
self.showApp(appName, doc, href, doCount);
}
}
catch(e)
{
}
catch(e) { }
}
}
// Scan environment variables
if ( environmentVars && typeof wappalyzer.apps[appName].env != 'undefined' )
{
var regex = wappalyzer.apps[appName].env;
if ( environmentVars && typeof self.apps[appName].env != 'undefined' ) {
var regex = self.apps[appName].env;
for ( var i in environmentVars )
{
try
{
if ( regex.test(environmentVars[i]) )
{
wappalyzer.showApp(appName, href, doCount);
}
for ( var i in environmentVars ) {
try {
if ( regex.test(environmentVars[i]) ) {
self.showApp(appName, doc, href, doCount);
}
catch(e)
{
}
catch(e) { }
}
}
}
@ -431,48 +382,41 @@ wappalyzer =
}
},
showApp: function(detectedApp, href, doCount)
{
wappalyzer.log('showApp ' + detectedApp);
showApp: function(detectedApp, doc, href, doCount) {
self.log('showApp ' + detectedApp);
self.report(detectedApp, href);
// Keep detected application names in memory
if ( typeof wappalyzer.browser.contentDocument.wappalyzerApps == 'undefined' )
{
wappalyzer.browser.contentDocument.wappalyzerApps = [];
if ( doc ) {
if ( typeof doc.detectedApps == 'undefined' ) {
doc.detectedApps = [];
}
wappalyzer.browser.contentDocument.wappalyzerApps.push(detectedApp);
wappalyzer.report(detectedApp, href);
doc.detectedApps.push(detectedApp);
}
if ( detectedApp && typeof wappalyzer.checkUnique[detectedApp] == 'undefined' )
{
if ( detectedApp && typeof self.checkUnique[detectedApp] == 'undefined' ) {
var show = false;
for ( var i in wappalyzer.apps[detectedApp].cats )
{
if ( wappalyzer.showCats[wappalyzer.apps[detectedApp].cats[i]] )
{
for ( var i in self.apps[detectedApp].cats ) {
if ( self.showCats[self.apps[detectedApp].cats[i]] ) {
show = true;
break;
}
}
if ( show )
{
if ( show && self.currentTab ) {
var e = document.getElementById('wappalyzer-detected-apps');
if ( wappalyzer.autoDetect )
{
if ( wappalyzer.showApps == 2 )
{
if ( self.autoDetect ) {
if ( self.showApps == 2 ) {
document.getElementById('wappalyzer-icon').setAttribute('src', 'chrome://wappalyzer/skin/icon16x16_hot.ico');
document.getElementById('wappalyzer-detected-apps').style.display = 'none';
}
else
{
else {
// Hide Wappalyzer icon
document.getElementById('wappalyzer-icon').style.display = 'none';
@ -482,27 +426,23 @@ wappalyzer =
// Show app icon and label
var child = document.createElement('image');
if ( typeof wappalyzer.apps[detectedApp].icon == 'string' )
{
child.setAttribute('src', wappalyzer.apps[detectedApp].icon);
if ( typeof self.apps[detectedApp].icon == 'string' ) {
child.setAttribute('src', self.apps[detectedApp].icon);
}
else
{
else {
child.setAttribute('src', 'chrome://wappalyzer/skin/icons/' + detectedApp + '.ico');
}
child.setAttribute('class', 'wappalyzer-icon');
if ( wappalyzer.appsDetected )
{
if ( self.appsDetected ) {
child.setAttribute('style', 'margin-left: .5em');
}
e.appendChild(child);
}
if ( wappalyzer.showApps == 0 )
{
if ( self.showApps == 0 ) {
var child = document.createElement('label');
child.setAttribute('value', detectedApp);
@ -514,13 +454,11 @@ wappalyzer =
// Show application in popup
var e = document.getElementById('wappalyzer-apps');
if ( !wappalyzer.appsDetected )
{
if ( !self.appsDetected ) {
// Remove "no apps detected" message
document.getElementById('wappalyzer-apps').removeChild(document.getElementById('wappalyzer-no-detected-apps'));
}
else
{
else {
var child = document.createElement('menuseparator');
e.appendChild(child);
@ -530,29 +468,26 @@ wappalyzer =
child.setAttribute('class', 'menuitem-iconic');
child.setAttribute('type', '');
child.setAttribute('oncommand', 'wappalyzer.openTab(\'' + wappalyzer.homeUrl + 'stats/app/' + escape(detectedApp) + '\');');
if ( typeof wappalyzer.apps[detectedApp].custom == 'undefined' )
{
child.addEventListener('command', function() { self.openTab(self.homeUrl + 'stats/app/' + escape(detectedApp)); }, false);
if ( typeof self.apps[detectedApp].custom == 'undefined' ) {
child.setAttribute('label', detectedApp);
child.setAttribute('image', 'chrome://wappalyzer/skin/icons/' + detectedApp + '.ico');
}
else
{
child.setAttribute('label', detectedApp + ' (' + wappalyzer.strings.getString('wappalyzer.custom') + ')');
else {
child.setAttribute('label', detectedApp + ' (' + self.strings.getString('wappalyzer.custom') + ')');
child.setAttribute('disabled', 'true');
child.setAttribute('image', wappalyzer.apps[detectedApp].icon);
child.setAttribute('image', self.apps[detectedApp].icon);
}
e.appendChild(child);
if ( wappalyzer.apps[detectedApp].cats )
{
for ( var i in wappalyzer.apps[detectedApp].cats )
{
if ( self.apps[detectedApp].cats ) {
for ( var i in self.apps[detectedApp].cats ) {
var child = document.createElement('menuitem');
child.setAttribute('label', wappalyzer.cats[wappalyzer.apps[detectedApp].cats[i]].name);
child.setAttribute('label', self.cats[self.apps[detectedApp].cats[i]].name);
child.setAttribute('disabled', 'true');
e.appendChild(child);
@ -560,72 +495,60 @@ wappalyzer =
}
}
if ( doCount )
{
wappalyzer.report(detectedApp, href);
if ( doCount ) {
self.report(detectedApp, href);
}
wappalyzer.appsDetected ++;
self.appsDetected ++;
wappalyzer.checkUnique[detectedApp] = true;
self.checkUnique[detectedApp] = true;
}
},
report: function(detectedApp, href)
{
wappalyzer.log('report');
report: function(detectedApp, href) {
self.log('report');
if ( typeof wappalyzer.apps[detectedApp].custom == 'undefined' )
{
if ( typeof self.apps[detectedApp].custom == 'undefined' ) {
var
regex = /:\/\/(.[^/]+)/,
domain = href.match(regex) ? href.match(regex)[1] : ''
;
if ( wappalyzer.enableTracking && wappalyzer.regexDomain.test(domain) && !wappalyzer.regexBlacklist.test(href) )
{
if ( typeof wappalyzer.history[domain] == 'undefined' )
{
wappalyzer.history[domain] = [];
if ( self.enableTracking && self.regexDomain.test(domain) && !self.regexBlacklist.test(href) ) {
if ( typeof self.history[domain] == 'undefined' ) {
self.history[domain] = [];
}
if ( typeof wappalyzer.history[domain][detectedApp] == 'undefined' )
{
wappalyzer.history[domain][detectedApp] = 0;
if ( typeof self.history[domain][detectedApp] == 'undefined' ) {
self.history[domain][detectedApp] = 0;
}
wappalyzer.history[domain][detectedApp] ++;
self.history[domain][detectedApp] ++;
wappalyzer.hitCount ++;
self.hitCount ++;
if ( wappalyzer.hitCount > 200 )
{
wappalyzer.sendReport();
if ( self.hitCount > 200 ) {
self.sendReport();
}
}
}
},
sendReport: function()
// Anonymously send the name of the detected apps and domains to wappalyzer.com
// You can turn this off in the options dialog
// This is used to track the distribution of software, stats are publicly available on the site
{
wappalyzer.log('sendReport');
sendReport: function() {
self.log('sendReport');
if ( wappalyzer.enableTracking && !wappalyzer.req )
{
if ( self.enableTracking && !self.req ) {
var report = '';
if ( wappalyzer.history )
{
for ( var i in wappalyzer.history )
{
if ( self.history ) {
for ( var i in self.history ) {
report += '[' + i;
for ( var j in wappalyzer.history[i] )
{
report += '|' + j + ':' + wappalyzer.history[i][j];
for ( var j in self.history[i] ) {
report += '|' + j + ':' + self.history[i][j];
}
report += ']';
@ -633,43 +556,39 @@ wappalyzer =
}
// Make POST request
wappalyzer.req = new XMLHttpRequest();
self.req = new XMLHttpRequest();
wappalyzer.req.open('POST', wappalyzer.homeUrl + 'report/', true);
self.req.open('POST', self.homeUrl + 'report/', true);
wappalyzer.req.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
self.req.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
wappalyzer.req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
self.req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
wappalyzer.req.onreadystatechange = function(e)
{
if ( wappalyzer.req.readyState == 4 )
{
if ( wappalyzer.req.status == 200 )
{
self.req.onreadystatechange = function(e) {
if ( self.req.readyState == 4 ) {
if ( self.req.status == 200 ) {
// Reset
report = '';
wappalyzer.hitCount = 0;
wappalyzer.history = [];
self.hitCount = 0;
self.history = [];
}
wappalyzer.req.close();
self.req.close();
wappalyzer.req = false;
self.req = false;
}
};
wappalyzer.req.send('d=' + encodeURIComponent(report));
self.req.send('d=' + encodeURIComponent(report));
}
},
clearDetectedApps: function()
{
wappalyzer.log('clearDetectedApps');
clearDetectedApps: function() {
self.log('clearDetectedApps');
wappalyzer.appsDetected = 0;
wappalyzer.checkUnique = [];
self.appsDetected = 0;
self.checkUnique = [];
// Show Wappalyzer icon
document.getElementById('wappalyzer-icon').setAttribute('src', 'chrome://wappalyzer/skin/icon16x16.ico');
@ -678,22 +597,20 @@ wappalyzer =
// Clear app icons and labels
var e = document.getElementById('wappalyzer-detected-apps');
while ( e.childNodes.length > 0 )
{
while ( e.childNodes.length > 0 ) {
e.removeChild(e.childNodes.item(0));
}
// Clear application popup
var e = document.getElementById('wappalyzer-apps');
while ( e.childNodes.length > 0 )
{
while ( e.childNodes.length > 0 ) {
e.removeChild(e.childNodes.item(0));
}
var child = document.createElement('menuitem');
child.setAttribute('label', wappalyzer.strings.getString('wappalyzer.noDetectedApps'));
child.setAttribute('label', self.strings.getString('wappalyzer.noDetectedApps'));
child.setAttribute('id', 'wappalyzer-no-detected-apps');
child.setAttribute('class', 'menuitem-iconic');
child.setAttribute('disabled', 'true');
@ -702,17 +619,25 @@ wappalyzer =
e.appendChild(child);
},
installSuccess: function()
{
wappalyzer.browser.removeEventListener('load', wappalyzer.installSuccess, false);
installSuccess: function() {
self.log('installSuccess');
self.browser.removeEventListener('load', self.installSuccess, false);
wappalyzer.openTab(wappalyzer.homeUrl + 'install/success/');
self.openTab(self.homeUrl + 'install/success/');
},
upgradeSuccess: function()
{
wappalyzer.browser.removeEventListener('load', wappalyzer.upgradeSuccess, false);
upgradeSuccess: function() {
self.log('upgradeSuccess');
self.browser.removeEventListener('load', self.upgradeSuccess, false);
wappalyzer.openTab(wappalyzer.homeUrl + 'install/upgraded/');
self.openTab(self.homeUrl + 'install/upgraded/');
}
};
addEventListener('load', function() { self.init(); }, false);
addEventListener('unload', function() { self.sendReport(); }, false);
return self;
})();

@ -5,7 +5,7 @@
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>wappalyzer@crunchlabz.com</em:id>
<em:version>1.15</em:version>
<em:version>1.15.2</em:version>
<em:type>2</em:type>
<em:unpack>true</em:unpack>
@ -14,7 +14,7 @@
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>4.0</em:minVersion>
<em:maxVersion>7.*</em:maxVersion>
<em:maxVersion>8.*</em:maxVersion>
</Description>
</em:targetApplication>

Binary file not shown.