/** * Bookmarklet driver */ (function() { if ( typeof wappalyzer === 'undefined' ) { return; } var w = wappalyzer, debug = true d = window.document, container = d.getElementById('wappalyzer-container'), domain = window.top.location.host, url = window.top.location.href, hasOwn = Object.prototype.hasOwnProperty; w.driver = { timeout: 1000, /** * Log messages to console */ log: function(args) { if ( debug && console != null && console[args.type] != null ) { console[args.type](args.message); } }, /** * Initialize */ init: function() { w.driver.getEnvironmentVars(); w.driver.getResponseHeaders(); }, getEnvironmentVars: function() { w.log('func: getEnvironmentVars'); var i, env = []; for ( i in window ) { env.push(i); } w.analyze(domain, url, { html: d.documentElement.innerHTML, env: env }); }, getResponseHeaders: function() { w.log('func: getResponseHeaders'); var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.onreadystatechange = function() { if ( xhr.readyState === 4 && xhr.status ) { var headers = xhr.getAllResponseHeaders().split("\n"); if ( headers.length > 0 && headers[0] != '' ) { w.log('responseHeaders: ' + xhr.getAllResponseHeaders()); var responseHeaders = {}; headers.forEach(function(line) { var name, value; if ( line ) { name = line.substring(0, line.indexOf(': ')); value = line.substring(line.indexOf(': ') + 2, line.length - 1); responseHeaders[name.toLowerCase()] = value; } }); w.analyze(domain, url, { headers: responseHeaders }); } } } xhr.send(); }, /** * Display apps */ displayApps: function() { w.log('func: diplayApps'); var i, first = true, app, category, html; html = '' + 'Close' + '' + '
'; if ( w.detected[url] != null && Object.keys(w.detected[url]).length ) { for ( app in w.detected[url] ) { if ( !hasOwn.call(w.detected[url], app) ) { continue; } html += '
' + '' + '' + ' ' + app + '' + ''; for ( i in w.apps[app].cats ) { if ( !hasOwn.call(w.apps[app].cats, i) ) { continue; } category = w.categories[w.apps[app].cats[i]]; html += '' + category + ''; } html += '
'; first = false; } } else { html += '
No applications detected
'; } html += '
'; container.innerHTML = html; }, /** * Go to URL */ goToURL: function(args) { window.open(args.url); }, slugify: function(string) { return string.toLowerCase().replace(/ /g, '-').replace(/[^\w-]/g, ''); } }; w.init(); })();