From 40e15e3570f0643ca813259234e2ff2414f080af Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Wed, 2 Mar 2022 07:10:00 +0300 Subject: Added a bypass watch on twitter button. Renamed some things --- src/assets/javascripts/helpers/twitter.js | 14 ++++++++++++++ src/pages/options/reddit/reddit.html | 2 +- src/pages/options/twitter/twitter.html | 5 +++++ src/pages/options/twitter/twitter.js | 6 ++++++ 4 files changed, 26 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/assets/javascripts/helpers/twitter.js b/src/assets/javascripts/helpers/twitter.js index 992e44f3..3d0fc2e3 100644 --- a/src/assets/javascripts/helpers/twitter.js +++ b/src/assets/javascripts/helpers/twitter.js @@ -94,6 +94,14 @@ function setProtocol(val) { console.log("twitterProtocol: ", val) } +let bypassWatchOnTwitter; +const getBypassWatchOnTwitter = () => bypassWatchOnTwitter; +function setBypassWatchOnTwitter(val) { + bypassWatchOnTwitter = val; + browser.storage.local.set({ bypassWatchOnTwitter }) + console.log("bypassWatchOnTwitter: ", bypassWatchOnTwitter) +} + function redirect(url, initiator) { if (disable) return null; @@ -103,6 +111,7 @@ function redirect(url, initiator) { if (url.pathname.split("/").includes("home")) return null; if ( + bypassWatchOnTwitter && initiator && ( [...redirects.nitter.normal, ...redirects.nitter.tor, @@ -176,6 +185,8 @@ async function init() { protocol = result.twitterProtocol ?? "normal"; + bypassWatchOnTwitter = result.bypassWatchOnTwitter ?? true; + redirects.nitter = dataJson.nitter; if (result.twitterRedirects) redirects = result.twitterRedirects; @@ -212,6 +223,9 @@ export default { getNitterTorCustomRedirects, setNitterTorCustomRedirects, + getBypassWatchOnTwitter, + setBypassWatchOnTwitter, + getProtocol, setProtocol, diff --git a/src/pages/options/reddit/reddit.html b/src/pages/options/reddit/reddit.html index 4802b19d..d6776e9b 100644 --- a/src/pages/options/reddit/reddit.html +++ b/src/pages/options/reddit/reddit.html @@ -112,7 +112,7 @@
-

Bypass Watch On Reddit

+

Bypass Read on Reddit

diff --git a/src/pages/options/twitter/twitter.html b/src/pages/options/twitter/twitter.html index 02923641..a3151b43 100644 --- a/src/pages/options/twitter/twitter.html +++ b/src/pages/options/twitter/twitter.html @@ -102,6 +102,11 @@ +
+

Bypass Watch on Twitter

+ +
+
diff --git a/src/pages/options/twitter/twitter.js b/src/pages/options/twitter/twitter.js index f76230fb..2d86d9a8 100644 --- a/src/pages/options/twitter/twitter.js +++ b/src/pages/options/twitter/twitter.js @@ -29,8 +29,14 @@ function changeProtocolSettings(protocol) { } } +let bypassWatchOnTwitterElement = document.getElementById("bypass-watch-on-twitter") +bypassWatchOnTwitterElement.addEventListener("change", + event => twitterHelper.setBypassWatchOnTwitter(event.target.checked) +); + twitterHelper.init().then(() => { disableTwitterElement.checked = !twitterHelper.getDisable(); + bypassWatchOnTwitterElement.checked = twitterHelper.getBypassWatchOnTwitter(); let protocol = twitterHelper.getProtocol(); protocolElement.value = protocol; -- cgit 1.4.1