Fix options

main
Elbert Alias 7 years ago
parent b633a087c0
commit ea900bfd1f

@ -32,10 +32,6 @@ do {
const wappalyzer = new Wappalyzer(url, options); const wappalyzer = new Wappalyzer(url, options);
wappalyzer.log = (message) => {
process.stdout.write('xx');
};
wappalyzer.analyze() wappalyzer.analyze()
.then((json) => { .then((json) => {
process.stdout.write(`${JSON.stringify(json)}\n`); process.stdout.write(`${JSON.stringify(json)}\n`);

@ -25,20 +25,18 @@ browser.tabs.onRemoved.addListener((tabId) => {
* Get a value from localStorage * Get a value from localStorage
*/ */
function getOption(name, defaultValue = null) { function getOption(name, defaultValue = null) {
return new Promise((resolve, reject) => { return new Promise(async (resolve) => {
const callback = (item) => { let option = defaultValue;
options[name] = item[name] ? item[name] : defaultValue;
resolve(options[name]); try {
}; option = await browser.storage.local.get(name);
} catch (error) {
wappalyzer.log(error, 'driver', 'error');
}
browser.storage.local.get(name) options[name] = option;
.then(callback)
.catch((error) => {
wappalyzer.log(error, 'driver', 'error');
reject(); resolve(option);
});
}); });
} }

@ -1,5 +1,7 @@
/** global: browser */ /** global: browser */
/** global: Wappalyzer */ /** global: Wappalyzer */
/* globals browser chrome Wappalyzer */
/* eslint-env browser */
const wappalyzer = new Wappalyzer(); const wappalyzer = new Wappalyzer();
@ -26,15 +28,15 @@ document.addEventListener('DOMContentLoaded', () => {
}); });
document.querySelector('#github').addEventListener('click', () => { document.querySelector('#github').addEventListener('click', () => {
open(wappalyzer.config.githubURL); window.open(wappalyzer.config.githubURL);
}); });
document.querySelector('#twitter').addEventListener('click', () => { document.querySelector('#twitter').addEventListener('click', () => {
open(wappalyzer.config.twitterURL); window.open(wappalyzer.config.twitterURL);
}); });
document.querySelector('#wappalyzer').addEventListener('click', () => { document.querySelector('#wappalyzer').addEventListener('click', () => {
open(wappalyzer.config.websiteURL); window.open(wappalyzer.config.websiteURL);
}); });
getOption('upgradeMessage', true, (value) => { getOption('upgradeMessage', true, (value) => {