Apps.js to JSON

main
foobar 12 years ago
parent eab3d824ef
commit 758afea8e3

@ -6,7 +6,6 @@
<script src="js/ga.js"></script> <script src="js/ga.js"></script>
<script src="js/wappalyzer.js"></script> <script src="js/wappalyzer.js"></script>
<script src="js/apps.js"></script>
<script src="js/defaults.js"></script> <script src="js/defaults.js"></script>
<script src="js/driver.js"></script> <script src="js/driver.js"></script>
<script src="js/background.js"></script> <script src="js/background.js"></script>

@ -23,6 +23,22 @@
chrome.browserAction.setBadgeBackgroundColor({ color: [255, 102, 0, 255] }); chrome.browserAction.setBadgeBackgroundColor({ color: [255, 102, 0, 255] });
// Load apps.json
var xhr = new XMLHttpRequest();
xhr.open('GET', 'apps.json', true);
xhr.overrideMimeType('application/json');
xhr.onload = function() {
var json = JSON.parse(xhr.responseText);
w.categories = json.categories;
w.apps = json.apps;
};
xhr.send(null);
// Version check // Version check
try { try {
var version = chrome.app.getDetails().version; var version = chrome.app.getDetails().version;
@ -145,17 +161,17 @@
ping: function() { ping: function() {
if ( Object.keys(w.ping.hostnames).length && localStorage['tracking'] ) { if ( Object.keys(w.ping.hostnames).length && localStorage['tracking'] ) {
// Make POST request // Make POST request
var request = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
request.open('POST', w.config.websiteURL + 'ping/', true); xhr.open('POST', w.config.websiteURL + 'ping/', true);
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
request.onreadystatechange = function(e) { xhr.onreadystatechange = function(e) {
if ( request.readyState == 4 ) { w.log('w.driver.ping: status ' + request.status); } if ( request.readyState == 4 ) { w.log('w.driver.ping: status ' + request.status); }
}; };
request.send('json=' + encodeURIComponent(JSON.stringify(w.ping))); xhr.send('json=' + encodeURIComponent(JSON.stringify(w.ping)));
w.log('w.driver.ping: ' + JSON.stringify(w.ping)); w.log('w.driver.ping: ' + JSON.stringify(w.ping));

@ -10,7 +10,6 @@
<script src="js/ga.js"></script> <script src="js/ga.js"></script>
<script src="js/lib/jquery.min.js"></script> <script src="js/lib/jquery.min.js"></script>
<script src="js/popup.js"></script> <script src="js/popup.js"></script>
<script src="js/apps.js"></script>
<script src="js/i18n.js"></script> <script src="js/i18n.js"></script>
</head> </head>
<body> <body>

@ -40,12 +40,11 @@
// Read apps.json // Read apps.json
var xhr = Cc['@mozilla.org/xmlextras/xmlhttprequest;1'].createInstance(Ci.nsIXMLHttpRequest); var xhr = Cc['@mozilla.org/xmlextras/xmlhttprequest;1'].createInstance(Ci.nsIXMLHttpRequest);
//xhr.overrideMimeType('text/plain');
xhr.overrideMimeType('application/json'); xhr.overrideMimeType('application/json');
xhr.open('GET', 'chrome://wappalyzer/content/apps.json', true); xhr.open('GET', 'chrome://wappalyzer/content/apps.json', true);
xhr.onload = function(e) { xhr.onload = function() {
var json = JSON.parse(xhr.responseText); var json = JSON.parse(xhr.responseText);
w.categories = json.categories; w.categories = json.categories;

@ -105,17 +105,24 @@ var wappalyzer = wappalyzer || (function() {
if ( data ) { if ( data ) {
for ( app in w.apps ) { for ( app in w.apps ) {
for ( type in w.apps[app] ) { 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 // Skip if the app has already been detected
if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) {
continue;
}
switch ( type ) { switch ( type ) {
case 'url': case 'url':
if ( w.apps[app].url.test(url) ) { apps.push(app); } regex = new RegExp(w.apps[app][type], 'i');
if ( regex.test(url) ) { apps.push(app); }
break; break;
case 'html': case 'html':
if ( data[type] == null ) { break; } if ( data[type] == null ) { break; }
if ( w.apps[app][type].test(data[type]) ) { apps.push(app); } regex = new RegExp(w.apps[app][type], 'i');
if ( regex.test(data[type]) ) { apps.push(app); }
break; break;
case 'script': case 'script':
@ -156,7 +163,9 @@ var wappalyzer = wappalyzer || (function() {
if ( data[type] == null ) { break; } if ( data[type] == null ) { break; }
for ( header in w.apps[app].headers ) { for ( header in w.apps[app].headers ) {
if ( data[type][header] != null && w.apps[app][type][header].test(data[type][header]) ) { regex = new RegExp(w.apps[app][type][header], 'i');
if ( data[type][header] != null && regex.test(data[type][header]) ) {
apps.push(app); apps.push(app);
break; break;
@ -167,8 +176,10 @@ var wappalyzer = wappalyzer || (function() {
case 'env': case 'env':
if ( data[type] == null ) { break; } if ( data[type] == null ) { break; }
regex = RegExp(w.apps[app][type], 'i');
for ( i in data[type] ) { for ( i in data[type] ) {
if ( w.apps[app][type].test(data[type][i]) ) { if ( regex.test(data[type][i]) ) {
apps.push(app); apps.push(app);
break; break;

Loading…
Cancel
Save