From fe9a4a134b584cde352d8a5da5fbb533ffec8a5c Mon Sep 17 00:00:00 2001 From: Kevin Payravi Date: Sat, 4 Nov 2023 13:50:10 -0500 Subject: [PATCH] Simplify and fix siteSetting instantiation --- background.js | 9 +-------- content-banners.js | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/background.js b/background.js index 2a57220..4a1cf0b 100644 --- a/background.js +++ b/background.js @@ -362,14 +362,7 @@ async function main(eventInfo) { // Get user's settings for the wiki let settings = storage.wikiSettings || {}; let id = site['id']; - let siteSetting = ''; - if (settings.hasOwnProperty(id)) { - siteSetting = settings[id]; - } else if (storage.defaultWikiAction) { - siteSetting = storage.defaultWikiAction; - } else { - siteSetting = 'alert'; - } + let siteSetting = settings[id] || storage.defaultWikiAction || 'alert'; // Check if redirects are enabled for the site if (siteSetting === 'redirect') { // Get article name from the end of the URL; diff --git a/content-banners.js b/content-banners.js index 88f7e8c..14c003f 100644 --- a/content-banners.js +++ b/content-banners.js @@ -252,14 +252,7 @@ function main() { // Get user's settings for the wiki let settings = storage.wikiSettings || {}; let id = site['id']; - let siteSetting = ''; - if (settings.hasOwnProperty(id)) { - siteSetting = settings[id]; - } else if (storage.defaultActionSettings && storage.defaultActionSettings[site.language]) { - siteSetting = storage.defaultActionSettings[site.language]; - } else { - siteSetting = 'alert'; - } + let siteSetting = settings[id] || storage.defaultWikiAction || 'alert'; // Notify if enabled for the wiki: if (siteSetting === 'alert') { // Get article name from the end of the URL;