From 933cd7b908891b098d5cfaf5b3909a1c8adf1001 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 3 Feb 2022 17:33:24 +0300 Subject: [PATCH] changing from || to ?? --- src/assets/javascripts/helpers/instagram.js | 9 ++------- src/assets/javascripts/helpers/maps.js | 2 +- src/assets/javascripts/helpers/medium.js | 2 +- src/assets/javascripts/helpers/reddit.js | 4 ++-- src/assets/javascripts/helpers/search.js | 5 ++--- src/assets/javascripts/helpers/translate.js | 4 ++-- src/assets/javascripts/helpers/twitter.js | 2 +- src/assets/javascripts/helpers/wikipedia.js | 2 +- src/assets/javascripts/helpers/youtube.js | 18 +++++++++--------- src/pages/background/background.js | 7 +++---- 10 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/assets/javascripts/helpers/instagram.js b/src/assets/javascripts/helpers/instagram.js index 367f568..69f3101 100644 --- a/src/assets/javascripts/helpers/instagram.js +++ b/src/assets/javascripts/helpers/instagram.js @@ -59,7 +59,6 @@ function setBibliogramInstance(val) { browser.storage.sync.set({ bibliogramInstance }) }; - async function redirect(url, initiator, type) { await init(); if (disableInstagram) @@ -68,11 +67,7 @@ async function redirect(url, initiator, type) { // Do not redirect Bibliogram view on Instagram links if ( initiator && - ( - initiator.origin === bibliogramInstance || - redirects.normal.includes(initiator.origin) || - targets.includes(initiator.host) - ) + (initiator.origin === bibliogramInstance || redirects.normal.includes(initiator.origin) || targets.includes(initiator.host)) ) return null; @@ -97,7 +92,7 @@ async function init() { "disableInstagram", "bibliogramInstance", ]) - disableInstagram = result.disableInstagram || false; + disableInstagram = result.disableInstagram ?? false; bibliogramInstance = result.bibliogramInstance; } diff --git a/src/assets/javascripts/helpers/maps.js b/src/assets/javascripts/helpers/maps.js index e2f8950..cfb2a90 100644 --- a/src/assets/javascripts/helpers/maps.js +++ b/src/assets/javascripts/helpers/maps.js @@ -146,7 +146,7 @@ async function init() { "disableMaps", "osmInstance", ]) - disableMaps = result.disableMaps; + disableMaps = result.disableMaps ?? false; osmInstance = result.osmInstance; } diff --git a/src/assets/javascripts/helpers/medium.js b/src/assets/javascripts/helpers/medium.js index bbae4f6..a5c43b9 100644 --- a/src/assets/javascripts/helpers/medium.js +++ b/src/assets/javascripts/helpers/medium.js @@ -64,7 +64,7 @@ async function init() { "disableMedium", "scribeInstance", ]) - disableMedium = result.disableMedium || false; + disableMedium = result.disableMedium ?? false; scribeInstance = result.scribeInstance; } diff --git a/src/assets/javascripts/helpers/reddit.js b/src/assets/javascripts/helpers/reddit.js index 25bdc80..873afd0 100644 --- a/src/assets/javascripts/helpers/reddit.js +++ b/src/assets/javascripts/helpers/reddit.js @@ -118,9 +118,9 @@ async function init() { "redditInstance", "redditFrontend", ]) - disableReddit = result.disableReddit || false; + disableReddit = result.disableReddit ?? false; redditInstance = result.redditInstance; - redditFrontend = result.redditFrontend || 'libreddit'; + redditFrontend = result.redditFrontend ?? 'libreddit'; } export default { diff --git a/src/assets/javascripts/helpers/search.js b/src/assets/javascripts/helpers/search.js index 8d17757..66e1705 100644 --- a/src/assets/javascripts/helpers/search.js +++ b/src/assets/javascripts/helpers/search.js @@ -200,15 +200,14 @@ async function redirect(url, initiator) { } async function init() { - console.log("Init Search Helper"); let result = await browser.storage.sync.get([ "disableSearch", "searchInstance", "searchFrontend", ]) - disableSearch = result.disableSearch; + disableSearch = result.disableSearch ?? false; searchInstance = result.searchInstance; - searchFrontend = result.searchFrontend; + searchFrontend = result.searchFrontend ?? 'searx'; } export default { diff --git a/src/assets/javascripts/helpers/translate.js b/src/assets/javascripts/helpers/translate.js index 8e5cd6c..e35a6a5 100644 --- a/src/assets/javascripts/helpers/translate.js +++ b/src/assets/javascripts/helpers/translate.js @@ -90,9 +90,9 @@ async function init() { "simplyTranslateInstance", "translateFrontend" ]); - disableTranslate = result.disableTranslate || false; + disableTranslate = result.disableTranslate ?? false; simplyTranslateInstance = result.simplyTranslateInstance; - translateFrontend = result.translateFrontend || "simplyTransalte"; + translateFrontend = result.translateFrontend ?? "simplyTransalte"; } export default { diff --git a/src/assets/javascripts/helpers/twitter.js b/src/assets/javascripts/helpers/twitter.js index 816ed00..e51f620 100644 --- a/src/assets/javascripts/helpers/twitter.js +++ b/src/assets/javascripts/helpers/twitter.js @@ -96,7 +96,7 @@ async function init() { "disableTwitter", "nitterInstance" ]); - disableTwitter = result.disableTwitter || false; + disableTwitter = result.disableTwitter ?? false; nitterInstance = result.nitterInstance; } diff --git a/src/assets/javascripts/helpers/wikipedia.js b/src/assets/javascripts/helpers/wikipedia.js index 57d12c3..e86f870 100644 --- a/src/assets/javascripts/helpers/wikipedia.js +++ b/src/assets/javascripts/helpers/wikipedia.js @@ -60,7 +60,7 @@ async function init() { "disableWikipedia", "wikipediaInstance", ]); - disableWikipedia = result.disableWikipedia || false; + disableWikipedia = result.disableWikipedia ?? false; wikipediaInstance = result.wikipediaInstance; } diff --git a/src/assets/javascripts/helpers/youtube.js b/src/assets/javascripts/helpers/youtube.js index ea7146d..b0077d2 100644 --- a/src/assets/javascripts/helpers/youtube.js +++ b/src/assets/javascripts/helpers/youtube.js @@ -234,17 +234,17 @@ async function init() { "invidiousAutoplay", "useFreeTube", ]); - disableYoutube = result.disableYoutube || false; + disableYoutube = result.disableYoutube ?? false; invidiousInstance = result.invidiousInstance; - invidiousAlwaysProxy = result.invidiousAlwaysProxy || true; - invidiousOnlyEmbeddedVideo = result.invidiousOnlyEmbeddedVideo || false; - invidiousVideoQuality = result.invidiousVideoQuality || 'medium'; - invidiousDarkMode = result.invidiousDarkMode || true; - invidiousVolume = result.invidiousVolume || 50; - invidiousPlayerStyle = result.invidiousPlayerStyle || 'invidious'; + invidiousAlwaysProxy = result.invidiousAlwaysProxy ?? true; + invidiousOnlyEmbeddedVideo = result.invidiousOnlyEmbeddedVideo ?? false; + invidiousVideoQuality = result.invidiousVideoQuality ?? 'medium'; + invidiousDarkMode = result.invidiousDarkMode ?? true; + invidiousVolume = result.invidiousVolume ?? 50; + invidiousPlayerStyle = result.invidiousPlayerStyle ?? 'invidious'; invidiousSubtitles = result.invidiousSubtitles || ''; - invidiousAutoplay = result.invidiousAutoplay || true; - useFreeTube = result.useFreeTube || false; + invidiousAutoplay = result.invidiousAutoplay ?? true; + useFreeTube = result.useFreeTube ?? false; if (result.persistInvidiousPrefs) initInvidiousCookie(); } diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 9c63e51..4b0532d 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -1,15 +1,14 @@ "use strict"; -import mapsHelper from "../../assets/javascripts/helpers/maps.js"; -import twitterHelper from "../../assets/javascripts/helpers/twitter.js"; import youtubeHelper from "../../assets/javascripts/helpers/youtube.js"; +import twitterHelper from "../../assets/javascripts/helpers/twitter.js"; import instagramHelper from "../../assets/javascripts/helpers/instagram.js"; -import mediumHelper from "../../assets/javascripts/helpers/medium.js"; import redditHelper from "../../assets/javascripts/helpers/reddit.js"; import searchHelper from "../../assets/javascripts/helpers/search.js"; import translateHelper from "../../assets/javascripts/helpers/translate.js"; -import wikipediaHelper from "../../assets/javascripts/helpers/wikipedia.js"; import mapsHelper from "../../assets/javascripts/helpers/maps.js"; +import wikipediaHelper from "../../assets/javascripts/helpers/wikipedia.js"; +import mediumHelper from "../../assets/javascripts/helpers/medium.js"; window.browser = window.browser || window.chrome;