var wappalyzer = {};
(function() {
var popup = {
pollHeaders: null,
init: function() {
chrome.tabs.getSelected(null, function(tab) {
if ( tab.url.match(/https?:\/\//) ) {
$('#detected-apps').html('
No applications detected.
');
$('#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('Nothing to do here.
');
$('#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').removeClass('pending');
}
if ( response.tabCache.count > 0 ) {
$('#detected-apps').html('');
response.tabCache.appsDetected.map(function(appName) {
html =
'';
$('#detected-apps').append(html);
});
}
});
});
}
}
popup.init();
})();