You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.0 KiB
123 lines
3.0 KiB
14 years ago
|
(function() {
|
||
13 years ago
|
var self = {
|
||
13 years ago
|
element: false,
|
||
14 years ago
|
prevUrl: '',
|
||
|
|
||
|
init: function() {
|
||
|
self.log('init');
|
||
14 years ago
|
|
||
14 years ago
|
addEventListener('DOMContentLoaded', self.onPageLoad, false);
|
||
14 years ago
|
},
|
||
|
|
||
14 years ago
|
log: function(message) {
|
||
13 years ago
|
return; //
|
||
|
|
||
14 years ago
|
var consoleService = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
|
||
14 years ago
|
|
||
14 years ago
|
consoleService.logStringMessage("Wappalyzer content.js: " + message);
|
||
|
},
|
||
14 years ago
|
|
||
14 years ago
|
onPageLoad: function(e) {
|
||
|
self.log('onPageLoad');
|
||
14 years ago
|
|
||
14 years ago
|
self.getEnvironmentVars();
|
||
|
},
|
||
|
|
||
|
onUrlChange: function(request) {
|
||
|
self.log('onUrlChange');
|
||
|
|
||
|
self.getEnvironmentVars();
|
||
|
},
|
||
|
|
||
|
urlChange: {
|
||
|
QueryInterface: function(iid) {
|
||
|
if ( iid.equals(Components.interfaces.nsIWebProgressListener) ||
|
||
|
iid.equals(Components.interfaces.nsISupportsWeakReference) ||
|
||
|
iid.equals(Components.interfaces.nsISupports) ) {
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
throw Components.results.NS_NOINTERFACE;
|
||
|
},
|
||
|
|
||
|
onLocationChange: function(progress, request, url) {
|
||
|
if ( !url ) {
|
||
|
self.prevUrl = '';
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if ( url.spec != self.prevUrl ) {
|
||
|
self.prevUrl = url.spec;
|
||
|
|
||
|
self.onUrlChange(request);
|
||
|
}
|
||
|
},
|
||
|
|
||
|
onStateChange: function(a, b, c, d) {},
|
||
|
onProgressChange: function(a, b, c, d, e, f) {},
|
||
|
onStatusChange: function(a, b, c, d) {},
|
||
|
onSecurityChange: function(a, b, c) {}
|
||
14 years ago
|
},
|
||
|
|
||
14 years ago
|
getEnvironmentVars: function() {
|
||
|
self.log('getEnvironmentVars');
|
||
|
|
||
13 years ago
|
if ( content.document.contentType != 'text/html' || typeof content.document.html == 'undefined' ) {
|
||
13 years ago
|
return;
|
||
|
}
|
||
|
|
||
14 years ago
|
var environmentVars = '';
|
||
|
|
||
|
try {
|
||
|
var element = content.document.createElement('wappalyzerData');
|
||
14 years ago
|
|
||
13 years ago
|
element.setAttribute('id', 'wappalyzerData');
|
||
|
element.setAttribute('style', 'display: none');
|
||
|
|
||
|
content.document.documentElement.appendChild(element);
|
||
|
|
||
|
content.location.href = 'javascript:' +
|
||
|
'(function() {' +
|
||
|
'try {' +
|
||
|
'var event = document.createEvent("Events");' +
|
||
|
|
||
|
'event.initEvent("wappalyzerEvent", true, false);' +
|
||
|
|
||
|
'var environmentVars = "";' +
|
||
|
|
||
|
'for ( var i in window ) environmentVars += i + " ";' +
|
||
|
|
||
|
'document.getElementById("wappalyzerData").appendChild(document.createComment(environmentVars));' +
|
||
|
|
||
|
'document.getElementById("wappalyzerData").dispatchEvent(event);' +
|
||
|
'}' +
|
||
|
'catch(e) { }' +
|
||
|
'})();';
|
||
14 years ago
|
|
||
14 years ago
|
element.addEventListener('wappalyzerEvent', (function(event) {
|
||
13 years ago
|
environmentVars = event.target.childNodes[0].nodeValue;
|
||
14 years ago
|
|
||
14 years ago
|
self.log('getEnvironmentVars: ' + environmentVars);
|
||
14 years ago
|
|
||
14 years ago
|
element.parentNode.removeChild(element);
|
||
14 years ago
|
|
||
14 years ago
|
sendAsyncMessage('wappalyzer:onPageLoad', {
|
||
|
href: content.document.location.href,
|
||
|
html: content.document.documentElement.innerHTML,
|
||
|
headers: [],
|
||
13 years ago
|
environmentVars: environmentVars.split(' ')
|
||
14 years ago
|
});
|
||
|
}), true);
|
||
|
}
|
||
|
catch(e) { }
|
||
14 years ago
|
|
||
14 years ago
|
return environmentVars;
|
||
|
}
|
||
14 years ago
|
}
|
||
|
|
||
14 years ago
|
self.init();
|
||
13 years ago
|
|
||
13 years ago
|
return self;
|
||
14 years ago
|
})();
|