|
|
@ -1,24 +1,17 @@
|
|
|
|
/** global: chrome */
|
|
|
|
/** global: chrome */
|
|
|
|
/** global: browser */
|
|
|
|
/** global: browser */
|
|
|
|
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
(function() {
|
|
|
|
var
|
|
|
|
var popup = {
|
|
|
|
slugify, popup,
|
|
|
|
|
|
|
|
d = document,
|
|
|
|
|
|
|
|
detectedApps = d.getElementById('detected-apps');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
slugify = function(string) {
|
|
|
|
|
|
|
|
return string.toLowerCase().replace(/[^a-z0-9-]/g, '-').replace(/--+/g, '-').replace(/(?:^-|-$)/, '');
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
popup = {
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
init: function() {
|
|
|
|
var callback = function(tabs) {
|
|
|
|
var callback = function(tabs) {
|
|
|
|
if ( tabs[0].url.match(/https?:\/\//) ) {
|
|
|
|
( chrome || browser ).runtime.sendMessage({ id: 'get_apps', tab: tabs[0], source: 'popup.js' }, function(response) {
|
|
|
|
detectedApps.innerHTML = '<div class="empty">' + browser.i18n.getMessage('noAppsDetected') + '</div>';
|
|
|
|
if ( /complete|interacrive|loaded/.test(document.readyState) ) {
|
|
|
|
} else {
|
|
|
|
popup.displayApps(response)
|
|
|
|
detectedApps.innerHTML = '<div class="empty">' + browser.i18n.getMessage('nothingToDo') + '</div>';
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function() { popup.displayApps(response) });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -28,62 +21,56 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
// Edge
|
|
|
|
// Edge
|
|
|
|
browser.tabs.query({ active: true, currentWindow: true }, callback);
|
|
|
|
browser.tabs.query({ active: true, currentWindow: true }, callback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
popup.displayApps();
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
displayApps: function() {
|
|
|
|
displayApps: function(response) {
|
|
|
|
var appName, confidence, version;
|
|
|
|
var
|
|
|
|
|
|
|
|
appName, confidence, version,
|
|
|
|
|
|
|
|
detectedApps = document.querySelector('#detected-apps');
|
|
|
|
|
|
|
|
html = '';
|
|
|
|
|
|
|
|
|
|
|
|
var callback = function(tabs) {
|
|
|
|
if ( response.tabCache && response.tabCache.count > 0 ) {
|
|
|
|
function sendGetApps(response) {
|
|
|
|
for ( appName in response.tabCache.appsDetected ) {
|
|
|
|
var html;
|
|
|
|
confidence = response.tabCache.appsDetected[appName].confidenceTotal;
|
|
|
|
|
|
|
|
version = response.tabCache.appsDetected[appName].version;
|
|
|
|
if ( response.tabCache && response.tabCache.count > 0 ) {
|
|
|
|
|
|
|
|
detectedApps.innerHTML = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( appName in response.tabCache.appsDetected ) {
|
|
|
|
html +=
|
|
|
|
confidence = response.tabCache.appsDetected[appName].confidenceTotal;
|
|
|
|
'<div class="detected-app">' +
|
|
|
|
version = response.tabCache.appsDetected[appName].version;
|
|
|
|
'<a target="_blank" href="https://wappalyzer.com/applications/' + popup.slugify(appName) + '">' +
|
|
|
|
|
|
|
|
'<img src="images/icons/' + ( response.apps[appName].icon || 'default.svg' ) + '"/>' +
|
|
|
|
|
|
|
|
'<span class="label">' +
|
|
|
|
|
|
|
|
'<span class="name">' + appName + '</span>' +
|
|
|
|
|
|
|
|
( version ? ' ' + version : '' ) + ( confidence < 100 ? ' (' + confidence + '% sure)' : '' ) +
|
|
|
|
|
|
|
|
'</span>' +
|
|
|
|
|
|
|
|
'</a>';
|
|
|
|
|
|
|
|
|
|
|
|
html =
|
|
|
|
response.apps[appName].cats.forEach(function(cat) {
|
|
|
|
'<div class="detected-app">' +
|
|
|
|
html +=
|
|
|
|
'<a target="_blank" href="https://wappalyzer.com/applications/' + slugify(appName) + '">' +
|
|
|
|
'<a target="_blank" href="https://wappalyzer.com/categories/' + popup.slugify(response.categories[cat].name) + '">' +
|
|
|
|
'<img src="images/icons/' + (response.apps[appName].icon || 'default.svg') + '"/>' +
|
|
|
|
'<span class="category"><span class="name">' + browser.i18n.getMessage('categoryName' + cat) + '</span></span>' +
|
|
|
|
'<span class="label"><span class="name">' + appName + '</span>' + ( version ? ' ' + version : '' ) + ( confidence < 100 ? ' (' + confidence + '% sure)' : '' ) + '</span>' +
|
|
|
|
'</a>';
|
|
|
|
'</a>';
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
response.apps[appName].cats.forEach(function(cat) {
|
|
|
|
html +=
|
|
|
|
html +=
|
|
|
|
'</a>' +
|
|
|
|
'<a target="_blank" href="https://wappalyzer.com/categories/' + slugify(response.categories[cat].name) + '">' +
|
|
|
|
'</div>';
|
|
|
|
'<span class="category"><span class="name">' + browser.i18n.getMessage('categoryName' + cat) + '</span></span>' +
|
|
|
|
}
|
|
|
|
'</a>';
|
|
|
|
} else {
|
|
|
|
});
|
|
|
|
html = '<div class="empty">' + browser.i18n.getMessage('noAppsDetected') + '</div>';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
html +=
|
|
|
|
detectedApps.innerHTML = html;
|
|
|
|
'</a>' +
|
|
|
|
|
|
|
|
'</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
detectedApps.innerHTML = detectedApps.innerHTML + html;
|
|
|
|
// Force redraw after popup animation on Mac OS
|
|
|
|
}
|
|
|
|
setTimeout(function() {
|
|
|
|
}
|
|
|
|
document.body.innerHTML += '<span style="line-height: 1px;"> </span>';
|
|
|
|
}
|
|
|
|
}, 600);
|
|
|
|
if (typeof chrome === "undefined") {
|
|
|
|
},
|
|
|
|
browser.runtime.sendMessage({ id: 'get_apps', tab: tabs[0] }, sendGetApps);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
chrome.runtime.sendMessage({ id: 'get_apps', tab: tabs[0] }, sendGetApps);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
slugify: function(string) {
|
|
|
|
// Chrome, Firefox
|
|
|
|
return string.toLowerCase().replace(/[^a-z0-9-]/g, '-').replace(/--+/g, '-').replace(/(?:^-|-$)/, '');
|
|
|
|
browser.tabs.query({ active: true, currentWindow: true }).then(callback);
|
|
|
|
|
|
|
|
} catch ( e ) {
|
|
|
|
|
|
|
|
// Edge
|
|
|
|
|
|
|
|
browser.tabs.query({ active: true, currentWindow: true }, callback);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
popup.init();
|
|
|
|
popup.init();
|
|
|
|
});
|
|
|
|
}());
|
|
|
|