Fix options

main
Elbert Alias 7 years ago
parent b633a087c0
commit ea900bfd1f

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

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

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