var wappalyzer = {}; (function() { var popup = { pollHeaders: null, init: function() { chrome.tabs.getSelected(null, function(tab) { if ( tab.url.match(/https?:\/\//) ) { $('#detected-apps').html('
' + chrome.i18n.getMessage('noAppsDetected') + '
'); $('#analyze-headers').show().click(function() { $(this).addClass('pending'); chrome.extension.sendRequest({ id: 'fetch_headers', tab: tab }); popup.pollHeaders = setInterval(popup.displayApps, 100); }); } else { $('#detected-apps').html('
' + chrome.i18n.getMessage('nothingToDo') + '
'); $('#analyze-headers').hide(); } }); popup.displayApps(); }, displayApps: function() { chrome.tabs.getSelected(null, function(tab) { chrome.extension.sendRequest({ id: 'get_apps', tab: tab }, function(response) { if ( response.tabCache.analyzed.indexOf('headers') > 0 ) { clearTimeout(popup.pollHeaders); $('#analyze-headers').hide().removeClass('pending'); } if ( response.tabCache.count > 0 ) { $('#detected-apps').html(''); response.tabCache.appsDetected.map(function(appName) { html = '
' + '' + '' + '' + appName + '' + ''; wappalyzer.apps[appName].cats.map(function(cat) { html += '' + '' + chrome.i18n.getMessage('categoryName' + cat) + '' + ''; }); html += '' + '
'; $('#detected-apps').append(html); }); } }); }); } } popup.init(); })();