Save hostnameCache in localStorage

main
Elbert Alias 6 years ago
parent cd0b1b6e60
commit e46e4e7f1e

@ -41,7 +41,7 @@ function getOption(name, defaultValue = null) {
* Set a value in localStorage
*/
function setOption(name, value) {
var option = {};
const option = {};
option[name] = value;
@ -68,18 +68,12 @@ function post(url, body) {
method: 'POST',
body: JSON.stringify(body)
})
.then(response => {
wappalyzer.log('POST ' + url + ': ' + response.status, 'driver');
})
.catch(error => {
wappalyzer.log('POST ' + url + ': ' + error, 'driver', 'error');
});
.then(response => wappalyzer.log(`POST ${url}: ${response.status}`, 'driver'))
.catch(error => wappalyzer.log(`POST ${url}: ${error}`, 'driver', 'error'));
}
fetch('../apps.json')
.then(response => {
return response.json();
})
.then(response => response.json())
.then(json => {
wappalyzer.apps = json.apps;
wappalyzer.categories = json.categories;
@ -90,12 +84,10 @@ fetch('../apps.json')
.map(categoryId => parseInt(categoryId, 10))
.sort((a, b) => wappalyzer.categories[a].priority - wappalyzer.categories[b].priority);
})
.catch(error => {
wappalyzer.log('GET apps.json: ' + error, 'driver', 'error');
});
.catch(error => wappalyzer.log(`GET apps.json: ${error}`, 'driver', 'error'));
// Version check
var version = browser.runtime.getManifest().version;
let version = browser.runtime.getManifest().version;
getOption('version')
.then(previousVersion => {
@ -107,12 +99,10 @@ getOption('version')
getOption('upgradeMessage', true)
.then(upgradeMessage => {
if (upgradeMessage) {
/*
openTab({
url: wappalyzer.config.websiteURL + 'upgraded?v' + version,
background: true
});
*/
}
});
}
@ -123,6 +113,8 @@ getOption('version')
getOption('dynamicIcon', true);
getOption('pinnedCategory');
getOption('hostnameCache', {}).then(hostnameCache => wappalyzer.hostnameCache = hostnameCache);
// Run content script on all tabs
browser.tabs.query({ url: [ 'http://*/*', 'https://*/*' ] })
.then(tabs => {
@ -170,8 +162,8 @@ browser.webRequest.onCompleted.addListener(request => {
wappalyzer.log('Message' + (message.source ? ' from ' + message.source : '') + ': ' + message.id, 'driver');
}
var url = wappalyzer.parseUrl(sender.tab ? sender.tab.url : '');
var response;
let url = wappalyzer.parseUrl(sender.tab ? sender.tab.url : '');
let response;
switch ( message.id ) {
case 'log':
@ -186,6 +178,8 @@ browser.webRequest.onCompleted.addListener(request => {
case 'analyze':
wappalyzer.analyze(url, message.subject, { tab: sender.tab });
setOption('hostnameCache', wappalyzer.hostnameCache);
break;
case 'ad_log':
wappalyzer.cacheDetectedAds(message.subject);
@ -225,14 +219,14 @@ wappalyzer.driver.document = document;
* Log messages to console
*/
wappalyzer.driver.log = (message, source, type) => {
console.log('[wappalyzer ' + type + ']', '[' + source + ']', message);
console.log(`[wappalyzer ${type}]`, `[${source}]`, message);
};
/**
* Display apps
*/
wappalyzer.driver.displayApps = (detected, meta, context) => {
var tab = context.tab;
let tab = context.tab;
if (tab === undefined) {
return;

Loading…
Cancel
Save