Analyze response headers, listen for location and tab changes, added context menu

main
ElbertF 13 years ago
parent 5d2504037f
commit 64dcac17e4

@ -7,7 +7,7 @@
var w = wappalyzer; var w = wappalyzer;
var $; var $, strings;
w.adapter = { w.adapter = {
/** /**
@ -28,24 +28,7 @@
w.log('w.adapter: browser window loaded'); w.log('w.adapter: browser window loaded');
// Listen for tab events strings = document.getElementById('wappalyzer-strings');
gBrowser.addTabsProgressListener({
/*
onLocationChange: function(progress, request, location, flags) {
w.log('tab location change: ' + location.URI.spec);
w.adapter('displayApps', { url: location.URI.spec });
}
*/
/*
onStateChange: function(browser, progress, request, flags, status) {
if ( (flag & Components.interfaces.nsIWebProgressListener.STATE_STOP) ) {
// Some operations including the DOM parsing here
}
}
*/
});
AddonManager.getAddonByID('wappalyzer@crunchlabz.com', function(addon) { AddonManager.getAddonByID('wappalyzer@crunchlabz.com', function(addon) {
addon.version = addon.version; addon.version = addon.version;
@ -65,6 +48,28 @@
// Load content script // Load content script
messageManager.loadFrameScript('chrome://wappalyzer/content/js/content.js', true); messageManager.loadFrameScript('chrome://wappalyzer/content/js/content.js', true);
gBrowser.addProgressListener({
// Listen for location changes
onLocationChange: function(progress, request, location, flags) {
w.adapter.displayApps();
},
// Get response headers
onStateChange: function(progress, request, flags, status) {
if ( flags & Components.interfaces.nsIWebProgressListener.STATE_STOP ) {
var headers = new Object();
request.nsIHttpChannel.visitResponseHeaders(function(header, value) {
headers[header] = value;
});
w.analyze(progress.currentURI.host, progress.currentURI.spec, { headers: headers });
}
}
});
gBrowser.tabContainer.addEventListener('TabSelect', w.adapter.displayApps, false);
callback(); callback();
}); });
}; };
@ -75,17 +80,15 @@
/** /**
* Display apps * Display apps
*/ */
displayApps: function(args) { displayApps: function() {
var browser = gBrowser.getBrowserForTab(gBrowser.selectedTab); var url = gBrowser.currentURI.spec;
url = browser.currentURI.spec; $('#wappalyzer-menu > menuitem, #wappalyzer-menu > menuseparator').remove();
if ( args.apps ) { if ( w.detected[url] != null && w.detected[url].length ) {
$('#wappalyzer-icon').attr('src', 'chrome://wappalyzer/skin/images/icon16x16_hot.ico'); $('#wappalyzer-icon').attr('src', 'chrome://wappalyzer/skin/images/icon16x16_hot.ico');
$('#wappalyzer-menu > menuitem, #wappalyzer-menu > menuseparator').remove(); w.detected[url].map(function(app, i) {
args.apps.map(function(app, i) {
var menuSeparator = $('<menuseparator/>'); var menuSeparator = $('<menuseparator/>');
$('#wappalyzer-menu').append(menuSeparator); $('#wappalyzer-menu').append(menuSeparator);
@ -119,10 +122,10 @@
var menuItem = $('<menuitem/>') var menuItem = $('<menuitem/>')
.attr('disabled', 'true') .attr('disabled', 'true')
.label('&wappalyzer.noAppsDetected') .attr('label', strings.getString('wappalyzer.noAppsDetected'))
; ;
$('#wappalyzer-menu').html(menuItem); $('#wappalyzer-menu').append(menuItem);
} }
}, },

@ -20,7 +20,15 @@
<menupopup id="wappalyzer-menu" position="after_end"> <menupopup id="wappalyzer-menu" position="after_end">
<menu label="&wappalyzer.name;"> <menu label="&wappalyzer.name;">
<menupopup> <menupopup>
<menuitem label="sub" image="chrome://wappalyzer/skin/images/icon16x16_hot.ico"/> <menuitem label="&wappalyzer.options;" oncommand="" image="chrome://wappalyzer/skin/images/options.png"/>
<menuseparator/>
<menuitem label="&wappalyzer.donate;" oncommand="wappalyzer.adapter.goToURL({ url: wappalyzer.config.websiteURL + 'donate/' });" image="chrome://wappalyzer/skin/images/donate.png"/>
<menuitem label="&wappalyzer.feedback;" oncommand="wappalyzer.adapter.goToURL({ url: wappalyzer.config.websiteURL + '?redirect=feedback' });" image="chrome://wappalyzer/skin/images/feedback.png"/>
<menuitem label="&wappalyzer.github;" oncommand="wappalyzer.adapter.goToURL({ url: wappalyzer.config.githubURL });" image="chrome://wappalyzer/skin/images/github.ico"/>
<menuitem label="&wappalyzer.twitter;" oncommand="wappalyzer.adapter.goToURL({ url: wappalyzer.config.twitterURL });" image="chrome://wappalyzer/skin/images/twitter.ico"/>
<menuitem label="&wappalyzer.website;" oncommand="wappalyzer.adapter.goToURL({ url: wappalyzer.config.websiteURL });" image="chrome://wappalyzer/skin/images/icon16x16_hot.ico"/>
</menupopup> </menupopup>
</menu> </menu>

@ -1,5 +1,11 @@
<!ENTITY wappalyzer.name "Wappalyzer"> <!ENTITY wappalyzer.name "Wappalyzer">
<!ENTITY wappalyzer.noAppsDetected "No applications detected">
<!ENTITY wappalyzer.options "Options">
<!ENTITY wappalyzer.donate "Donate!">
<!ENTITY wappalyzer.feedback "Feedback">
<!ENTITY wappalyzer.github "Fork on Github">
<!ENTITY wappalyzer.twitter "Twitter">
<!ENTITY wappalyzer.website "Visit Wappalyzer">
<!ENTITY wappalyzer.cat1 "CMS"> <!ENTITY wappalyzer.cat1 "CMS">
<!ENTITY wappalyzer.cat2 "Message boards"> <!ENTITY wappalyzer.cat2 "Message boards">

@ -1 +1,2 @@
wappalyzer.name = Wappalyzer wappalyzer.name = Wappalyzer
wappalyzer.noAppsDetected = No applications detected

@ -197,7 +197,7 @@ var wappalyzer = wappalyzer || (function() {
delete apps, data; delete apps, data;
} }
adapter('displayApps', { url: url, apps: w.detected[url] }); adapter('displayApps');
} }
}; };

Loading…
Cancel
Save