diff options
author | ManeraKai <manerakai@protonmail.com> | 2022-07-27 17:44:04 +0200 |
---|---|---|
committer | ManeraKai <manerakai@protonmail.com> | 2022-07-27 17:44:04 +0200 |
commit | a9a7dba5a329eb17e23ba08802406a4e2e2cb836 (patch) | |
tree | 2cb69c855b36e82128a00e5895d5f5409d5e0a5e /src/pages | |
parent | Merge branch 'BobIsMyManager-librex' (diff) | |
parent | , (diff) | |
download | libredirect-a9a7dba5a329eb17e23ba08802406a4e2e2cb836.zip |
Merge pull request 'Squashed a few bugs' (#10) from BobIsMyManager/libredirect:master into master
Reviewed-on: https://codeberg.org/LibRedirect/libredirect/pulls/10
Diffstat (limited to 'src/pages')
38 files changed, 2164 insertions, 1973 deletions
diff --git a/src/pages/background/background.html b/src/pages/background/background.html index c9ae2a81..542df18b 100644 --- a/src/pages/background/background.html +++ b/src/pages/background/background.html @@ -1,9 +1,7 @@ <!DOCTYPE html> <html> - -<head> - <meta charset="utf-8" /> - <script type="module" src="background.js"></script> -</head> - -</html> \ No newline at end of file + <head> + <meta charset="utf-8" /> + <script type="module" src="background.js"></script> + </head> +</html> diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 293a2c84..359a912d 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -1,263 +1,252 @@ -"use strict"; - -import generalHelper from "../../assets/javascripts/general.js"; -import utils from "../../assets/javascripts/utils.js"; - -import youtubeHelper from "../../assets/javascripts/youtube/youtube.js"; -import youtubeMusicHelper from "../../assets/javascripts/youtubeMusic.js"; -import twitterHelper from "../../assets/javascripts/twitter.js"; -import instagramHelper from "../../assets/javascripts/instagram.js"; -import redditHelper from "../../assets/javascripts/reddit.js"; -import searchHelper from "../../assets/javascripts/search.js"; -import translateHelper from "../../assets/javascripts/translate/translate.js"; -import mapsHelper from "../../assets/javascripts/maps.js"; -import wikipediaHelper from "../../assets/javascripts/wikipedia.js"; -import mediumHelper from "../../assets/javascripts/medium.js"; -import quoraHelper from "../../assets/javascripts/quora.js"; -import libremdbHelper from "../../assets/javascripts/imdb.js"; -import reutersHelper from "../../assets/javascripts/reuters.js"; -import imgurHelper from "../../assets/javascripts/imgur.js"; -import tiktokHelper from "../../assets/javascripts/tiktok.js"; -import sendTargetsHelper from "../../assets/javascripts/sendTargets.js"; -import peertubeHelper from "../../assets/javascripts/peertube.js"; -import lbryHelper from "../../assets/javascripts/lbry.js"; - - -window.browser = window.browser || window.chrome; - -browser.runtime.onInstalled.addListener( - details => { - function initDefaults() { - fetch('/instances/blacklist.json').then(response => response.text()).then(async data => { - browser.storage.local.clear( - () => { - browser.storage.local.set({ cloudflareBlackList: JSON.parse(data).cloudflare }, - () => { - browser.storage.local.set({ authenticateBlackList: JSON.parse(data).authenticate }, - () => { - generalHelper.initDefaults(); - youtubeHelper.initDefaults(); - youtubeMusicHelper.initDefaults(); - twitterHelper.initDefaults(); - instagramHelper.initDefaults(); - mapsHelper.initDefaults(); - searchHelper.initDefaults(); - translateHelper.initDefaults(); - mediumHelper.initDefaults(); - quoraHelper.initDefaults(); - libremdbHelper.initDefaults(); - reutersHelper.initDefaults(); - redditHelper.initDefaults(); - wikipediaHelper.initDefaults(); - imgurHelper.initDefaults(); - tiktokHelper.initDefaults(); - sendTargetsHelper.initDefaults(); - peertubeHelper.initDefaults(); - lbryHelper.initDefaults(); - }) - }) - }); - }) - }; - if (details.reason == 'install') initDefaults(); - - // if (details.reason == 'install' || (details.reason == "update" && details.previousVersion != browser.runtime.getManifest().version)) { - // if (details.reason == "update") - // browser.storage.local.get(null, r => { - // if (r.theme) { - // const old = encodeURIComponent(JSON.stringify(r)) - // browser.tabs.create({ url: browser.runtime.getURL(`/pages/background/reset_warning.html?data=${old}`) }); - // } - // initDefaults(); - // }) - // else initDefaults(); - // } - } -) - -youtubeHelper.pasteInvidiousCookies(); -translateHelper.pasteSimplyTranslateCookies(); -twitterHelper.pasteNitterCookies(); -wikipediaHelper.pasteWikilessCookies(); -searchHelper.pasteSearxCookies(); -searchHelper.pasteSearxngCookies(); -searchHelper.pasteLibrexCookies(); -redditHelper.pasteLibredditCookies(); -redditHelper.pasteTedditCookies(); -tiktokHelper.pasteProxiTokCookies(); - - -let BYPASSTABs = []; +"use strict" + +import generalHelper from "../../assets/javascripts/general.js" +import utils from "../../assets/javascripts/utils.js" + +import youtubeHelper from "../../assets/javascripts/youtube/youtube.js" +import youtubeMusicHelper from "../../assets/javascripts/youtubeMusic.js" +import twitterHelper from "../../assets/javascripts/twitter.js" +import instagramHelper from "../../assets/javascripts/instagram.js" +import redditHelper from "../../assets/javascripts/reddit.js" +import searchHelper from "../../assets/javascripts/search.js" +import translateHelper from "../../assets/javascripts/translate/translate.js" +import mapsHelper from "../../assets/javascripts/maps.js" +import wikipediaHelper from "../../assets/javascripts/wikipedia.js" +import mediumHelper from "../../assets/javascripts/medium.js" +import quoraHelper from "../../assets/javascripts/quora.js" +import libremdbHelper from "../../assets/javascripts/imdb.js" +import reutersHelper from "../../assets/javascripts/reuters.js" +import imgurHelper from "../../assets/javascripts/imgur.js" +import tiktokHelper from "../../assets/javascripts/tiktok.js" +import sendTargetsHelper from "../../assets/javascripts/sendTargets.js" +import peertubeHelper from "../../assets/javascripts/peertube.js" +import lbryHelper from "../../assets/javascripts/lbry.js" + +window.browser = window.browser || window.chrome + +browser.runtime.onInstalled.addListener(details => { + function initDefaults() { + fetch("/instances/blacklist.json") + .then(response => response.text()) + .then(async data => { + browser.storage.local.clear(() => { + browser.storage.local.set({ cloudflareBlackList: JSON.parse(data).cloudflare }, () => { + browser.storage.local.set({ authenticateBlackList: JSON.parse(data).authenticate }, () => { + generalHelper.initDefaults() + youtubeHelper.initDefaults() + youtubeMusicHelper.initDefaults() + twitterHelper.initDefaults() + instagramHelper.initDefaults() + mapsHelper.initDefaults() + searchHelper.initDefaults() + translateHelper.initDefaults() + mediumHelper.initDefaults() + quoraHelper.initDefaults() + libremdbHelper.initDefaults() + reutersHelper.initDefaults() + redditHelper.initDefaults() + wikipediaHelper.initDefaults() + imgurHelper.initDefaults() + tiktokHelper.initDefaults() + sendTargetsHelper.initDefaults() + peertubeHelper.initDefaults() + lbryHelper.initDefaults() + }) + }) + }) + }) + } + if (details.reason == "install") initDefaults() + + // if (details.reason == 'install' || (details.reason == "update" && details.previousVersion != browser.runtime.getManifest().version)) { + // if (details.reason == "update") + // browser.storage.local.get(null, r => { + // if (r.theme) { + // const old = encodeURIComponent(JSON.stringify(r)) + // browser.tabs.create({ url: browser.runtime.getURL(`/pages/background/reset_warning.html?data=${old}`) }); + // } + // initDefaults(); + // }) + // else initDefaults(); + // } +}) + +youtubeHelper.pasteInvidiousCookies() +translateHelper.pasteSimplyTranslateCookies() +twitterHelper.pasteNitterCookies() +wikipediaHelper.pasteWikilessCookies() +searchHelper.pasteSearxCookies() +searchHelper.pasteSearxngCookies() +searchHelper.pasteLibrexCookies() +redditHelper.pasteLibredditCookies() +redditHelper.pasteTedditCookies() +tiktokHelper.pasteProxiTokCookies() + +let BYPASSTABs = [] browser.webRequest.onBeforeRequest.addListener( - details => { - const url = new URL(details.url); - if (new RegExp(/^chrome-extension:\/{2}.*\/instances\/.*.json$/).test(url.href) && details.type == 'xmlhttprequest') return; - let initiator; - try { - if (details.originUrl) initiator = new URL(details.originUrl); - else if (details.initiator) initiator = new URL(details.initiator); - } - catch { return null; } - - let newUrl = youtubeMusicHelper.redirect(url, details.type) - if (!newUrl) newUrl = youtubeHelper.redirect(url, details.type, initiator) - if (!newUrl) newUrl = twitterHelper.redirect(url, details.type, initiator); - if (!newUrl) newUrl = instagramHelper.redirect(url, details.type, initiator); - if (!newUrl) newUrl = mapsHelper.redirect(url, initiator); - if (!newUrl) newUrl = redditHelper.redirect(url, details.type, initiator); - if (!newUrl) newUrl = mediumHelper.redirect(url, details.type, initiator); - if (!newUrl) newUrl = quoraHelper.redirect(url, details.type, initiator); - if (!newUrl) newUrl = libremdbHelper.redirect(url, details.type, initiator); - if (!newUrl) newUrl = reutersHelper.redirect(url, details.type, initiator); - if (!newUrl) newUrl = imgurHelper.redirect(url, details.type, initiator); - if (!newUrl) newUrl = tiktokHelper.redirect(url, details.type, initiator); - if (!newUrl) newUrl = sendTargetsHelper.redirect(url, details.type, initiator); - if (!newUrl) newUrl = peertubeHelper.redirect(url, details.type, initiator); - if (!newUrl) newUrl = lbryHelper.redirect(url, details.type, initiator); - if (!newUrl) newUrl = translateHelper.redirect(url); - if (!newUrl) newUrl = searchHelper.redirect(url) - if (!newUrl) newUrl = wikipediaHelper.redirect(url); - - if ( - details.frameAncestors && details.frameAncestors.length > 0 && - generalHelper.isException(new URL(details.frameAncestors[0].url)) - ) newUrl = null; - - if (generalHelper.isException(url)) newUrl = 'BYPASSTAB'; - if (BYPASSTABs.includes(details.tabId)) newUrl = null; - - if (newUrl) { - if (newUrl === 'CANCEL') { - console.log(`Canceled ${url}`); - return { cancel: true }; - } - if (newUrl === 'BYPASSTAB') { - console.log(`Bypassed ${details.tabId} ${url}`); - if (!BYPASSTABs.includes(details.tabId)) BYPASSTABs.push(details.tabId); - return null; - } - console.info("Redirecting", url.href, "=>", newUrl); - return { redirectUrl: newUrl }; - } - return null; - }, - { urls: ["<all_urls>"], }, - ["blocking"] -); + details => { + const url = new URL(details.url) + if (new RegExp(/^chrome-extension:\/{2}.*\/instances\/.*.json$/).test(url.href) && details.type == "xmlhttprequest") return + let initiator + try { + if (details.originUrl) initiator = new URL(details.originUrl) + else if (details.initiator) initiator = new URL(details.initiator) + } catch { + return null + } + + let newUrl = youtubeMusicHelper.redirect(url, details.type) + if (!newUrl) newUrl = youtubeHelper.redirect(url, details.type, initiator) + if (!newUrl) newUrl = twitterHelper.redirect(url, details.type, initiator) + if (!newUrl) newUrl = instagramHelper.redirect(url, details.type, initiator) + if (!newUrl) newUrl = mapsHelper.redirect(url, initiator) + if (!newUrl) newUrl = redditHelper.redirect(url, details.type, initiator) + if (!newUrl) newUrl = mediumHelper.redirect(url, details.type, initiator) + if (!newUrl) newUrl = quoraHelper.redirect(url, details.type, initiator) + if (!newUrl) newUrl = libremdbHelper.redirect(url, details.type, initiator) + if (!newUrl) newUrl = reutersHelper.redirect(url, details.type, initiator) + if (!newUrl) newUrl = imgurHelper.redirect(url, details.type, initiator) + if (!newUrl) newUrl = tiktokHelper.redirect(url, details.type, initiator) + if (!newUrl) newUrl = sendTargetsHelper.redirect(url, details.type, initiator) + if (!newUrl) newUrl = peertubeHelper.redirect(url, details.type, initiator) + if (!newUrl) newUrl = lbryHelper.redirect(url, details.type, initiator) + if (!newUrl) newUrl = translateHelper.redirect(url) + if (!newUrl) newUrl = searchHelper.redirect(url) + if (!newUrl) newUrl = wikipediaHelper.redirect(url) + + if (details.frameAncestors && details.frameAncestors.length > 0 && generalHelper.isException(new URL(details.frameAncestors[0].url))) newUrl = null + + if (generalHelper.isException(url)) newUrl = "BYPASSTAB" + if (BYPASSTABs.includes(details.tabId)) newUrl = null + + if (newUrl) { + if (newUrl === "CANCEL") { + console.log(`Canceled ${url}`) + return { cancel: true } + } + if (newUrl === "BYPASSTAB") { + console.log(`Bypassed ${details.tabId} ${url}`) + if (!BYPASSTABs.includes(details.tabId)) BYPASSTABs.push(details.tabId) + return null + } + console.info("Redirecting", url.href, "=>", newUrl) + return { redirectUrl: newUrl } + } + return null + }, + { urls: ["<all_urls>"] }, + ["blocking"] +) -browser.tabs.onRemoved.addListener( - tabId => { - const i = BYPASSTABs.indexOf(tabId); - if (i > -1) { - BYPASSTABs.splice(i, 1); - console.log("Removed BYPASSTABs", tabId); - } - } -); +browser.tabs.onRemoved.addListener(tabId => { + const i = BYPASSTABs.indexOf(tabId) + if (i > -1) { + BYPASSTABs.splice(i, 1) + console.log("Removed BYPASSTABs", tabId) + } +}) browser.webRequest.onHeadersReceived.addListener( - e => { - let response = youtubeHelper.removeXFrameOptions(e); - if (!response) response = twitterHelper.removeXFrameOptions(e); - return response; - }, - { urls: ["<all_urls>"] }, - ["blocking", "responseHeaders"] -); + e => { + let response = youtubeHelper.removeXFrameOptions(e) + if (!response) response = twitterHelper.removeXFrameOptions(e) + return response + }, + { urls: ["<all_urls>"] }, + ["blocking", "responseHeaders"] +) async function redirectOfflineInstance(url, tabId) { - let newUrl = await youtubeHelper.switchInstance(url); - if (!newUrl) newUrl = await twitterHelper.switchInstance(url); - if (!newUrl) newUrl = await instagramHelper.switchInstance(url); - if (!newUrl) newUrl = await redditHelper.switchInstance(url); - if (!newUrl) newUrl = await searchHelper.switchInstance(url); - if (!newUrl) newUrl = await translateHelper.switchInstance(url); - if (!newUrl) newUrl = await mediumHelper.switchInstance(url); - if (!newUrl) newUrl = await quoraHelper.switchInstance(url); - if (!newUrl) newUrl = await libremdbHelper.switchInstance(url); - if (!newUrl) newUrl = await tiktokHelper.switchInstance(url); - if (!newUrl) newUrl = await imgurHelper.switchInstance(url); - if (!newUrl) newUrl = await wikipediaHelper.switchInstance(url); - if (!newUrl) newUrl = await peertubeHelper.switchInstance(url); - if (!newUrl) newUrl = await lbryHelper.switchInstance(url); - - if (newUrl) { - if (counter >= 5) { - browser.tabs.update(tabId, { url: `/pages/errors/instance_offline.html?url=${encodeURIComponent(newUrl)}` }); - counter = 0; - } else { - browser.tabs.update(tabId, { url: newUrl }); - counter++; - } - } + let newUrl = await youtubeHelper.switchInstance(url, true) + if (!newUrl) newUrl = await twitterHelper.switchInstance(url, true) + if (!newUrl) newUrl = await instagramHelper.switchInstance(url, true) + if (!newUrl) newUrl = await redditHelper.switchInstance(url, true) + if (!newUrl) newUrl = await searchHelper.switchInstance(url, true) + if (!newUrl) newUrl = await translateHelper.switchInstance(url, true) + if (!newUrl) newUrl = await mediumHelper.switchInstance(url, true) + if (!newUrl) newUrl = await quoraHelper.switchInstance(url, true) + if (!newUrl) newUrl = await libremdbHelper.switchInstance(url, true) + if (!newUrl) newUrl = await tiktokHelper.switchInstance(url, true) + if (!newUrl) newUrl = await imgurHelper.switchInstance(url, true) + if (!newUrl) newUrl = await wikipediaHelper.switchInstance(url, true) + if (!newUrl) newUrl = await peertubeHelper.switchInstance(url, true) + if (!newUrl) newUrl = await lbryHelper.switchInstance(url, true) + if (!newUrl) newUrl = await youtubeMusicHelper.switchInstance(url, true) + + if (newUrl) { + if (counter >= 5) { + browser.tabs.update(tabId, { + url: `/pages/errors/instance_offline.html?url=${encodeURIComponent(newUrl)}`, + }) + counter = 0 + } else { + browser.tabs.update(tabId, { url: newUrl }) + counter++ + } + } } -let counter = 0; +let counter = 0 function isAutoRedirect() { - return new Promise(resolve => browser.storage.local.get('autoRedirect', r => resolve(r.autoRedirect == true))) + return new Promise(resolve => browser.storage.local.get("autoRedirect", r => resolve(r.autoRedirect == true))) } browser.webRequest.onResponseStarted.addListener( - async details => { - if (!await isAutoRedirect()) return null; - if (details.type == 'main_frame' && details.statusCode >= 500) redirectOfflineInstance(new URL(details.url), details.tabId); - }, - { urls: ["<all_urls>"] } + async details => { + if (!(await isAutoRedirect())) return null + if (details.type == "main_frame" && details.statusCode >= 500) redirectOfflineInstance(new URL(details.url), details.tabId) + }, + { urls: ["<all_urls>"] } ) browser.webRequest.onErrorOccurred.addListener( - async details => { - if (!await isAutoRedirect()) return; - if (details.type == 'main_frame') redirectOfflineInstance(new URL(details.url), details.tabId); - }, - { urls: ["<all_urls>"] } + async details => { + if (!(await isAutoRedirect())) return + if (details.type == "main_frame") redirectOfflineInstance(new URL(details.url), details.tabId) + }, + { urls: ["<all_urls>"] } ) -browser.commands.onCommand.addListener( - command => { - if (command === 'switchInstance') utils.switchInstance(); - else if (command == 'copyRaw') utils.copyRaw(); - else if (command == 'unify') utils.unify(); - } -) +browser.commands.onCommand.addListener(command => { + if (command === "switchInstance") utils.switchInstance() + else if (command == "copyRaw") utils.copyRaw() + else if (command == "unify") utils.unify() +}) browser.contextMenus.create({ - id: "settings", - title: browser.i18n.getMessage("Settings"), - contexts: ["browser_action"] -}); + id: "settings", + title: browser.i18n.getMessage("Settings"), + contexts: ["browser_action"], +}) browser.contextMenus.create({ - id: "switchInstance", - title: browser.i18n.getMessage("switchInstance"), - contexts: ["browser_action"] -}); + id: "switchInstance", + title: browser.i18n.getMessage("switchInstance"), + contexts: ["browser_action"], +}) browser.contextMenus.create({ - id: "copyRaw", - title: browser.i18n.getMessage("copyRaw"), - contexts: ["browser_action"] -}); + id: "copyRaw", + title: browser.i18n.getMessage("copyRaw"), + contexts: ["browser_action"], +}) browser.contextMenus.create({ - id: "unify", - title: browser.i18n.getMessage("unifySettings"), - contexts: ["browser_action"] -}); - - -browser.contextMenus.onClicked.addListener( - (info) => { - if (info.menuItemId == 'switchInstance') utils.switchInstance(); - else if (info.menuItemId == 'settings') browser.runtime.openOptionsPage() - else if (info.menuItemId == 'copyRaw') utils.copyRaw(); - else if (info.menuItemId == 'unify') utils.unify(); - } -); + id: "unify", + title: browser.i18n.getMessage("unifySettings"), + contexts: ["browser_action"], +}) + +browser.contextMenus.onClicked.addListener(info => { + if (info.menuItemId == "switchInstance") utils.switchInstance() + else if (info.menuItemId == "settings") browser.runtime.openOptionsPage() + else if (info.menuItemId == "copyRaw") utils.copyRaw() + else if (info.menuItemId == "unify") utils.unify() +}) browser.runtime.onMessage.addListener((message, sender, sendResponse) => { - if (message.function === 'unify') utils.unify(false).then(r => sendResponse({ response: r })) - return true; -}); + if (message.function === "unify") utils.unify(false).then(r => sendResponse({ response: r })) + return true +}) -browser.storage.local.set({"version": browser.runtime.getManifest().version}) +browser.storage.local.set({ version: browser.runtime.getManifest().version }) diff --git a/src/pages/background/incognito.html b/src/pages/background/incognito.html index 7b1c0ee1..227d99e4 100644 --- a/src/pages/background/incognito.html +++ b/src/pages/background/incognito.html @@ -1,37 +1,35 @@ <!DOCTYPE html> <html> + <head> + <meta charset="utf-8" /> + <meta charset="UTF-8" /> + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <title data-localise="__MSG_instanceIsOff__">Initializing Cookies</title> + <link href="../stylesheets/styles.css" rel="stylesheet" /> + <style> + body { + margin: 0; + padding: 0; + height: 100vh; + width: 100vw; + flex-wrap: wrap; + justify-content: center; + align-items: center; + font-size: 30px; + display: flex; + } -<head> - <meta charset="utf-8" /> - <meta charset="UTF-8"> - <meta http-equiv="X-UA-Compatible" content="IE=edge"> - <meta name="viewport" content="width=device-width, initial-scale=1" /> - <title data-localise="__MSG_instanceIsOff__">Initializing Cookies</title> - <link href="../stylesheets/styles.css" rel="stylesheet" /> - <style> - body { - margin: 0; - padding: 0; - height: 100vh; - width: 100vw; - flex-wrap: wrap; - justify-content: center; - align-items: center; - font-size: 30px; - display: flex; - } + div { + text-align: center; + } + </style> + </head> - div { - text-align: center; - } - </style> -</head> - -<body> - <div> - <p>Initializing Cookies...</p> - </div> - <script type="module" src="incognito.js"></script> -</body> - -</html> \ No newline at end of file + <body> + <div> + <p>Initializing Cookies...</p> + </div> + <script type="module" src="incognito.js"></script> + </body> +</html> diff --git a/src/pages/background/incognito.js b/src/pages/background/incognito.js index f42eadcf..c7ed2b7d 100644 --- a/src/pages/background/incognito.js +++ b/src/pages/background/incognito.js @@ -1,22 +1,22 @@ -import youtubeHelper from "../../assets/javascripts/youtube/youtube.js"; -import twitterHelper from "../../assets/javascripts/twitter.js"; -import redditHelper from "../../assets/javascripts/reddit.js"; -import searchHelper from "../../assets/javascripts/search.js"; -import translateHelper from "../../assets/javascripts/translate/translate.js"; -import wikipediaHelper from "../../assets/javascripts/wikipedia.js"; -import tiktokHelper from "../../assets/javascripts/tiktok.js"; +import youtubeHelper from "../../assets/javascripts/youtube/youtube.js" +import twitterHelper from "../../assets/javascripts/twitter.js" +import redditHelper from "../../assets/javascripts/reddit.js" +import searchHelper from "../../assets/javascripts/search.js" +import translateHelper from "../../assets/javascripts/translate/translate.js" +import wikipediaHelper from "../../assets/javascripts/wikipedia.js" +import tiktokHelper from "../../assets/javascripts/tiktok.js" -window.browser = window.browser || window.chrome; +window.browser = window.browser || window.chrome -await youtubeHelper.pasteInvidiousCookies(); -await translateHelper.pasteSimplyTranslateCookies(); -await twitterHelper.pasteNitterCookies(); -await wikipediaHelper.pasteWikilessCookies(); -await searchHelper.pasteSearxCookies(); -await searchHelper.pasteSearxngCookies(); -await searchHelper.pasteLibrexCookies(); -await redditHelper.pasteLibredditCookies(); -await redditHelper.pasteTedditCookies(); -await tiktokHelper.pasteProxiTokCookies(); +await youtubeHelper.pasteInvidiousCookies() +await translateHelper.pasteSimplyTranslateCookies() +await twitterHelper.pasteNitterCookies() +await wikipediaHelper.pasteWikilessCookies() +await searchHelper.pasteSearxCookies() +await searchHelper.pasteSearxngCookies() +await searchHelper.pasteLibrexCookies() +await redditHelper.pasteLibredditCookies() +await redditHelper.pasteTedditCookies() +await tiktokHelper.pasteProxiTokCookies() window.close() diff --git a/src/pages/background/reset_warning.html b/src/pages/background/reset_warning.html index d2d493e0..f1881ed8 100644 --- a/src/pages/background/reset_warning.html +++ b/src/pages/background/reset_warning.html @@ -1,66 +1,59 @@ <!DOCTYPE html> <html lang="en"> - -<head> - <meta charset="UTF-8"> - <meta http-equiv="X-UA-Compatible" content="IE=edge"> - <meta name="viewport" content="width=device-width, initial-scale=1" /> - <title data-localise="__MSG_instanceIsOff__">Reset Warning</title> - <link href="../stylesheets/styles.css" rel="stylesheet" /> - <style> - body { - margin: 0; - padding: 0; - height: 100vh; - width: 100vw; - flex-wrap: wrap; - justify-content: center; - align-items: center; - font-size: 30px; - display: flex; - } - - div { - width: 80%; - } - - div.logo { - display: flex; - } - - img { - width: 90px; - height: auto; - } - </style> - -</head> - -<body> - <div> - <div class="logo"> - <img src="/assets/images/libredirect.svg" alt="LibRedirect icon"> - <h1>LibRedirect</h1> - </div> - - <p data-localise="__MSG_instanceOffline__">All settings have been reset as they're incompatible with the - previous version.</p> - <p>Sorry for the inconvenience, but we're going in a fast development process and can't - support nor convert older settings. It will reach a stable plateau though.</p> - - - <a id="export-settings" class="button button-inline"> - <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" - fill="currentColor"> - <path - d="M10.09 15.59L11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67l-2.58 2.59zM19 3H5c-1.11 0-2 .9-2 2v4h2V5h14v14H5v-4H3v4c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"> - </path> - </svg> - - <x data-localise="__MSG_exportSettings__">Export Settings</x> - </a> - </div> -</body> -<script src="reset_warning.js"></script> - -</html> \ No newline at end of file + <head> + <meta charset="UTF-8" /> + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <title data-localise="__MSG_instanceIsOff__">Reset Warning</title> + <link href="../stylesheets/styles.css" rel="stylesheet" /> + <style> + body { + margin: 0; + padding: 0; + height: 100vh; + width: 100vw; + flex-wrap: wrap; + justify-content: center; + align-items: center; + font-size: 30px; + display: flex; + } + + div { + width: 80%; + } + + div.logo { + display: flex; + } + + img { + width: 90px; + height: auto; + } + </style> + </head> + + <body> + <div> + <div class="logo"> + <img src="/assets/images/libredirect.svg" alt="LibRedirect icon" /> + <h1>LibRedirect</h1> + </div> + + <p data-localise="__MSG_instanceOffline__">All settings have been reset as they're incompatible with the previous version.</p> + <p>Sorry for the inconvenience, but we're going in a fast development process and can't support nor convert older settings. It will reach a stable plateau though.</p> + + <a id="export-settings" class="button button-inline"> + <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> + <path + d="M10.09 15.59L11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67l-2.58 2.59zM19 3H5c-1.11 0-2 .9-2 2v4h2V5h14v14H5v-4H3v4c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z" + ></path> + </svg> + + <x data-localise="__MSG_exportSettings__">Export Settings</x> + </a> + </div> + </body> + <script src="reset_warning.js"></script> +</html> diff --git a/src/pages/background/reset_warning.js b/src/pages/background/reset_warning.js index 15e3a594..9ce49c9a 100644 --- a/src/pages/background/reset_warning.js +++ b/src/pages/background/reset_warning.js @@ -1,11 +1,7 @@ -let params = new URLSearchParams(location.search); +let params = new URLSearchParams(location.search) -const resultString = JSON.stringify( - JSON.parse(params.get('data')), - null, - ' ' -); +const resultString = JSON.stringify(JSON.parse(params.get("data")), null, " ") -let exportSettingsElement = document.getElementById("export-settings"); -exportSettingsElement.href = 'data:application/json;base64,' + btoa(resultString); -exportSettingsElement.download = 'libredirect-settings.json'; +let exportSettingsElement = document.getElementById("export-settings") +exportSettingsElement.href = "data:application/json;base64," + btoa(resultString) +exportSettingsElement.download = "libredirect-settings.json" diff --git a/src/pages/errors/instance_offline.html b/src/pages/errors/instance_offline.html index 3b7e46d5..4f27445c 100644 --- a/src/pages/errors/instance_offline.html +++ b/src/pages/errors/instance_offline.html @@ -1,41 +1,38 @@ <!DOCTYPE html> <html lang="en"> + <head> + <meta charset="UTF-8" /> + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <title data-localise="__MSG_instanceIsOff__">Instance is offline</title> + <link href="../stylesheets/styles.css" rel="stylesheet" /> + <style> + body { + margin: 0; + padding: 0; + height: 100vh; + width: 100vw; + flex-wrap: wrap; + justify-content: center; + align-items: center; + font-size: 30px; + display: flex; + } -<head> - <meta charset="UTF-8"> - <meta http-equiv="X-UA-Compatible" content="IE=edge"> - <meta name="viewport" content="width=device-width, initial-scale=1" /> - <title data-localise="__MSG_instanceIsOff__">Instance is offline</title> - <link href="../stylesheets/styles.css" rel="stylesheet" /> - <style> - body { - margin: 0; - padding: 0; - height: 100vh; - width: 100vw; - flex-wrap: wrap; - justify-content: center; - align-items: center; - font-size: 30px; - display: flex; - } + div { + text-align: center; + } + </style> + </head> - div { - text-align: center; - } - </style> + <body> + <div> + <p id="message" data-localise="__MSG_instanceOffline__"> + This instance is offline, you'll be redirected after <span id="number">2</span> <x data-localise="__MSG_sec__">seconds</x> + </p> + <button id="cancel" data-localise="__MSG_cancel__">Cancel</button> + </div> -</head> - -<body> - <div> - <p id="message" data-localise="__MSG_instanceOffline__">This instance is offline, you'll be redirected - after <span id="number">2</span> <x data-localise="__MSG_sec__">seconds</x> - </p> - <button id="cancel" data-localise="__MSG_cancel__">Cancel</button> - </div> - - <script src="instance_offline.js" type="module"></script> -</body> - -</html> \ No newline at end of file + <script src="instance_offline.js" type="module"></script> + </body> +</html> diff --git a/src/pages/errors/instance_offline.js b/src/pages/errors/instance_offline.js index 8137ccd0..fadb7681 100644 --- a/src/pages/errors/instance_offline.js +++ b/src/pages/errors/instance_offline.js @@ -1,25 +1,20 @@ -import localise from "../../assets/javascripts/localise.js"; +import localise from "../../assets/javascripts/localise.js" +const params = new Proxy(new URLSearchParams(window.location.search), { + get: (searchParams, prop) => searchParams.get(prop), +}) -const params = new Proxy( - new URLSearchParams(window.location.search), - { get: (searchParams, prop) => searchParams.get(prop) } -); - -let number = document.getElementById("number"); -setTimeout(() => number.innerHTML = '1', 1000); -setTimeout( - () => { - number.innerHTML = '0' - if (!isCanceled) window.location = params.url; - }, - 2000 -); +let number = document.getElementById("number") +setTimeout(() => (number.innerHTML = "1"), 1000) +setTimeout(() => { + number.innerHTML = "0" + if (!isCanceled) window.location = params.url +}, 2000) -let isCanceled = false; +let isCanceled = false document.getElementById("cancel").addEventListener("click", () => { - isCanceled = true; - document.getElementById("message").innerHTML = browser.i18n.getMessage('redirectionCanceled'); + isCanceled = true + document.getElementById("message").innerHTML = browser.i18n.getMessage("redirectionCanceled") }) -localise.localisePage(); \ No newline at end of file +localise.localisePage() diff --git a/src/pages/options/index.html b/src/pages/options/index.html index 29e454bf..84955339 100644 --- a/src/pages/options/index.html +++ b/src/pages/options/index.html @@ -285,6 +285,7 @@ <option value="invidious">Invidious</option> <option value="piped">Piped</option> <option value="pipedMaterial">Piped-Material</option> + <option value="cloudtube">CloudTube</option> <option value="freetube">FreeTube</option> <option value="yatte">Yattee</option> </select> @@ -296,6 +297,7 @@ <option value="invidious">Invidious</option> <option value="piped">Piped</option> <option value="pipedMaterial">Piped-Material</option> + <option value="cloudtube">CloudTube</option> </select> </div> </div> @@ -595,6 +597,102 @@ <div class="checklist custom-checklist"></div> </div> </div> + <div id="cloudtube"> + <hr> + <div class="normal"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="https://cloudtube.com" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + <div class="buttons buttons-inline"> + <label class="button button-inline" id="latency-cloudtube-label" for="latency-cloudtube"> + <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> + <path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"></path> + </svg> + <x data-localise="__MSG_testInstancesLatency__">Test Instances Latency</x> + </label> + <input class="button button-inline" id="latency-cloudtube" style="display:none;"> + </div> + </div> + <div class="tor"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://cloudtube.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://cloudtube.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://cloudtube.loki" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + </div> <script type="module" src="./widgets/youtube.js"></script> </section> <section class="option-block" id="youtubeMusic_page"> @@ -606,6 +704,13 @@ <h4 data-localise="__MSG_enable__">Enable</h4> <input id="youtubeMusic-enable" type="checkbox"> </div> + <div class="some-block option-block"> + <h4 data-localise="__MSG_frontend__">Frontend</h4> + <select id="youtubeMusic-frontend"> + <option value="beatbump">Beatbump</option> + <option value="hyperpipe">Hyperpipe</option> + </select> + </div> <div id="beatbump"> <hr> <div class="normal"> @@ -619,7 +724,7 @@ </div> <form class="custom-instance-form"> <div class="some-block option-block"> - <input class="custom-instance" placeholder="https://beatbump.wewe" type="url"> + <input class="custom-instance" placeholder="https://beatbump.org" type="url"> <button class="add add-instance" type="submit"> <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> @@ -702,6 +807,102 @@ <div class="checklist custom-checklist"></div> </div> </div> + <div id="hyperpipe"> + <hr> + <div class="normal"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="https://hyperpipe.org" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + <div class="buttons buttons-inline"> + <label class="button button-inline" id="latency-hyperpipe-label" for="latency-hyperpipe"> + <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> + <path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"></path> + </svg> + <x data-localise="__MSG_testInstancesLatency__">Test Instances Latency</x> + </label> + <input class="button button-inline" id="latency-hyperpipe" style="display:none;"> + </div> + </div> + <div class="tor"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://hyperpipe.onion" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="i2p"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://hyperpipe.i2p" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + <div class="loki"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://hyperpipe.loki" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + </div> + </div> <script type="module" src="./widgets/youtubeMusic.js"></script> </section> <section class="option-block" id="twitter_page"> @@ -1994,13 +2195,20 @@ </section> <section class="option-block" id="lbry_page"> <div class="some-block option-block"> - <h1 data-localise="__MSG_lbry__">LBRY/Odysee</h1> + <h1 data-localise="__MSG_lbry__">LBRY</h1> </div> <hr> <div class="some-block option-block"> <h4 data-localise="__MSG_enable__">Enable</h4> <input id="lbry-enable" type="checkbox"> </div> + <div class="some-block option-block"> + <h4 data-localise="__MSG_frontend__">Frontend</h4> + <select id="lbry-frontend"> + <option value="librarian">Librarian</option> + <option value="lbryDesktop" data-localise="__MSG_lbryDesktop__">LBRY Desktop</option> + </select> + </div> <div id="librarian"> <hr> <div class="normal"> diff --git a/src/pages/options/index.js b/src/pages/options/index.js index 39f9c8f3..409fa5b5 100644 --- a/src/pages/options/index.js +++ b/src/pages/options/index.js @@ -1,24 +1,23 @@ -for (const a of document.getElementById('links').getElementsByTagName('a')) { - a.addEventListener('click', e => { - const path = a.getAttribute('href').replace('#', ''); - loadPage(path); - e.preventDefault(); - }) +for (const a of document.getElementById("links").getElementsByTagName("a")) { + a.addEventListener("click", e => { + const path = a.getAttribute("href").replace("#", "") + loadPage(path) + e.preventDefault() + }) } function loadPage(path) { - for (const section of document.getElementById('pages').getElementsByTagName('section')) - section.style.display = 'none'; - document.getElementById(`${path}_page`).style.display = 'block'; + for (const section of document.getElementById("pages").getElementsByTagName("section")) section.style.display = "none" + document.getElementById(`${path}_page`).style.display = "block" - for (const a of document.getElementById('links').getElementsByTagName('a')) - if (a.getAttribute('href') == `#${path}`) a.classList.add('selected') - else a.classList.remove('selected') + for (const a of document.getElementById("links").getElementsByTagName("a")) + if (a.getAttribute("href") == `#${path}`) a.classList.add("selected") + else a.classList.remove("selected") - let stateObj = { id: "100" }; - window.history.pushState(stateObj, "Page 2", `/pages/options/index.html#${path}`); + let stateObj = { id: "100" } + window.history.pushState(stateObj, "Page 2", `/pages/options/index.html#${path}`) } const r = window.location.href.match(/#(.*)/) -if (r) loadPage(r[1]); -else loadPage('general'); \ No newline at end of file +if (r) loadPage(r[1]) +else loadPage("general") diff --git a/src/pages/options/init.js b/src/pages/options/init.js index daea2963..5b679da4 100644 --- a/src/pages/options/init.js +++ b/src/pages/options/init.js @@ -1,38 +1,35 @@ -window.browser = window.browser || window.chrome; +window.browser = window.browser || window.chrome -import localise from "../../assets/javascripts/localise.js"; +import localise from "../../assets/javascripts/localise.js" function changeTheme() { - return new Promise(resolve => { - browser.storage.local.get( - "theme", - r => { - switch (r.theme) { - case "dark": - document.body.classList.add("dark-theme"); - document.body.classList.remove("light-theme"); - break; - case "light": - document.body.classList.add("light-theme"); - document.body.classList.remove("dark-theme"); - break; - default: - if (matchMedia("(prefers-color-scheme: light)").matches) { - document.body.classList.add("light-theme"); - document.body.classList.remove("dark-theme"); - } else { - document.body.classList.add("dark-theme"); - document.body.classList.remove("light-theme"); - } - } - resolve(); - } - ) - }) + return new Promise(resolve => { + browser.storage.local.get("theme", r => { + switch (r.theme) { + case "dark": + document.body.classList.add("dark-theme") + document.body.classList.remove("light-theme") + break + case "light": + document.body.classList.add("light-theme") + document.body.classList.remove("dark-theme") + break + default: + if (matchMedia("(prefers-color-scheme: light)").matches) { + document.body.classList.add("light-theme") + document.body.classList.remove("dark-theme") + } else { + document.body.classList.add("dark-theme") + document.body.classList.remove("light-theme") + } + } + resolve() + }) + }) } -changeTheme(); -if (["ar", "iw", "ku", "fa", "ur"].includes(browser.i18n.getUILanguage())) document.getElementsByTagName("body")[0].classList.add("rtl"); -localise.localisePage(); +changeTheme() +if (["ar", "iw", "ku", "fa", "ur"].includes(browser.i18n.getUILanguage())) document.getElementsByTagName("body")[0].classList.add("rtl") +localise.localisePage() -window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", changeTheme) \ No newline at end of file +window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", changeTheme) diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index 352e4b76..5407159d 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -1,242 +1,217 @@ -"use strict"; -window.browser = window.browser || window.chrome; +"use strict" +window.browser = window.browser || window.chrome -import utils from "../../../assets/javascripts/utils.js"; -import generalHelper from "../../../assets/javascripts/general.js"; +import utils from "../../../assets/javascripts/utils.js" +import generalHelper from "../../../assets/javascripts/general.js" -import youtubeHelper from "../../../assets/javascripts/youtube/youtube.js"; -import youtubeMusicHelper from "../../../assets/javascripts/youtubeMusic.js"; -import twitterHelper from "../../../assets/javascripts/twitter.js"; -import instagramHelper from "../../../assets/javascripts/instagram.js"; -import redditHelper from "../../../assets/javascripts/reddit.js"; -import searchHelper from "../../../assets/javascripts/search.js"; -import translateHelper from "../../../assets/javascripts/translate/translate.js"; -import mapsHelper from "../../../assets/javascripts/maps.js"; -import wikipediaHelper from "../../../assets/javascripts/wikipedia.js"; -import mediumHelper from "../../../assets/javascripts/medium.js"; -import quoraHelper from "../../../assets/javascripts/quora.js"; -import libremdbHelper from "../../../assets/javascripts/imdb.js"; -import reutersHelper from "../../../assets/javascripts/reuters.js"; -import imgurHelper from "../../../assets/javascripts/imgur.js"; -import tiktokHelper from "../../../assets/javascripts/tiktok.js"; -import sendTargetsHelper from "../../../assets/javascripts/sendTargets.js"; -import peertubeHelper from "../../../assets/javascripts/peertube.js"; -import lbryHelper from "../../../assets/javascripts/lbry.js"; +import youtubeHelper from "../../../assets/javascripts/youtube/youtube.js" +import youtubeMusicHelper from "../../../assets/javascripts/youtubeMusic.js" +import twitterHelper from "../../../assets/javascripts/twitter.js" +import instagramHelper from "../../../assets/javascripts/instagram.js" +import redditHelper from "../../../assets/javascripts/reddit.js" +import searchHelper from "../../../assets/javascripts/search.js" +import translateHelper from "../../../assets/javascripts/translate/translate.js" +import mapsHelper from "../../../assets/javascripts/maps.js" +import wikipediaHelper from "../../../assets/javascripts/wikipedia.js" +import mediumHelper from "../../../assets/javascripts/medium.js" +import quoraHelper from "../../../assets/javascripts/quora.js" +import libremdbHelper from "../../../assets/javascripts/imdb.js" +import reutersHelper from "../../../assets/javascripts/reuters.js" +import imgurHelper from "../../../assets/javascripts/imgur.js" +import tiktokHelper from "../../../assets/javascripts/tiktok.js" +import sendTargetsHelper from "../../../assets/javascripts/sendTargets.js" +import peertubeHelper from "../../../assets/javascripts/peertube.js" +import lbryHelper from "../../../assets/javascripts/lbry.js" -let updateInstancesElement = document.getElementById("update-instances"); +let updateInstancesElement = document.getElementById("update-instances") updateInstancesElement.addEventListener("click", async () => { - let oldHtml = updateInstancesElement.innerHTML - updateInstancesElement.innerHTML = '...'; - if (await utils.updateInstances()) { - updateInstancesElement.innerHTML = oldHtml; - location.reload(); - } - else - updateInstancesElement.innerHTML = 'Failed Miserabely'; -}); + let oldHtml = updateInstancesElement.innerHTML + updateInstancesElement.innerHTML = "..." + if (await utils.updateInstances()) { + updateInstancesElement.innerHTML = oldHtml + location.reload() + } else updateInstancesElement.innerHTML = "Failed Miserabely" +}) -let exportSettingsElement = document.getElementById("export-settings"); +let exportSettingsElement = document.getElementById("export-settings") function exportSettings() { - browser.storage.local.get( - null, - result => { - let resultString = JSON.stringify(result, null, ' '); - exportSettingsElement.href = 'data:application/json;base64,' + btoa(encodeURI(resultString)); - exportSettingsElement.download = 'libredirect-settings.json'; - } - ); + browser.storage.local.get(null, result => { + let resultString = JSON.stringify(result, null, " ") + exportSettingsElement.href = "data:application/json;base64," + btoa(encodeURI(resultString)) + exportSettingsElement.download = "libredirect-settings.json" + }) } -exportSettings(); - -document.getElementById('general_page').addEventListener('click', exportSettings) +exportSettings() -let importSettingsElement = document.getElementById("import-settings"); -let importSettingsElementText = document.getElementById('import_settings_text'); -importSettingsElement.addEventListener("change", - () => { - importSettingsElementText.innerHTML = '...'; - let file = importSettingsElement.files[0]; - const reader = new FileReader(); - reader.readAsText(file); - reader.onload = async () => { - const data = JSON.parse(reader.result) - if ( - "theme" in data && - "disableImgur" in data && - "imgurRedirects" in data - ) { - browser.storage.local.clear( - () => { - browser.storage.local.set({ ...data }, - async () => { - await youtubeHelper.pasteInvidiousCookies(); - await youtubeHelper.pastePipedLocalStorage(); - await youtubeHelper.pastePipedMaterialLocalStorage(); +document.getElementById("general_page").addEventListener("click", exportSettings) - await translateHelper.pasteSimplyTranslateCookies(); - await translateHelper.pasteLingvaLocalStorage(); +let importSettingsElement = document.getElementById("import-settings") +let importSettingsElementText = document.getElementById("import_settings_text") +importSettingsElement.addEventListener("change", () => { + importSettingsElementText.innerHTML = "..." + let file = importSettingsElement.files[0] + const reader = new FileReader() + reader.readAsText(file) + reader.onload = async () => { + const data = JSON.parse(reader.result) + if ("theme" in data && "disableImgur" in data && "imgurRedirects" in data) { + browser.storage.local.clear(() => { + browser.storage.local.set({ ...data }, async () => { + await youtubeHelper.pasteInvidiousCookies() + await youtubeHelper.pastePipedLocalStorage() + await youtubeHelper.pastePipedMaterialLocalStorage() - await twitterHelper.pasteNitterCookies(); + await translateHelper.pasteSimplyTranslateCookies() + await translateHelper.pasteLingvaLocalStorage() - await wikipediaHelper.pasteWikilessCookies(); + await twitterHelper.pasteNitterCookies() - await searchHelper.pasteSearxCookies(); - await searchHelper.pasteSearxngCookies(); - await searchHelper.pasteLibrexCookies(); + await wikipediaHelper.pasteWikilessCookies() - await redditHelper.pasteLibredditCookies(); - await redditHelper.pasteTedditCookies(); + await searchHelper.pasteSearxCookies() + await searchHelper.pasteSearxngCookies() + await searchHelper.pasteLibrexCookies() - await tiktokHelper.pasteProxiTokCookies(); + await redditHelper.pasteLibredditCookies() + await redditHelper.pasteTedditCookies() - location.reload(); - }) + await tiktokHelper.pasteProxiTokCookies() - }); - } else { - console.log('incompatible settings'); - importError() - } - } - reader.onerror = error => { - console.log('error', error); - importError() - }; - } -); + location.reload() + }) + }) + } else { + console.log("incompatible settings") + importError() + } + } + reader.onerror = error => { + console.log("error", error) + importError() + } +}) function importError() { - const oldHTML = importSettingsElementText.innerHTML; - importSettingsElementText.innerHTML = '<span style="color:red;">Error!</span>'; - setTimeout(() => importSettingsElementText.innerHTML = oldHTML, 1000); + const oldHTML = importSettingsElementText.innerHTML + importSettingsElementText.innerHTML = '<span style="color:red;">Error!</span>' + setTimeout(() => (importSettingsElementText.innerHTML = oldHTML), 1000) } -const resetSettings = document.getElementById("reset-settings"); -resetSettings.addEventListener("click", - async () => { - resetSettings.innerHTML = '...' - browser.storage.local.clear( - () => { - fetch('/instances/blacklist.json').then(response => response.text()).then(async data => { - browser.storage.local.set({ cloudflareBlackList: JSON.parse(data).cloudflare }, - () => { - browser.storage.local.set({ authenticateBlackList: JSON.parse(data).authenticate }, - async () => { - await generalHelper.initDefaults(); - await youtubeHelper.initDefaults(); - await youtubeMusicHelper.initDefaults(); - await twitterHelper.initDefaults(); - await instagramHelper.initDefaults(); - await mapsHelper.initDefaults(); - await searchHelper.initDefaults(); - await translateHelper.initDefaults(); - await mediumHelper.initDefaults(); - await quoraHelper.initDefaults(); - await libremdbHelper.initDefaults(); - await reutersHelper.initDefaults(); - await redditHelper.initDefaults(); - await wikipediaHelper.initDefaults(); - await imgurHelper.initDefaults(); - await tiktokHelper.initDefaults(); - await sendTargetsHelper.initDefaults(); - await peertubeHelper.initDefaults(); - await lbryHelper.initDefaults(); - location.reload(); - }) - }) - }) - }); - - } -); +const resetSettings = document.getElementById("reset-settings") +resetSettings.addEventListener("click", async () => { + resetSettings.innerHTML = "..." + browser.storage.local.clear(() => { + fetch("/instances/blacklist.json") + .then(response => response.text()) + .then(async data => { + browser.storage.local.set({ cloudflareBlackList: JSON.parse(data).cloudflare }, () => { + browser.storage.local.set({ authenticateBlackList: JSON.parse(data).authenticate }, async () => { + await generalHelper.initDefaults() + await youtubeHelper.initDefaults() + await youtubeMusicHelper.initDefaults() + await twitterHelper.initDefaults() + await instagramHelper.initDefaults() + await mapsHelper.initDefaults() + await searchHelper.initDefaults() + await translateHelper.initDefaults() + await mediumHelper.initDefaults() + await quoraHelper.initDefaults() + await libremdbHelper.initDefaults() + await reutersHelper.initDefaults() + await redditHelper.initDefaults() + await wikipediaHelper.initDefaults() + await imgurHelper.initDefaults() + await tiktokHelper.initDefaults() + await sendTargetsHelper.initDefaults() + await peertubeHelper.initDefaults() + await lbryHelper.initDefaults() + location.reload() + }) + }) + }) + }) +}) let autoRedirectElement = document.getElementById("auto-redirect") autoRedirectElement.addEventListener("change", event => { - browser.storage.local.set({ autoRedirect: event.target.checked }) -}); + browser.storage.local.set({ autoRedirect: event.target.checked }) +}) -let themeElement = document.getElementById("theme"); +let themeElement = document.getElementById("theme") themeElement.addEventListener("change", event => { - const value = event.target.options[theme.selectedIndex].value; - browser.storage.local.set({ theme: value }); - location.reload(); + const value = event.target.options[theme.selectedIndex].value + browser.storage.local.set({ theme: value }) + location.reload() }) -let protocolElement = document.getElementById("protocol"); +let protocolElement = document.getElementById("protocol") protocolElement.addEventListener("change", event => { - const value = event.target.options[protocol.selectedIndex].value; - browser.storage.local.set({ protocol: value }); - location.reload(); + const value = event.target.options[protocol.selectedIndex].value + browser.storage.local.set({ protocol: value }) + location.reload() }) let protocolFallbackCheckbox = document.getElementById("protocol-fallback-checkbox") protocolFallbackCheckbox.addEventListener("change", event => { - browser.storage.local.set({ protocolFallback: event.target.checked }); + browser.storage.local.set({ protocolFallback: event.target.checked }) }) -let nameCustomInstanceInput = document.getElementById("exceptions-custom-instance"); -let instanceTypeElement = document.getElementById("exceptions-custom-instance-type"); +let nameCustomInstanceInput = document.getElementById("exceptions-custom-instance") +let instanceTypeElement = document.getElementById("exceptions-custom-instance-type") let instanceType = "url" -let popupFrontends; +let popupFrontends for (const frontend of generalHelper.allPopupFrontends) - document.getElementById(frontend).addEventListener("change", - event => { - if (event.target.checked && !popupFrontends.includes(frontend)) - popupFrontends.push(frontend) - else if (popupFrontends.includes(frontend)) { - var index = popupFrontends.indexOf(frontend); - if (index !== -1) popupFrontends.splice(index, 1); - } - browser.storage.local.set({ popupFrontends }) - } - ) + document.getElementById(frontend).addEventListener("change", event => { + if (event.target.checked && !popupFrontends.includes(frontend)) popupFrontends.push(frontend) + else if (popupFrontends.includes(frontend)) { + var index = popupFrontends.indexOf(frontend) + if (index !== -1) popupFrontends.splice(index, 1) + } + browser.storage.local.set({ popupFrontends }) + }) // const firstPartyIsolate = document.getElementById('firstPartyIsolate'); // firstPartyIsolate.addEventListener("change", () => browser.storage.local.set({ firstPartyIsolate: firstPartyIsolate.checked })) browser.storage.local.get( - [ - 'theme', - 'autoRedirect', - 'exceptions', - 'protocol', - 'protocolFallback' - // 'firstPartyIsolate' - ], - r => { - autoRedirectElement.checked = r.autoRedirect; - themeElement.value = r.theme; - protocolElement.value = r.protocol; - protocolFallbackCheckbox.checked = r.protocolFallback; - // firstPartyIsolate.checked = r.firstPartyIsolate; - - let protocolFallbackElement = document.getElementById('protocol-fallback') - if (protocolElement.value == "normal") { - protocolFallbackElement.style.display = 'none'; - } else { - protocolFallbackElement.style.display = 'block'; - } + [ + "theme", + "autoRedirect", + "exceptions", + "protocol", + "protocolFallback", + // 'firstPartyIsolate' + ], + r => { + autoRedirectElement.checked = r.autoRedirect + themeElement.value = r.theme + protocolElement.value = r.protocol + protocolFallbackCheckbox.checked = r.protocolFallback + // firstPartyIsolate.checked = r.firstPartyIsolate; + let protocolFallbackElement = document.getElementById("protocol-fallback") + if (protocolElement.value == "normal") { + protocolFallbackElement.style.display = "none" + } else { + protocolFallbackElement.style.display = "block" + } - instanceTypeElement.addEventListener("change", - event => { - instanceType = event.target.options[instanceTypeElement.selectedIndex].value - if (instanceType == 'url') { - nameCustomInstanceInput.setAttribute("type", "url"); - nameCustomInstanceInput.setAttribute("placeholder", "https://www.google.com"); - } - else if (instanceType == 'regex') { - nameCustomInstanceInput.setAttribute("type", "text"); - nameCustomInstanceInput.setAttribute("placeholder", "https?:\/\/(www\.|)youtube\.com\/"); - } - } - ) - let exceptionsCustomInstances = r.exceptions; - function calcExceptionsCustomInstances() { - document.getElementById("exceptions-custom-checklist").innerHTML = - [...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex].map( - (x) => `<div> + instanceTypeElement.addEventListener("change", event => { + instanceType = event.target.options[instanceTypeElement.selectedIndex].value + if (instanceType == "url") { + nameCustomInstanceInput.setAttribute("type", "url") + nameCustomInstanceInput.setAttribute("placeholder", "https://www.google.com") + } else if (instanceType == "regex") { + nameCustomInstanceInput.setAttribute("type", "text") + nameCustomInstanceInput.setAttribute("placeholder", "https?://(www.|)youtube.com/") + } + }) + let exceptionsCustomInstances = r.exceptions + function calcExceptionsCustomInstances() { + document.getElementById("exceptions-custom-checklist").innerHTML = [...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex] + .map( + x => `<div> ${x} <button class="add" id="clear-${x}"> <svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" @@ -246,53 +221,49 @@ browser.storage.local.get( </button> </div> <hr>` - ).join('\n'); + ) + .join("\n") - for (const x of [...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex]) { - document.getElementById(`clear-${x}`).addEventListener("click", - () => { - console.log(x); - let index; - index = exceptionsCustomInstances.url.indexOf(x); - if (index > -1) - exceptionsCustomInstances.url.splice(index, 1); - else { - index = exceptionsCustomInstances.regex.indexOf(x); - if (index > -1) - exceptionsCustomInstances.regex.splice(index, 1); - } - browser.storage.local.set({ exceptions: exceptionsCustomInstances }) - calcExceptionsCustomInstances(); - }); - } - } - calcExceptionsCustomInstances(); - document.getElementById("custom-exceptions-instance-form").addEventListener("submit", (event) => { - event.preventDefault(); + for (const x of [...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex]) { + document.getElementById(`clear-${x}`).addEventListener("click", () => { + console.log(x) + let index + index = exceptionsCustomInstances.url.indexOf(x) + if (index > -1) exceptionsCustomInstances.url.splice(index, 1) + else { + index = exceptionsCustomInstances.regex.indexOf(x) + if (index > -1) exceptionsCustomInstances.regex.splice(index, 1) + } + browser.storage.local.set({ exceptions: exceptionsCustomInstances }) + calcExceptionsCustomInstances() + }) + } + } + calcExceptionsCustomInstances() + document.getElementById("custom-exceptions-instance-form").addEventListener("submit", event => { + event.preventDefault() - let val - if (instanceType == 'url') { - if (nameCustomInstanceInput.validity.valid) { - let url = new URL(nameCustomInstanceInput.value); - val = `${url.protocol}//${url.host}` - if (!exceptionsCustomInstances.url.includes(val)) exceptionsCustomInstances.url.push(val) - } - } else if (instanceType == 'regex') { - val = nameCustomInstanceInput.value - if (val.trim() != '' && !exceptionsCustomInstances.regex.includes(val)) exceptionsCustomInstances.regex.push(val) - } - if (val) { - browser.storage.local.set({ exceptions: exceptionsCustomInstances }) - nameCustomInstanceInput.value = ''; - } - calcExceptionsCustomInstances(); - }) + let val + if (instanceType == "url") { + if (nameCustomInstanceInput.validity.valid) { + let url = new URL(nameCustomInstanceInput.value) + val = `${url.protocol}//${url.host}` + if (!exceptionsCustomInstances.url.includes(val)) exceptionsCustomInstances.url.push(val) + } + } else if (instanceType == "regex") { + val = nameCustomInstanceInput.value + if (val.trim() != "" && !exceptionsCustomInstances.regex.includes(val)) exceptionsCustomInstances.regex.push(val) + } + if (val) { + browser.storage.local.set({ exceptions: exceptionsCustomInstances }) + nameCustomInstanceInput.value = "" + } + calcExceptionsCustomInstances() + }) - browser.storage.local.get('popupFrontends', - r => { - popupFrontends = r.popupFrontends; - for (const frontend of generalHelper.allPopupFrontends) - document.getElementById(frontend).checked = popupFrontends.includes(frontend); - } - ) - }) + browser.storage.local.get("popupFrontends", r => { + popupFrontends = r.popupFrontends + for (const frontend of generalHelper.allPopupFrontends) document.getElementById(frontend).checked = popupFrontends.includes(frontend) + }) + } +) diff --git a/src/pages/options/widgets/imdb.js b/src/pages/options/widgets/imdb.js index ad115e93..094c5672 100644 --- a/src/pages/options/widgets/imdb.js +++ b/src/pages/options/widgets/imdb.js @@ -1,12 +1,12 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("libremdb") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("imdb-enable"); -const imdb = document.getElementById('imdb_page'); +const enable = document.getElementById("imdb-enable") +const imdb = document.getElementById("imdb_page") //const frontend = document.getElementById("imdb-frontend"); let protocol @@ -24,38 +24,32 @@ function changeFrontendsSettings() { */ function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "disableImdb", - "protocol" - ], - r => { - enable.checked = !r.disableImdb; - protocol = r.protocol; - changeProtocolSettings(); - } -) +browser.storage.local.get(["disableImdb", "protocol"], r => { + enable.checked = !r.disableImdb + protocol = r.protocol + changeProtocolSettings() +}) imdb.addEventListener("change", () => { - browser.storage.local.set({ disableImdb: !enable.checked }) + browser.storage.local.set({ disableImdb: !enable.checked }) }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++){ - utils.processDefaultCustomInstances('imdb', frontends[i], protocols[x], document) - } - utils.latency('imdb', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("imdb", frontends[i], protocols[x], document) + } + utils.latency("imdb", frontends[i], document, location) } diff --git a/src/pages/options/widgets/imgur.js b/src/pages/options/widgets/imgur.js index 475bf472..236e809d 100644 --- a/src/pages/options/widgets/imgur.js +++ b/src/pages/options/widgets/imgur.js @@ -1,12 +1,12 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("rimgo") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("imgur-enable"); -const imgur = document.getElementById('imgur_page'); +const enable = document.getElementById("imgur-enable") +const imgur = document.getElementById("imgur_page") //const frontend = document.getElementById("imgur-frontend"); let protocol @@ -24,38 +24,32 @@ function changeFrontendsSettings() { */ function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "disableImgur", - "protocol" - ], - r => { - enable.checked = !r.disableImgur; - protocol = r.protocol; - changeProtocolSettings(); - } -); +browser.storage.local.get(["disableImgur", "protocol"], r => { + enable.checked = !r.disableImgur + protocol = r.protocol + changeProtocolSettings() +}) imgur.addEventListener("change", () => { - browser.storage.local.set({ disableImgur: !enable.checked }); + browser.storage.local.set({ disableImgur: !enable.checked }) }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++){ - utils.processDefaultCustomInstances('imgur', frontends[i], protocols[x], document) - } - utils.latency('imgur', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("imgur", frontends[i], protocols[x], document) + } + utils.latency("imgur", frontends[i], document, location) } diff --git a/src/pages/options/widgets/instagram.js b/src/pages/options/widgets/instagram.js index 84456845..e22f720f 100644 --- a/src/pages/options/widgets/instagram.js +++ b/src/pages/options/widgets/instagram.js @@ -1,12 +1,12 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("bibliogram") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("instagram-enable"); -const instagram = document.getElementById('instagram_page') +const enable = document.getElementById("instagram-enable") +const instagram = document.getElementById("instagram_page") //const frontend = document.getElementById("instagram-frontend"); let protocol @@ -24,38 +24,32 @@ function changeFrontendsSettings() { */ function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "disableInstagram", - "protocol" - ], - r => { - enable.checked = !r.disableInstagram; - protocol = r.protocol; - changeProtocolSettings(); - } -) +browser.storage.local.get(["disableInstagram", "protocol"], r => { + enable.checked = !r.disableInstagram + protocol = r.protocol + changeProtocolSettings() +}) instagram.addEventListener("change", () => { - browser.storage.local.set({ disableInstagram: !enable.checked }) + browser.storage.local.set({ disableInstagram: !enable.checked }) }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++){ - utils.processDefaultCustomInstances('instagram', frontends[i], protocols[x], document) - } - utils.latency('instagram', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("instagram", frontends[i], protocols[x], document) + } + utils.latency("instagram", frontends[i], document, location) } diff --git a/src/pages/options/widgets/lbry.js b/src/pages/options/widgets/lbry.js index 645017ff..76e212cb 100644 --- a/src/pages/options/widgets/lbry.js +++ b/src/pages/options/widgets/lbry.js @@ -1,61 +1,57 @@ -import utils from "../../../assets/javascripts/utils.js"; - -// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST +import utils from "../../../assets/javascripts/utils.js" const frontends = new Array("librarian") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("lbry-enable"); -const lbry = document.getElementById('lbry_page'); -//const frontend = document.getElementById("lbry-frontend"); +const enable = document.getElementById("lbry-enable") +const lbry = document.getElementById("lbry_page") +const frontend = document.getElementById("lbry-frontend") let protocol -/* function changeFrontendsSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - if (frontends[i] == frontend.value) { - frontendDiv.style.display = 'block' - } else { - frontendDiv.style.display = 'none' - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = "block" + } else { + frontendDiv.style.display = "none" + } + } } -*/ function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "disableLbryTargets", - "protocol" - ], - r => { - enable.checked = !r.disableLbryTargets; - protocol = r.protocol; - changeProtocolSettings(); - } -) +browser.storage.local.get(["disableLbryTargets", "protocol", "lbryFrontend"], r => { + enable.checked = !r.disableLbryTargets + protocol = r.protocol + frontend.value = r.lbryFrontend + changeFrontendsSettings() + changeProtocolSettings() +}) lbry.addEventListener("change", () => { - browser.storage.local.set({ disableLbryTargets: !enable.checked }); + browser.storage.local.set({ + disableLbryTargets: !enable.checked, + lbryFrontend: frontend.value, + }) + changeFrontendsSettings() }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++){ - utils.processDefaultCustomInstances('lbryTargets', frontends[i], protocols[x], document) - } - utils.latency('lbryTargets', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("lbryTargets", frontends[i], protocols[x], document) + } + utils.latency("lbryTargets", frontends[i], document, location) } diff --git a/src/pages/options/widgets/lbry.pug b/src/pages/options/widgets/lbry.pug index 2bdccb5a..678b87d9 100644 --- a/src/pages/options/widgets/lbry.pug +++ b/src/pages/options/widgets/lbry.pug @@ -1,11 +1,17 @@ section#lbry_page.option-block .some-block.option-block - h1(data-localise="__MSG_lbry__") LBRY/Odysee + h1(data-localise="__MSG_lbry__") LBRY hr .some-block.option-block h4(data-localise="__MSG_enable__") Enable input#lbry-enable(type="checkbox") + .some-block.option-block + h4(data-localise="__MSG_frontend__") Frontend + select#lbry-frontend + option(value="librarian") Librarian + option(value="lbryDesktop" data-localise="__MSG_lbryDesktop__") LBRY Desktop + #librarian hr .normal diff --git a/src/pages/options/widgets/maps.js b/src/pages/options/widgets/maps.js index 9e4be6d3..acc8aca8 100644 --- a/src/pages/options/widgets/maps.js +++ b/src/pages/options/widgets/maps.js @@ -1,64 +1,57 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" const frontends = new Array("facil") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("maps-enable"); -const maps = document.getElementById('maps_page'); -const frontend = document.getElementById("maps-frontend"); +const enable = document.getElementById("maps-enable") +const maps = document.getElementById("maps_page") +const frontend = document.getElementById("maps-frontend") let protocol function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } function changeFrontendsSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - if (frontends[i] == frontend.value) { - frontendDiv.style.display = 'block' - } else { - frontendDiv.style.display = 'none' - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = "block" + } else { + frontendDiv.style.display = "none" + } + } } -browser.storage.local.get( - [ - "disableMaps", - "protocol", - "mapsFrontend" - ], - r => { - enable.checked = !r.disableMaps; - protocol = r.protocol; - frontend.value = r.mapsFrontend; - changeFrontendsSettings(); - changeProtocolSettings(); - } -) +browser.storage.local.get(["disableMaps", "protocol", "mapsFrontend"], r => { + enable.checked = !r.disableMaps + protocol = r.protocol + frontend.value = r.mapsFrontend + changeFrontendsSettings() + changeProtocolSettings() +}) maps.addEventListener("change", () => { - browser.storage.local.set({ - disableMaps: !enable.checked, - mapsFrontend: frontend.value - }); - changeFrontendsSettings(); + browser.storage.local.set({ + disableMaps: !enable.checked, + mapsFrontend: frontend.value, + }) + changeFrontendsSettings() }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++) { - utils.processDefaultCustomInstances('maps', frontends[i], protocols[x], document) - } - utils.latency('maps', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("maps", frontends[i], protocols[x], document) + } + utils.latency("maps", frontends[i], document, location) } diff --git a/src/pages/options/widgets/medium.js b/src/pages/options/widgets/medium.js index 765a956c..8db5c0f0 100644 --- a/src/pages/options/widgets/medium.js +++ b/src/pages/options/widgets/medium.js @@ -1,12 +1,12 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("scribe") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("medium-enable"); -const medium = document.getElementById('medium_page'); +const enable = document.getElementById("medium-enable") +const medium = document.getElementById("medium_page") //const frontend = document.getElementById("medium-frontend"); let protocol @@ -24,38 +24,32 @@ function changeFrontendsSettings() { */ function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "disableMedium", - "protocol" - ], - r => { - enable.checked = !r.disableMedium; - protocol = r.protocol; - changeProtocolSettings(); - } -) +browser.storage.local.get(["disableMedium", "protocol"], r => { + enable.checked = !r.disableMedium + protocol = r.protocol + changeProtocolSettings() +}) medium.addEventListener("change", () => { - browser.storage.local.set({ disableMedium: !enable.checked }) + browser.storage.local.set({ disableMedium: !enable.checked }) }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++){ - utils.processDefaultCustomInstances('medium', frontends[i], protocols[x], document) - } - utils.latency('medium', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("medium", frontends[i], protocols[x], document) + } + utils.latency("medium", frontends[i], document, location) } diff --git a/src/pages/options/widgets/peertube.js b/src/pages/options/widgets/peertube.js index 9e994119..e3b8dcc5 100644 --- a/src/pages/options/widgets/peertube.js +++ b/src/pages/options/widgets/peertube.js @@ -1,12 +1,12 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("simpleertube") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("peertube-enable"); -const peertube = document.getElementById('peertube_page'); +const enable = document.getElementById("peertube-enable") +const peertube = document.getElementById("peertube_page") //const frontend = document.getElementById("peertube-frontend"); let protocol @@ -24,38 +24,32 @@ function changeFrontendsSettings() { */ function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "disablePeertubeTargets", - "protocol" - ], - r => { - enable.checked = !r.disablePeertubeTargets; - protocol = r.protocol; - changeProtocolSettings(); - } -) +browser.storage.local.get(["disablePeertubeTargets", "protocol"], r => { + enable.checked = !r.disablePeertubeTargets + protocol = r.protocol + changeProtocolSettings() +}) peertube.addEventListener("change", () => { - browser.storage.local.set({ disablePeertubeTargets: !enable.checked }) + browser.storage.local.set({ disablePeertubeTargets: !enable.checked }) }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++){ - utils.processDefaultCustomInstances('peertube', frontends[i], protocols[x], document) - } - utils.latency('peertube', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("peertube", frontends[i], protocols[x], document) + } + utils.latency("peertube", frontends[i], document, location) } diff --git a/src/pages/options/widgets/quora.js b/src/pages/options/widgets/quora.js index ded21e57..f3e361c3 100644 --- a/src/pages/options/widgets/quora.js +++ b/src/pages/options/widgets/quora.js @@ -1,12 +1,12 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("quetre") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("quora-enable"); -const quora = document.getElementById('quora_page'); +const enable = document.getElementById("quora-enable") +const quora = document.getElementById("quora_page") //const frontend = document.getElementById("quora-frontend"); let protocol @@ -24,38 +24,32 @@ function changeFrontendsSettings() { */ function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "disableQuora", - "protocol" - ], - r => { - enable.checked = !r.disableQuora; - protocol = r.protocol; - changeProtocolSettings(); - } -) +browser.storage.local.get(["disableQuora", "protocol"], r => { + enable.checked = !r.disableQuora + protocol = r.protocol + changeProtocolSettings() +}) quora.addEventListener("change", () => { - browser.storage.local.set({ disableQuora: !enable.checked }) + browser.storage.local.set({ disableQuora: !enable.checked }) }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++){ - utils.processDefaultCustomInstances('quora', frontends[i], protocols[x], document) - } - utils.latency('quora', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("quora", frontends[i], protocols[x], document) + } + utils.latency("quora", frontends[i], document, location) } diff --git a/src/pages/options/widgets/reddit.js b/src/pages/options/widgets/reddit.js index a32632d2..c2d16fa3 100644 --- a/src/pages/options/widgets/reddit.js +++ b/src/pages/options/widgets/reddit.js @@ -1,64 +1,57 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" const frontends = new Array("libreddit", "teddit") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("reddit-enable"); -const reddit = document.getElementById('reddit_page'); -const frontend = document.getElementById("reddit-frontend"); +const enable = document.getElementById("reddit-enable") +const reddit = document.getElementById("reddit_page") +const frontend = document.getElementById("reddit-frontend") let protocol function changeFrontendsSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - if (frontends[i] == frontend.value) { - frontendDiv.style.display = 'block' - } else { - frontendDiv.style.display = 'none' - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = "block" + } else { + frontendDiv.style.display = "none" + } + } } function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "disableReddit", - "protocol", - "redditFrontend", - ], - r => { - enable.checked = !r.disableReddit - protocol = r.protocol - frontend.value = r.redditFrontend - changeFrontendsSettings(); - changeProtocolSettings(); - } -) +browser.storage.local.get(["disableReddit", "protocol", "redditFrontend"], r => { + enable.checked = !r.disableReddit + protocol = r.protocol + frontend.value = r.redditFrontend + changeFrontendsSettings() + changeProtocolSettings() +}) reddit.addEventListener("change", () => { - browser.storage.local.set({ - disableReddit: !enable.checked, - redditFrontend: frontend.value - }); - changeFrontendsSettings(); + browser.storage.local.set({ + disableReddit: !enable.checked, + redditFrontend: frontend.value, + }) + changeFrontendsSettings() }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++){ - utils.processDefaultCustomInstances('reddit', frontends[i], protocols[x], document) - } - utils.latency('reddit', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("reddit", frontends[i], protocols[x], document) + } + utils.latency("reddit", frontends[i], document, location) } diff --git a/src/pages/options/widgets/reuters.js b/src/pages/options/widgets/reuters.js index 297e3e70..d8c937e4 100644 --- a/src/pages/options/widgets/reuters.js +++ b/src/pages/options/widgets/reuters.js @@ -1,12 +1,12 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("neuters") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("reuters-enable"); -const reuters = document.getElementById('reuters_page'); +const enable = document.getElementById("reuters-enable") +const reuters = document.getElementById("reuters_page") //const frontend = document.getElementById("reuters-frontend"); let protocol @@ -24,38 +24,32 @@ function changeFrontendsSettings() { */ function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "disableReuters", - "protocol" - ], - r => { - enable.checked = !r.disableReuters; - protocol = r.protocol; - changeProtocolSettings(); - } -) +browser.storage.local.get(["disableReuters", "protocol"], r => { + enable.checked = !r.disableReuters + protocol = r.protocol + changeProtocolSettings() +}) reuters.addEventListener("change", () => { - browser.storage.local.set({ disableReuters: !enable.checked }) + browser.storage.local.set({ disableReuters: !enable.checked }) }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++){ - utils.processDefaultCustomInstances('reuters', frontends[i], protocols[x], document) - } - utils.latency('reuters', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("reuters", frontends[i], protocols[x], document) + } + utils.latency("reuters", frontends[i], document, location) } diff --git a/src/pages/options/widgets/search.js b/src/pages/options/widgets/search.js index 7cadf143..3301cd70 100644 --- a/src/pages/options/widgets/search.js +++ b/src/pages/options/widgets/search.js @@ -1,4 +1,4 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" // GOAL: to never mention frontends/protocls outside these two arrays, so that adding a new frontend/protocol is as easy as adding it here. // This may be expanded across the whole project, where almost everything becomes a template, and the frontend/protocol parts just become a JSON file. @@ -15,8 +15,8 @@ for (let i = 0; i < frontends.length; i++) { this.frontends[i] = frontends[i].getElementsByClassName(protocol) } */ - // There was a class here, but I deleted a bit of it - /* +// There was a class here, but I deleted a bit of it +/* this.searxDiv = searxDiv.getElementsByClassName(protocol)[0]; this.searxngDiv = searxngDiv.getElementsByClassName(protocol)[0]; this.librexDiv = librexDiv.getElementsByClassName(protocol)[0]; @@ -35,23 +35,22 @@ const searxngDiv = document.getElementById("searxng"); const whoogleDiv = document.getElementById("whoogle"); */ -const enable = document.getElementById("search-enable"); -const search = document.getElementById('search_page'); -const frontend = document.getElementById("search-frontend"); +const enable = document.getElementById("search-enable") +const search = document.getElementById("search_page") +const frontend = document.getElementById("search-frontend") let protocol function changeFrontendsSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - if (frontends[i] == frontend.value) { - frontendDiv.style.display = 'block' - } else { - frontendDiv.style.display = 'none' - } - } - - - /* + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = "block" + } else { + frontendDiv.style.display = "none" + } + } + + /* if (frontend.value == 'searx') { searxDiv.style.display = 'block'; searxngDiv.style.display = 'none'; @@ -79,32 +78,27 @@ function changeFrontendsSettings() { */ } - - function changeProtocolSettings() { - - - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - //if (frontends[i] == frontend.value) { // Here we are checking if the frontend matches the current one. This skips the protocol checking for that frontend, speeding things up. I no longer do this as protocol setting is only set once in the ui so every frontend needs to get their protocols setup immidiately. - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { //if the frontend value equals the selected one, it will show. Otherwise, it will be hidden - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - /* + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + //if (frontends[i] == frontend.value) { // Here we are checking if the frontend matches the current one. This skips the protocol checking for that frontend, speeding things up. I no longer do this as protocol setting is only set once in the ui so every frontend needs to get their protocols setup immidiately. + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + //if the frontend value equals the selected one, it will show. Otherwise, it will be hidden + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + /* } else { continue } */ - } - + } - -/* + /* * "Legacy" code const normalsearxDiv = searxDiv.getElementsByClassName("normal")[0]; const torsearxDiv = searxDiv.getElementsByClassName("tor")[0]; @@ -168,35 +162,28 @@ function changeProtocolSettings() { */ } -browser.storage.local.get( - [ - "disableSearch", - "searchFrontend", - "protocol", - ], - r => { - enable.checked = !r.disableSearch; - frontend.value = r.searchFrontend; - protocol = r.protocol; - - changeFrontendsSettings(); - changeProtocolSettings(); - } -); +browser.storage.local.get(["disableSearch", "searchFrontend", "protocol"], r => { + enable.checked = !r.disableSearch + frontend.value = r.searchFrontend + protocol = r.protocol + + changeFrontendsSettings() + changeProtocolSettings() +}) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++){ - utils.processDefaultCustomInstances('search', frontends[i], protocols[x], document) - } - utils.latency('search', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("search", frontends[i], protocols[x], document) + } + utils.latency("search", frontends[i], document, location) } search.addEventListener("change", () => { - browser.storage.local.set({ - disableSearch: !enable.checked, - searchFrontend: frontend.value, - }); - changeFrontendsSettings(); + browser.storage.local.set({ + disableSearch: !enable.checked, + searchFrontend: frontend.value, + }) + changeFrontendsSettings() }) /* diff --git a/src/pages/options/widgets/sendTargets.js b/src/pages/options/widgets/sendTargets.js index 27c90d4e..9380a72f 100644 --- a/src/pages/options/widgets/sendTargets.js +++ b/src/pages/options/widgets/sendTargets.js @@ -1,12 +1,12 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("send") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("sendTargets-enable"); -const sendTargets = document.getElementById('sendTargets_page'); +const enable = document.getElementById("sendTargets-enable") +const sendTargets = document.getElementById("sendTargets_page") //const frontend = document.getElementById("sendTargets-frontend"); let protocol @@ -24,38 +24,32 @@ function changeFrontendsSettings() { */ function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "disableSendTarget", - "protocol" - ], - r => { - enable.checked = !r.disableSendTarget; - protocol = r.protocol; - changeProtocolSettings(); - } -) +browser.storage.local.get(["disableSendTarget", "protocol"], r => { + enable.checked = !r.disableSendTarget + protocol = r.protocol + changeProtocolSettings() +}) sendTargets.addEventListener("change", () => { - browser.storage.local.set({ disableSendTarget: !enable.checked }) + browser.storage.local.set({ disableSendTarget: !enable.checked }) }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++){ - utils.processDefaultCustomInstances('sendTargets', frontends[i], protocols[x], document) - } - utils.latency('sendTargets', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("sendTargets", frontends[i], protocols[x], document) + } + utils.latency("sendTargets", frontends[i], document, location) } diff --git a/src/pages/options/widgets/tiktok.js b/src/pages/options/widgets/tiktok.js index 37c36366..38ec9ea0 100644 --- a/src/pages/options/widgets/tiktok.js +++ b/src/pages/options/widgets/tiktok.js @@ -1,12 +1,12 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("proxiTok") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("tiktok-enable"); -const tiktok = document.getElementById('tiktok_page'); +const enable = document.getElementById("tiktok-enable") +const tiktok = document.getElementById("tiktok_page") //const frontend = document.getElementById("tiktok-frontend"); let protocol @@ -24,38 +24,32 @@ function changeFrontendsSettings() { */ function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "disableTiktok", - "protocol" - ], - r => { - enable.checked = !r.disableTiktok; - protocol = r.protocol; - changeProtocolSettings(); - } -) +browser.storage.local.get(["disableTiktok", "protocol"], r => { + enable.checked = !r.disableTiktok + protocol = r.protocol + changeProtocolSettings() +}) tiktok.addEventListener("change", () => { - browser.storage.local.set({ disableTiktok: !enable.checked }); + browser.storage.local.set({ disableTiktok: !enable.checked }) }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++){ - utils.processDefaultCustomInstances('tiktok', frontends[i], protocols[x], document) - } - utils.latency('tiktok', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("tiktok", frontends[i], protocols[x], document) + } + utils.latency("tiktok", frontends[i], document, location) } diff --git a/src/pages/options/widgets/translate.js b/src/pages/options/widgets/translate.js index 87b8bb8d..e1008139 100644 --- a/src/pages/options/widgets/translate.js +++ b/src/pages/options/widgets/translate.js @@ -1,64 +1,57 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" const frontends = new Array("simplyTranslate", "lingva") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("translate-enable"); -const translate = document.getElementById('translate_page'); -const frontend = document.getElementById("translate-frontend"); +const enable = document.getElementById("translate-enable") +const translate = document.getElementById("translate_page") +const frontend = document.getElementById("translate-frontend") let protocol function changeFrontendsSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - if (frontends[i] == frontend.value) { - frontendDiv.style.display = 'block' - } else { - frontendDiv.style.display = 'none' - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = "block" + } else { + frontendDiv.style.display = "none" + } + } } function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "translateDisable", - "translateFrontend", - "protocol" - ], - r => { - enable.checked = !r.translateDisable; - frontend.value = r.translateFrontend; - protocol = r.protocol; - changeFrontendsSettings(); - changeProtocolSettings(); - } -); +browser.storage.local.get(["translateDisable", "translateFrontend", "protocol"], r => { + enable.checked = !r.translateDisable + frontend.value = r.translateFrontend + protocol = r.protocol + changeFrontendsSettings() + changeProtocolSettings() +}) translate.addEventListener("change", () => { - browser.storage.local.set({ - translateDisable: !enable.checked, - translateFrontend: frontend.value, - }) - changeFrontendsSettings(); + browser.storage.local.set({ + translateDisable: !enable.checked, + translateFrontend: frontend.value, + }) + changeFrontendsSettings() }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++){ - utils.processDefaultCustomInstances('translate', frontends[i], protocols[x], document) - } - utils.latency('translate', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("translate", frontends[i], protocols[x], document) + } + utils.latency("translate", frontends[i], document, location) } diff --git a/src/pages/options/widgets/twitter.js b/src/pages/options/widgets/twitter.js index d54fc928..5ad760b3 100644 --- a/src/pages/options/widgets/twitter.js +++ b/src/pages/options/widgets/twitter.js @@ -1,13 +1,13 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("nitter") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("twitter-enable"); -const twitter = document.getElementById('twitter_page'); -const redirectType = document.getElementById("twitter-redirect_type"); +const enable = document.getElementById("twitter-enable") +const twitter = document.getElementById("twitter_page") +const redirectType = document.getElementById("twitter-redirect_type") //const frontend = document.getElementById("twitter-frontend"); let protocol @@ -25,43 +25,36 @@ function changeFrontendsSettings() { */ function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "disableTwitter", - "protocol", - "twitterRedirectType" - ], - r => { - enable.checked = !r.disableTwitter; - protocol = r.protocol; - redirectType.value = r.twitterRedirectType; - changeProtocolSettings(); - } -) +browser.storage.local.get(["disableTwitter", "protocol", "twitterRedirectType"], r => { + enable.checked = !r.disableTwitter + protocol = r.protocol + redirectType.value = r.twitterRedirectType + changeProtocolSettings() +}) twitter.addEventListener("change", () => { - browser.storage.local.set({ - disableTwitter: !enable.checked, - twitterRedirectType: redirectType.value, - }); + browser.storage.local.set({ + disableTwitter: !enable.checked, + twitterRedirectType: redirectType.value, + }) }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++){ - utils.processDefaultCustomInstances('twitter', frontends[i], protocols[x], document) - } - utils.latency('twitter', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("twitter", frontends[i], protocols[x], document) + } + utils.latency("twitter", frontends[i], document, location) } diff --git a/src/pages/options/widgets/wikipedia.js b/src/pages/options/widgets/wikipedia.js index 09b21d02..9d06488b 100644 --- a/src/pages/options/widgets/wikipedia.js +++ b/src/pages/options/widgets/wikipedia.js @@ -1,12 +1,12 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("wikiless") const protocols = new Array("normal", "tor", "i2p", "loki") -const enable = document.getElementById("wikipedia-enable"); -const wikipedia = document.getElementById('wikipedia_page'); +const enable = document.getElementById("wikipedia-enable") +const wikipedia = document.getElementById("wikipedia_page") //const frontend = document.getElementById("wikipedia-frontend"); let protocol @@ -24,38 +24,32 @@ function changeFrontendsSettings() { */ function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "disableWikipedia", - "protocol" - ], - r => { - enable.checked = !r.disableWikipedia; - protocol = r.protocol; - changeProtocolSettings(); - } -) +browser.storage.local.get(["disableWikipedia", "protocol"], r => { + enable.checked = !r.disableWikipedia + protocol = r.protocol + changeProtocolSettings() +}) wikipedia.addEventListener("change", () => { - browser.storage.local.set({ disableWikipedia: !enable.checked }) + browser.storage.local.set({ disableWikipedia: !enable.checked }) }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++) { - utils.processDefaultCustomInstances('wikipedia', frontends[i], protocols[x], document) - } - utils.latency('wikipedia', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("wikipedia", frontends[i], protocols[x], document) + } + utils.latency("wikipedia", frontends[i], document, location) } diff --git a/src/pages/options/widgets/youtube.js b/src/pages/options/widgets/youtube.js index 76b673bd..065a195b 100644 --- a/src/pages/options/widgets/youtube.js +++ b/src/pages/options/widgets/youtube.js @@ -1,101 +1,92 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" -const frontends = new Array("invidious", "piped", "pipedMaterial") +const frontends = new Array("invidious", "piped", "pipedMaterial", "cloudtube") const protocols = new Array("normal", "tor", "i2p", "loki") const singleInstanceFrontends = new Array("freetube", "yatte") -const enable = document.getElementById("youtube-enable"); -const youtube = document.getElementById('youtube_page'); -const youtubeEmbedFrontend = document.getElementById("youtube-embed_frontend"); -const onlyEmbeddedVideo = document.getElementById("youtube-redirect_type"); -const embeddedFrontendDiv = document.getElementById("youtube-embedded_frontend"); -const frontend = document.getElementById("youtube-frontend"); +const enable = document.getElementById("youtube-enable") +const youtube = document.getElementById("youtube_page") +const youtubeEmbedFrontend = document.getElementById("youtube-embed_frontend") +const onlyEmbeddedVideo = document.getElementById("youtube-redirect_type") +const embeddedFrontendDiv = document.getElementById("youtube-embedded_frontend") +const frontend = document.getElementById("youtube-frontend") let protocol function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } function changeEmbedFrontendsSettings() { - if (embeddedFrontendDiv.style.display == 'block') { - for (let i = 0; i < frontends.length; i++) { - const embeddedFrontendDiv = document.getElementById(frontends[i]) - if (frontends[i] == youtubeEmbedFrontend.value) { - embeddedFrontendDiv.style.display = 'block' - } else { - embeddedFrontendDiv.style.display = 'none' - } - } - } + if (embeddedFrontendDiv.style.display == "block") { + for (let i = 0; i < frontends.length; i++) { + const embeddedFrontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == youtubeEmbedFrontend.value) { + embeddedFrontendDiv.style.display = "block" + } else { + embeddedFrontendDiv.style.display = "none" + } + } + } } function changeFrontendsSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - if (frontends[i] == frontend.value) { - frontendDiv.style.display = 'block' - } else { - frontendDiv.style.display = 'none' - } - } - let singleInstanceFrontend = false - for (let i = 0; i < singleInstanceFrontends.length; i++) { - if (singleInstanceFrontends[i] == frontend.value) { - singleInstanceFrontend = true - } - } - if (singleInstanceFrontend == true) { - embeddedFrontendDiv.style.display = 'block' - } else { - embeddedFrontendDiv.style.display = 'none' - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = "block" + } else { + frontendDiv.style.display = "none" + } + } + let singleInstanceFrontend = false + for (let i = 0; i < singleInstanceFrontends.length; i++) { + if (singleInstanceFrontends[i] == frontend.value) { + singleInstanceFrontend = true + } + } + if (singleInstanceFrontend == true) { + embeddedFrontendDiv.style.display = "block" + } else { + embeddedFrontendDiv.style.display = "none" + } } -browser.storage.local.get( - [ - "disableYoutube", - "onlyEmbeddedVideo", - "youtubeRedirects", - "youtubeFrontend", +browser.storage.local.get(["disableYoutube", "onlyEmbeddedVideo", "youtubeRedirects", "youtubeFrontend", "youtubeEmbedFrontend", "protocol"], r => { + enable.checked = !r.disableYoutube + onlyEmbeddedVideo.value = r.onlyEmbeddedVideo + youtubeEmbedFrontend.value = r.youtubeEmbedFrontend + frontend.value = r.youtubeFrontend + protocol = r.protocol - "youtubeEmbedFrontend", - "protocol" - ], - r => { - enable.checked = !r.disableYoutube; - onlyEmbeddedVideo.value = r.onlyEmbeddedVideo; - frontend.value = r.youtubeFrontend; - protocol = r.protocol; - - changeFrontendsSettings(); - changeProtocolSettings(); - changeEmbedFrontendsSettings(); - } -); + changeFrontendsSettings() + changeProtocolSettings() + changeEmbedFrontendsSettings() +}) youtube.addEventListener("change", () => { - browser.storage.local.set({ - disableYoutube: !enable.checked, - youtubeEmbedFrontend: youtubeEmbedFrontend.value, - onlyEmbeddedVideo: onlyEmbeddedVideo.value - }) - changeFrontendsSettings(); - changeEmbedFrontendsSettings(); + browser.storage.local.set({ + disableYoutube: !enable.checked, + youtubeEmbedFrontend: youtubeEmbedFrontend.value, + youtubeFrontend: frontend.value, + onlyEmbeddedVideo: onlyEmbeddedVideo.value, + }) + changeFrontendsSettings() + changeEmbedFrontendsSettings() }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++) { - utils.processDefaultCustomInstances('youtube', frontends[i], protocols[x], document) - } - utils.latency('youtube', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("youtube", frontends[i], protocols[x], document) + } + utils.latency("youtube", frontends[i], document, location) } diff --git a/src/pages/options/widgets/youtube.pug b/src/pages/options/widgets/youtube.pug index a7832d4c..33a43c34 100644 --- a/src/pages/options/widgets/youtube.pug +++ b/src/pages/options/widgets/youtube.pug @@ -12,6 +12,7 @@ section#youtube_page.option-block option(value="invidious") Invidious option(value="piped") Piped option(value="pipedMaterial") Piped-Material + option(value="cloudtube") CloudTube option(value="freetube") FreeTube option(value="yatte") Yattee @@ -22,6 +23,7 @@ section#youtube_page.option-block option(value="invidious") Invidious option(value="piped") Piped option(value="pipedMaterial") Piped-Material + option(value="cloudtube") CloudTube .some-block.option-block h4(data-localise="__MSG_redirectType__") Redirect Type @@ -81,4 +83,21 @@ section#youtube_page.option-block include ../../widgets/instances.pug +instances('http://piped-material.loki') + #cloudtube + hr + .normal + include ../../widgets/instances.pug + +instances('https://cloudtube.com') + include ../../widgets/latency.pug + +latency('cloudtube') + .tor + +instances('http://cloudtube.onion') + include ../../widgets/instances.pug + .i2p + include ../../widgets/instances.pug + +instances('http://cloudtube.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://cloudtube.loki') + script(type="module" src="./widgets/youtube.js") diff --git a/src/pages/options/widgets/youtubeMusic.js b/src/pages/options/widgets/youtubeMusic.js index 4d33c1fa..ad51ce7c 100644 --- a/src/pages/options/widgets/youtubeMusic.js +++ b/src/pages/options/widgets/youtubeMusic.js @@ -1,61 +1,57 @@ -import utils from "../../../assets/javascripts/utils.js"; +import utils from "../../../assets/javascripts/utils.js" -// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST - -const frontends = new Array("beatbump") +const frontends = new Array("beatbump", "hyperpipe") const protocols = new Array("normal", "tor", "i2p", "loki") -let enable = document.getElementById("youtubeMusic-enable"); -const youtubeMusic = document.getElementById('youtubeMusic_page'); -//const frontend = document.getElementById("youtubeMusic-frontend"); +let enable = document.getElementById("youtubeMusic-enable") +const youtubeMusic = document.getElementById("youtubeMusic_page") +const frontend = document.getElementById("youtubeMusic-frontend") let protocol -/* function changeFrontendsSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - if (frontends[i] == frontend.value) { - frontendDiv.style.display = 'block' - } else { - frontendDiv.style.display = 'none' - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + if (frontends[i] == frontend.value) { + frontendDiv.style.display = "block" + } else { + frontendDiv.style.display = "none" + } + } } -*/ function changeProtocolSettings() { - for (let i = 0; i < frontends.length; i++) { - const frontendDiv = document.getElementById(frontends[i]) - for (let x = 0; x < protocols.length; x++) { - const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] - if (protocols[x] == protocol) { - protocolDiv.style.display = 'block' - } else { - protocolDiv.style.display = 'none' - } - } - } + for (let i = 0; i < frontends.length; i++) { + const frontendDiv = document.getElementById(frontends[i]) + for (let x = 0; x < protocols.length; x++) { + const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0] + if (protocols[x] == protocol) { + protocolDiv.style.display = "block" + } else { + protocolDiv.style.display = "none" + } + } + } } -browser.storage.local.get( - [ - "disableYoutubeMusic", - "protocol" - ], - r => { - enable.checked = !r.disableYoutubeMusic - protocol = r.protocol - changeProtocolSettings() - } -); +browser.storage.local.get(["disableYoutubeMusic", "youtubeMusicFrontend", "protocol"], r => { + enable.checked = !r.disableYoutubeMusic + frontend.value = r.youtubeMusicFrontend + protocol = r.protocol + changeFrontendsSettings() + changeProtocolSettings() +}) youtubeMusic.addEventListener("change", () => { - browser.storage.local.set({ disableYoutubeMusic: !enable.checked }) + browser.storage.local.set({ + disableYoutubeMusic: !enable.checked, + youtubeMusicFrontend: frontend.value, + }) + changeFrontendsSettings() }) for (let i = 0; i < frontends.length; i++) { - for (let x = 0; x < protocols.length; x++) { - utils.processDefaultCustomInstances('youtubeMusic', frontends[i], protocols[x], document) - } - utils.latency('youtubeMusic', frontends[i], document, location) + for (let x = 0; x < protocols.length; x++) { + utils.processDefaultCustomInstances("youtubeMusic", frontends[i], protocols[x], document) + } + utils.latency("youtubeMusic", frontends[i], document, location) } diff --git a/src/pages/options/widgets/youtubeMusic.pug b/src/pages/options/widgets/youtubeMusic.pug index f307ae9a..bcba3d2d 100644 --- a/src/pages/options/widgets/youtubeMusic.pug +++ b/src/pages/options/widgets/youtubeMusic.pug @@ -6,11 +6,17 @@ section#youtubeMusic_page.option-block h4(data-localise="__MSG_enable__") Enable input#youtubeMusic-enable(type="checkbox") + .some-block.option-block + h4(data-localise="__MSG_frontend__") Frontend + select#youtubeMusic-frontend + option(value="beatbump") Beatbump + option(value="hyperpipe") Hyperpipe + #beatbump hr .normal include ../../widgets/instances.pug - +instances('https://beatbump.wewe') + +instances('https://beatbump.org') include ../../widgets/latency.pug +latency('beatbump') .tor @@ -23,4 +29,21 @@ section#youtubeMusic_page.option-block include ../../widgets/instances.pug +instances('http://beatbump.loki') + #hyperpipe + hr + .normal + include ../../widgets/instances.pug + +instances('https://hyperpipe.org') + include ../../widgets/latency.pug + +latency('hyperpipe') + .tor + +instances('http://hyperpipe.onion') + include ../../widgets/instances.pug + .i2p + include ../../widgets/instances.pug + +instances('http://hyperpipe.i2p') + .loki + include ../../widgets/instances.pug + +instances('http://hyperpipe.loki') + script(type="module" src="./widgets/youtubeMusic.js") diff --git a/src/pages/popup/popup.html b/src/pages/popup/popup.html index 4030f0ec..7493ecbe 100644 --- a/src/pages/popup/popup.html +++ b/src/pages/popup/popup.html @@ -97,7 +97,9 @@ <h4 data-localise="__MSG_sendFiles__">Send Files</h4></a> <input class="disable-sendTargets" type="checkbox"/> </div> - <hr> + <div id="current_site_divider"> + <hr> + </div> </div> <div class="all_sites"> <div class="youtube some-block"><a class="title" href="https://youtube.com"><img src="../../assets/images/youtube-icon.png"/> diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js index 5e7b2336..465080c5 100644 --- a/src/pages/popup/popup.js +++ b/src/pages/popup/popup.js @@ -1,330 +1,445 @@ -"use strict"; -window.browser = window.browser || window.chrome; - -import utils from "../../assets/javascripts/utils.js"; -import generalHelper from "../../assets/javascripts/general.js"; - -import youtubeHelper from "../../assets/javascripts/youtube/youtube.js"; -import youtubeMusicHelper from "../../assets/javascripts/youtubeMusic.js"; -import twitterHelper from "../../assets/javascripts/twitter.js"; -import instagramHelper from "../../assets/javascripts/instagram.js"; -import redditHelper from "../../assets/javascripts/reddit.js"; -import searchHelper from "../../assets/javascripts/search.js"; -import translateHelper from "../../assets/javascripts/translate/translate.js"; -import mapsHelper from "../../assets/javascripts/maps.js"; -import wikipediaHelper from "../../assets/javascripts/wikipedia.js"; -import mediumHelper from "../../assets/javascripts/medium.js"; -import quoraHelper from "../../assets/javascripts/quora.js"; -import libremdbHelper from "../../assets/javascripts/imdb.js"; -import reutersHelper from "../../assets/javascripts/reuters.js"; -import imgurHelper from "../../assets/javascripts/imgur.js"; -import tiktokHelper from "../../assets/javascripts/tiktok.js"; -import sendTargetsHelper from "../../assets/javascripts/sendTargets.js"; -import peertubeHelper from "../../assets/javascripts/peertube.js"; -import lbryHelper from "../../assets/javascripts/lbry.js"; - +"use strict" +window.browser = window.browser || window.chrome + +import utils from "../../assets/javascripts/utils.js" +import generalHelper from "../../assets/javascripts/general.js" + +import youtubeHelper from "../../assets/javascripts/youtube/youtube.js" +import youtubeMusicHelper from "../../assets/javascripts/youtubeMusic.js" +import twitterHelper from "../../assets/javascripts/twitter.js" +import instagramHelper from "../../assets/javascripts/instagram.js" +import redditHelper from "../../assets/javascripts/reddit.js" +import searchHelper from "../../assets/javascripts/search.js" +import translateHelper from "../../assets/javascripts/translate/translate.js" +import mapsHelper from "../../assets/javascripts/maps.js" +import wikipediaHelper from "../../assets/javascripts/wikipedia.js" +import mediumHelper from "../../assets/javascripts/medium.js" +import quoraHelper from "../../assets/javascripts/quora.js" +import libremdbHelper from "../../assets/javascripts/imdb.js" +import reutersHelper from "../../assets/javascripts/reuters.js" +import imgurHelper from "../../assets/javascripts/imgur.js" +import tiktokHelper from "../../assets/javascripts/tiktok.js" +import sendTargetsHelper from "../../assets/javascripts/sendTargets.js" +import peertubeHelper from "../../assets/javascripts/peertube.js" +import lbryHelper from "../../assets/javascripts/lbry.js" utils.unify(true).then(r => { - if (!r) document.getElementById('unify_div').style.display = 'none'; - else { - const unify = document.getElementById('unify'); - const textElement = document.getElementById('unify').getElementsByTagName('h4')[0] - unify.addEventListener("click", () => { - const oldHtml = textElement.innerHTML; - textElement.innerHTML = '...'; - browser.runtime.sendMessage({ function: 'unify' }, - response => { if (response && response.response) textElement.innerHTML = oldHtml }) - } - ); - } + if (!r) document.getElementById("unify_div").style.display = "none" + else { + const unify = document.getElementById("unify") + const textElement = document.getElementById("unify").getElementsByTagName("h4")[0] + unify.addEventListener("click", () => { + const oldHtml = textElement.innerHTML + textElement.innerHTML = "..." + browser.runtime.sendMessage({ function: "unify" }, response => { + if (response && response.response) textElement.innerHTML = oldHtml + }) + }) + } }) utils.switchInstance(true).then(r => { - if (!r) document.getElementById("change_instance_div").style.display = 'none'; - else document.getElementById("change_instance").addEventListener("click", () => utils.switchInstance(false)); -}); + if (!r) document.getElementById("change_instance_div").style.display = "none" + else document.getElementById("change_instance").addEventListener("click", () => utils.switchInstance(false)) +}) utils.copyRaw(true).then(r => { - if (!r) document.getElementById('copy_raw_div').style.display = 'none'; - else { - const copy_raw = document.getElementById('copy_raw'); - copy_raw.addEventListener("click", () => utils.copyRaw(false, copy_raw)); - } + if (!r) document.getElementById("copy_raw_div").style.display = "none" + else { + const copy_raw = document.getElementById("copy_raw") + copy_raw.addEventListener("click", () => utils.copyRaw(false, copy_raw)) + } }) -document.getElementById("more-options").addEventListener("click", () => browser.runtime.openOptionsPage()); +document.getElementById("more-options").addEventListener("click", () => browser.runtime.openOptionsPage()) + +const allSites = document.getElementsByClassName("all_sites")[0] +const currSite = document.getElementsByClassName("current_site")[0] -const allSites = document.getElementsByClassName('all_sites')[0]; -const currSite = document.getElementsByClassName('current_site')[0]; +const disableTwitterCurrentSite = currSite.getElementsByClassName("disable-nitter")[0] +const disableTwitterAllSites = allSites.getElementsByClassName("disable-nitter")[0] -const disableTwitterCurrentSite = currSite.getElementsByClassName("disable-nitter")[0]; -const disableTwitterAllSites = allSites.getElementsByClassName("disable-nitter")[0]; +const disableYoutubeCurrentSite = currSite.getElementsByClassName("disable-youtube")[0] +const disableYoutubeAllSites = allSites.getElementsByClassName("disable-youtube")[0] -const disableYoutubeCurrentSite = currSite.getElementsByClassName("disable-youtube")[0]; -const disableYoutubeAllSites = allSites.getElementsByClassName("disable-youtube")[0]; +const disableYoutubeMusicCurrentSite = currSite.getElementsByClassName("disable-youtubeMusic")[0] +const disableYoutubeMusicAllSites = allSites.getElementsByClassName("disable-youtubeMusic")[0] -const disableYoutubeMusicCurrentSite = currSite.getElementsByClassName("disable-youtubeMusic")[0]; -const disableYoutubeMusicAllSites = allSites.getElementsByClassName("disable-youtubeMusic")[0]; +const disableInstagramCurrentSite = currSite.getElementsByClassName("disable-bibliogram")[0] +const disableInstagramAllSites = allSites.getElementsByClassName("disable-bibliogram")[0] -const disableInstagramCurrentSite = currSite.getElementsByClassName("disable-bibliogram")[0]; -const disableInstagramAllSites = allSites.getElementsByClassName("disable-bibliogram")[0]; +const disableMapsCurrentSite = currSite.getElementsByClassName("disable-osm")[0] +const disableMapsAllSites = allSites.getElementsByClassName("disable-osm")[0] -const disableMapsCurrentSite = currSite.getElementsByClassName("disable-osm")[0]; -const disableMapsAllSites = allSites.getElementsByClassName("disable-osm")[0]; +const disableRedditCurrentSite = currSite.getElementsByClassName("disable-reddit")[0] +const disableRedditAllSites = allSites.getElementsByClassName("disable-reddit")[0] -const disableRedditCurrentSite = currSite.getElementsByClassName("disable-reddit")[0]; -const disableRedditAllSites = allSites.getElementsByClassName("disable-reddit")[0]; +const disableSearchCurrentSite = currSite.getElementsByClassName("disable-search")[0] +const disableSearchAllSites = allSites.getElementsByClassName("disable-search")[0] -const disableSearchCurrentSite = currSite.getElementsByClassName("disable-search")[0]; -const disableSearchAllSites = allSites.getElementsByClassName("disable-search")[0]; +const disableTranslateCurrentSite = currSite.getElementsByClassName("disable-translate")[0] +const disableTranslateAllSites = allSites.getElementsByClassName("disable-translate")[0] -const disableTranslateCurrentSite = currSite.getElementsByClassName("disable-translate")[0]; -const disableTranslateAllSites = allSites.getElementsByClassName("disable-translate")[0]; +const disableWikipediaCurrentSite = currSite.getElementsByClassName("disable-wikipedia")[0] +const disableWikipediaAllSites = allSites.getElementsByClassName("disable-wikipedia")[0] -const disableWikipediaCurrentSite = currSite.getElementsByClassName("disable-wikipedia")[0]; -const disableWikipediaAllSites = allSites.getElementsByClassName("disable-wikipedia")[0]; +const disableMediumCurrentSite = currSite.getElementsByClassName("disable-medium")[0] +const disableMediumAllSites = allSites.getElementsByClassName("disable-medium")[0] -const disableMediumCurrentSite = currSite.getElementsByClassName("disable-medium")[0]; -const disableMediumAllSites = allSites.getElementsByClassName("disable-medium")[0]; +const disableQuoraCurrentSite = currSite.getElementsByClassName("disable-quora")[0] +const disableQuoraAllSites = allSites.getElementsByClassName("disable-quora")[0] -const disableQuoraCurrentSite = currSite.getElementsByClassName("disable-quora")[0]; -const disableQuoraAllSites = allSites.getElementsByClassName("disable-quora")[0]; +const disableImdbCurrentSite = currSite.getElementsByClassName("disable-imdb")[0] +const disableImdbAllSites = allSites.getElementsByClassName("disable-imdb")[0] -const disableImdbCurrentSite = currSite.getElementsByClassName("disable-imdb")[0]; -const disableImdbAllSites = allSites.getElementsByClassName("disable-imdb")[0]; +const disableReutersCurrentSite = currSite.getElementsByClassName("disable-reuters")[0] +const disableReutersAllSites = allSites.getElementsByClassName("disable-reuters")[0] -const disableReutersCurrentSite = currSite.getElementsByClassName("disable-reuters")[0]; -const disableReutersAllSites = allSites.getElementsByClassName("disable-reuters")[0]; +const disablePeertubeTargetsCurrentSite = currSite.getElementsByClassName("disable-peertube")[0] +const disablePeertubeTargetsAllSites = allSites.getElementsByClassName("disable-peertube")[0] -const disablePeertubeTargetsCurrentSite = currSite.getElementsByClassName("disable-peertube")[0]; -const disablePeertubeTargetsAllSites = allSites.getElementsByClassName("disable-peertube")[0]; +const disableLbryTargetsCurrentSite = currSite.getElementsByClassName("disable-lbry")[0] +const disableLbryTargetsAllSites = allSites.getElementsByClassName("disable-lbry")[0] -const disableLbryTargetsCurrentSite = currSite.getElementsByClassName("disable-lbry")[0]; -const disableLbryTargetsAllSites = allSites.getElementsByClassName("disable-lbry")[0]; +const disableSendTargetsCurrentSite = currSite.getElementsByClassName("disable-sendTargets")[0] +const disableSendTargetsAllSites = allSites.getElementsByClassName("disable-sendTargets")[0] -const disableSendTargetsCurrentSite = currSite.getElementsByClassName("disable-sendTargets")[0]; -const disableSendTargetsAllSites = allSites.getElementsByClassName("disable-sendTargets")[0]; +const disableImgurCurrentSite = currSite.getElementsByClassName("disable-imgur")[0] +const disableImgurAllSites = allSites.getElementsByClassName("disable-imgur")[0] -const disableImgurCurrentSite = currSite.getElementsByClassName("disable-imgur")[0]; -const disableImgurAllSites = allSites.getElementsByClassName("disable-imgur")[0]; +const disableTiktokCurrentSite = currSite.getElementsByClassName("disable-tiktok")[0] +const disableTiktokAllSites = allSites.getElementsByClassName("disable-tiktok")[0] -const disableTiktokCurrentSite = currSite.getElementsByClassName("disable-tiktok")[0]; -const disableTiktokAllSites = allSites.getElementsByClassName("disable-tiktok")[0]; +const currentSiteIsFrontend = document.getElementById("current_site_divider") browser.storage.local.get( - [ - "disableTwitter", - "disableYoutube", - "disableYoutubeMusic", - "disableInstagram", - "disableMaps", - "disableReddit", - "disableSearch", - "translateDisable", - "disableWikipedia", - "disableImgur", - "disableTiktok", - "disableMedium", - "disableQuora", - "disableImdb", - "disableReuters", - "disablePeertubeTargets", - "disableLbryTargets", - "disableSendTarget", - "popupFrontends", - ], - r => { - disableTwitterCurrentSite.checked = !r.disableTwitter; disableTwitterAllSites.checked = !r.disableTwitter; - disableYoutubeCurrentSite.checked = !r.disableYoutube; disableYoutubeAllSites.checked = !r.disableYoutube; - disableYoutubeMusicCurrentSite.checked = !r.disableYoutubeMusic; disableYoutubeMusicAllSites.checked = !r.disableYoutubeMusic; - disableInstagramCurrentSite.checked = !r.disableInstagram; disableInstagramAllSites.checked = !r.disableInstagram; - disableMapsCurrentSite.checked = !r.disableMaps; disableMapsAllSites.checked = !r.disableMaps; - disableRedditCurrentSite.checked = !r.disableReddit; disableRedditAllSites.checked = !r.disableReddit; - disableSearchCurrentSite.checked = !r.disableSearch; disableSearchAllSites.checked = !r.disableSearch; - disableTranslateCurrentSite.checked = !r.translateDisable; disableTranslateAllSites.checked = !r.translateDisable; - disableWikipediaCurrentSite.checked = !r.disableWikipedia; disableWikipediaAllSites.checked = !r.disableWikipedia; - disableImgurCurrentSite.checked = !r.disableImgur; disableImgurAllSites.checked = !r.disableImgur; - disableTiktokCurrentSite.checked = !r.disableTiktok; disableTiktokAllSites.checked = !r.disableTiktok; - disableMediumCurrentSite.checked = !r.disableMedium; disableMediumAllSites.checked = !r.disableMedium; - disableQuoraCurrentSite.checked = !r.disableQuora; disableQuoraAllSites.checked = !r.disableQuora; - disableImdbCurrentSite.checked = !r.disableImdb; disableImdbAllSites.checked = !r.disableImdb; - disableReutersCurrentSite.checked = !r.disableReuters; disableReutersAllSites.checked = !r.disableReuters; - disablePeertubeTargetsCurrentSite.checked = !r.disablePeertubeTargets; disablePeertubeTargetsAllSites.checked = !r.disablePeertubeTargets; - disableLbryTargetsCurrentSite.checked = !r.disableLbryTargets; disableLbryTargetsAllSites.checked = !r.disableLbryTargets; - disableSendTargetsCurrentSite.checked = !r.disableSendTarget; disableSendTargetsAllSites.checked = !r.disableSendTarget; - - browser.tabs.query({ active: true, currentWindow: true }, async tabs => { - for (const frontend of generalHelper.allPopupFrontends) { - if (!r.popupFrontends.includes(frontend)) - allSites.getElementsByClassName(frontend)[0].classList.add("hide") - else - allSites.getElementsByClassName(frontend)[0].classList.remove("hide") - currSite.getElementsByClassName(frontend)[0].classList.add("hide") - } - - let url; - try { url = new URL(tabs[0].url); } - catch { return; } - - if (youtubeHelper.redirect(url, 'main_frame', false, true) || await youtubeHelper.switchInstance(url, 'main_frame', false, true)) { - currSite.getElementsByClassName('youtube')[0].classList.remove("hide"); - allSites.getElementsByClassName('youtube')[0].classList.add("hide"); - } - else if (twitterHelper.redirect(url, 'main_frame', false, true) || await twitterHelper.switchInstance(url, 'main_frame', false, true)) { - currSite.getElementsByClassName('twitter')[0].classList.remove("hide"); - allSites.getElementsByClassName('twitter')[0].classList.add("hide"); - } - else if (instagramHelper.redirect(url, 'main_frame', false, true) || await instagramHelper.switchInstance(url, 'main_frame', false, true)) { - currSite.getElementsByClassName('instagram')[0].classList.remove("hide"); - allSites.getElementsByClassName('instagram')[0].classList.add("hide"); - } - else if (mapsHelper.redirect(url, false)) { - currSite.getElementsByClassName('maps')[0].classList.remove("hide"); - allSites.getElementsByClassName('maps')[0].classList.add("hide"); - } - else if (redditHelper.redirect(url, 'main_frame', false, true) || await redditHelper.switchInstance(url, 'main_frame', false, true)) { - currSite.getElementsByClassName('reddit')[0].classList.remove("hide"); - allSites.getElementsByClassName('reddit')[0].classList.add("hide"); - } - else if (mediumHelper.redirect(url, 'main_frame', false, true) || await mediumHelper.switchInstance(url, 'main_frame', false, true)) { - currSite.getElementsByClassName('medium')[0].classList.remove("hide"); - allSites.getElementsByClassName('medium')[0].classList.add("hide"); - } - else if (quoraHelper.redirect(url, 'main_frame', false, true) || await quoraHelper.switchInstance(url, 'main_frame', false, true)) { - currSite.getElementsByClassName('quora')[0].classList.remove("hide"); - allSites.getElementsByClassName('quora')[0].classList.add("hide"); - } - else if (libremdbHelper.redirect(url, 'main_frame', false, true) || await libremdbHelper.switchInstance(url, 'main_frame', false, true)) { - currSite.getElementsByClassName('imdb')[0].classList.remove("hide"); - allSites.getElementsByClassName('imdb')[0].classList.add("hide"); - } - else if (reutersHelper.redirect(url, 'main_frame', false, true)) { - currSite.getElementsByClassName('reuters')[0].classList.remove("hide"); - allSites.getElementsByClassName('reuters')[0].classList.add("hide"); - } - else if (imgurHelper.redirect(url, 'main_frame', false, true) || await imgurHelper.switchInstance(url, 'main_frame', false, true)) { - currSite.getElementsByClassName('imgur')[0].classList.remove("hide"); - allSites.getElementsByClassName('imgur')[0].classList.add("hide"); - } - else if (tiktokHelper.redirect(url, 'main_frame', false, true) || await tiktokHelper.switchInstance(url, 'main_frame', false, true)) { - currSite.getElementsByClassName('tiktok')[0].classList.remove("hide"); - allSites.getElementsByClassName('tiktok')[0].classList.add("hide"); - } - else if (sendTargetsHelper.redirect(url, 'main_frame', false, true) || await sendTargetsHelper.switchInstance(url, 'main_frame', false, true)) { - currSite.getElementsByClassName('sendTargets')[0].classList.remove("hide"); - allSites.getElementsByClassName('sendTargets')[0].classList.add("hide"); - } - else if (peertubeHelper.redirect(url, 'main_frame', false, true) || await peertubeHelper.switchInstance(url, 'main_frame', false, true)) { - currSite.getElementsByClassName('peertube')[0].classList.remove("hide"); - allSites.getElementsByClassName('peertube')[0].classList.add("hide"); - } - else if (lbryHelper.redirect(url, 'main_frame', false, true) || await lbryHelper.switchInstance(url, 'main_frame', false, true)) { - currSite.getElementsByClassName('lbry')[0].classList.remove("hide"); - allSites.getElementsByClassName('lbry')[0].classList.add("hide"); - } - else if (translateHelper.redirect(url, true) || await translateHelper.switchInstance(url, true)) { - currSite.getElementsByClassName('translate')[0].classList.remove("hide"); - allSites.getElementsByClassName('translate')[0].classList.add("hide"); - } - else if (searchHelper.redirect(url, true) || await searchHelper.switchInstance(url, true)) { - currSite.getElementsByClassName('search')[0].classList.remove("hide"); - allSites.getElementsByClassName('search')[0].classList.add("hide"); - } - else if (wikipediaHelper.redirect(url, true) || await wikipediaHelper.switchInstance(url, true)) { - currSite.getElementsByClassName('wikipedia')[0].classList.remove("hide"); - allSites.getElementsByClassName('wikipedia')[0].classList.add("hide"); - } - else if (youtubeMusicHelper.redirect(url, 'main_frame', false, true)) { - currSite.getElementsByClassName('youtubeMusic')[0].classList.remove("hide"); - allSites.getElementsByClassName('youtubeMusic')[0].classList.add("hide"); - } - }) - } + [ + "disableTwitter", + "disableYoutube", + "disableYoutubeMusic", + "disableInstagram", + "disableMaps", + "disableReddit", + "disableSearch", + "translateDisable", + "disableWikipedia", + "disableImgur", + "disableTiktok", + "disableMedium", + "disableQuora", + "disableImdb", + "disableReuters", + "disablePeertubeTargets", + "disableLbryTargets", + "disableSendTarget", + "popupFrontends", + ], + r => { + disableTwitterCurrentSite.checked = !r.disableTwitter + disableTwitterAllSites.checked = !r.disableTwitter + disableYoutubeCurrentSite.checked = !r.disableYoutube + disableYoutubeAllSites.checked = !r.disableYoutube + disableYoutubeMusicCurrentSite.checked = !r.disableYoutubeMusic + disableYoutubeMusicAllSites.checked = !r.disableYoutubeMusic + disableInstagramCurrentSite.checked = !r.disableInstagram + disableInstagramAllSites.checked = !r.disableInstagram + disableMapsCurrentSite.checked = !r.disableMaps + disableMapsAllSites.checked = !r.disableMaps + disableRedditCurrentSite.checked = !r.disableReddit + disableRedditAllSites.checked = !r.disableReddit + disableSearchCurrentSite.checked = !r.disableSearch + disableSearchAllSites.checked = !r.disableSearch + disableTranslateCurrentSite.checked = !r.translateDisable + disableTranslateAllSites.checked = !r.translateDisable + disableWikipediaCurrentSite.checked = !r.disableWikipedia + disableWikipediaAllSites.checked = !r.disableWikipedia + disableImgurCurrentSite.checked = !r.disableImgur + disableImgurAllSites.checked = !r.disableImgur + disableTiktokCurrentSite.checked = !r.disableTiktok + disableTiktokAllSites.checked = !r.disableTiktok + disableMediumCurrentSite.checked = !r.disableMedium + disableMediumAllSites.checked = !r.disableMedium + disableQuoraCurrentSite.checked = !r.disableQuora + disableQuoraAllSites.checked = !r.disableQuora + disableImdbCurrentSite.checked = !r.disableImdb + disableImdbAllSites.checked = !r.disableImdb + disableReutersCurrentSite.checked = !r.disableReuters + disableReutersAllSites.checked = !r.disableReuters + disablePeertubeTargetsCurrentSite.checked = !r.disablePeertubeTargets + disablePeertubeTargetsAllSites.checked = !r.disablePeertubeTargets + disableLbryTargetsCurrentSite.checked = !r.disableLbryTargets + disableLbryTargetsAllSites.checked = !r.disableLbryTargets + disableSendTargetsCurrentSite.checked = !r.disableSendTarget + disableSendTargetsAllSites.checked = !r.disableSendTarget + + browser.tabs.query({ active: true, currentWindow: true }, async tabs => { + for (const frontend of generalHelper.allPopupFrontends) { + if (!r.popupFrontends.includes(frontend)) allSites.getElementsByClassName(frontend)[0].classList.add("hide") + else allSites.getElementsByClassName(frontend)[0].classList.remove("hide") + currSite.getElementsByClassName(frontend)[0].classList.add("hide") + } + + let url + try { + url = new URL(tabs[0].url) + } catch { + currentSiteIsFrontend.classList.add("hide") + return + } + + if (youtubeMusicHelper.redirect(url, "main_frame", false, true) || (await youtubeMusicHelper.switchInstance(url, true))) { + currSite.getElementsByClassName("youtubeMusic")[0].classList.remove("hide") + allSites.getElementsByClassName("youtubeMusic")[0].classList.add("hide") + } else if (twitterHelper.redirect(url, "main_frame", false, true) || (await twitterHelper.switchInstance(url, "main_frame", false, true))) { + currSite.getElementsByClassName("twitter")[0].classList.remove("hide") + allSites.getElementsByClassName("twitter")[0].classList.add("hide") + } else if (instagramHelper.redirect(url, "main_frame", false, true) || (await instagramHelper.switchInstance(url, "main_frame", false, true))) { + currSite.getElementsByClassName("instagram")[0].classList.remove("hide") + allSites.getElementsByClassName("instagram")[0].classList.add("hide") + } else if (mapsHelper.redirect(url, false)) { + currSite.getElementsByClassName("maps")[0].classList.remove("hide") + allSites.getElementsByClassName("maps")[0].classList.add("hide") + } else if (redditHelper.redirect(url, "main_frame", false, true) || (await redditHelper.switchInstance(url, "main_frame", false, true))) { + currSite.getElementsByClassName("reddit")[0].classList.remove("hide") + allSites.getElementsByClassName("reddit")[0].classList.add("hide") + } else if (mediumHelper.redirect(url, "main_frame", false, true) || (await mediumHelper.switchInstance(url, "main_frame", false, true))) { + currSite.getElementsByClassName("medium")[0].classList.remove("hide") + allSites.getElementsByClassName("medium")[0].classList.add("hide") + } else if (quoraHelper.redirect(url, "main_frame", false, true) || (await quoraHelper.switchInstance(url, "main_frame", false, true))) { + currSite.getElementsByClassName("quora")[0].classList.remove("hide") + allSites.getElementsByClassName("quora")[0].classList.add("hide") + } else if (libremdbHelper.redirect(url, "main_frame", false, true) || (await libremdbHelper.switchInstance(url, "main_frame", false, true))) { + currSite.getElementsByClassName("imdb")[0].classList.remove("hide") + allSites.getElementsByClassName("imdb")[0].classList.add("hide") + } else if (reutersHelper.redirect(url, "main_frame", false, true)) { + currSite.getElementsByClassName("reuters")[0].classList.remove("hide") + allSites.getElementsByClassName("reuters")[0].classList.add("hide") + } else if (imgurHelper.redirect(url, "main_frame", false, true) || (await imgurHelper.switchInstance(url, "main_frame", false, true))) { + currSite.getElementsByClassName("imgur")[0].classList.remove("hide") + allSites.getElementsByClassName("imgur")[0].classList.add("hide") + } else if (tiktokHelper.redirect(url, "main_frame", false, true) || (await tiktokHelper.switchInstance(url, "main_frame", false, true))) { + currSite.getElementsByClassName("tiktok")[0].classList.remove("hide") + allSites.getElementsByClassName("tiktok")[0].classList.add("hide") + } else if (sendTargetsHelper.redirect(url, "main_frame", false, true) || (await sendTargetsHelper.switchInstance(url, "main_frame", false, true))) { + currSite.getElementsByClassName("sendTargets")[0].classList.remove("hide") + allSites.getElementsByClassName("sendTargets")[0].classList.add("hide") + } else if (peertubeHelper.redirect(url, "main_frame", false, true) || (await peertubeHelper.switchInstance(url, true))) { + currSite.getElementsByClassName("peertube")[0].classList.remove("hide") + allSites.getElementsByClassName("peertube")[0].classList.add("hide") + } else if (lbryHelper.redirect(url, "main_frame", false, true) || (await lbryHelper.switchInstance(url, "main_frame", false, true))) { + currSite.getElementsByClassName("lbry")[0].classList.remove("hide") + allSites.getElementsByClassName("lbry")[0].classList.add("hide") + } else if (translateHelper.redirect(url, true) || (await translateHelper.switchInstance(url, true))) { + currSite.getElementsByClassName("translate")[0].classList.remove("hide") + allSites.getElementsByClassName("translate")[0].classList.add("hide") + } else if (searchHelper.redirect(url, true) || (await searchHelper.switchInstance(url, true))) { + currSite.getElementsByClassName("search")[0].classList.remove("hide") + allSites.getElementsByClassName("search")[0].classList.add("hide") + } else if (wikipediaHelper.redirect(url, true) || (await wikipediaHelper.switchInstance(url, true))) { + currSite.getElementsByClassName("wikipedia")[0].classList.remove("hide") + allSites.getElementsByClassName("wikipedia")[0].classList.add("hide") + } else if (youtubeHelper.redirect(url, "main_frame", false, true) || (await youtubeHelper.switchInstance(url, "main_frame", false, true))) { + currSite.getElementsByClassName("youtube")[0].classList.remove("hide") + allSites.getElementsByClassName("youtube")[0].classList.add("hide") + } else { + currentSiteIsFrontend.classList.add("hide") + } + }) + } ) document.addEventListener("change", () => { - browser.storage.local.get( - [ - "disableTwitter", - "disableYoutube", - "disableYoutubeMusic", - "disableInstagram", - "disableMaps", - "disableReddit", - "disableSearch", - "translateDisable", - "disableWikipedia", - "disableImgur", - "disableTiktok", - "disableMedium", - "disableQuora", - "disableImdb", - "disableReuters", - "disablePeertubeTargets", - "disableLbryTargets", - "disableSendTarget", - ], - r => { - if (!r.disableTwitter != disableTwitterCurrentSite.checked) browser.storage.local.set({ disableTwitter: !disableTwitterCurrentSite.checked }) - else if (!r.disableTwitter != disableTwitterAllSites.checked) browser.storage.local.set({ disableTwitter: !disableTwitterAllSites.checked }) - - if (!r.disableYoutube != disableYoutubeCurrentSite.checked) browser.storage.local.set({ disableYoutube: !disableYoutubeCurrentSite.checked }) - else if (!r.disableYoutube != disableYoutubeAllSites.checked) browser.storage.local.set({ disableYoutube: !disableYoutubeAllSites.checked }) - - if (!r.disableYoutubeMusic != disableYoutubeMusicCurrentSite.checked) browser.storage.local.set({ disableYoutubeMusic: !disableYoutubeMusicCurrentSite.checked }) - else if (!r.disableYoutubeMusic != disableYoutubeMusicAllSites.checked) browser.storage.local.set({ disableYoutubeMusic: !disableYoutubeMusicAllSites.checked }) - - if (!r.disableInstagram != disableInstagramCurrentSite.checked) browser.storage.local.set({ disableInstagram: !disableInstagramCurrentSite.checked }) - else if (!r.disableInstagram != disableInstagramAllSites.checked) browser.storage.local.set({ disableInstagram: !disableInstagramAllSites.checked }) - - if (!r.disableMaps != disableMapsCurrentSite.checked) browser.storage.local.set({ disableMaps: !disableMapsCurrentSite.checked }) - else if (!r.disableMaps != disableMapsAllSites.checked) browser.storage.local.set({ disableMaps: !disableMapsAllSites.checked }) - - if (!r.disableReddit != disableRedditCurrentSite.checked) browser.storage.local.set({ disableReddit: !disableRedditCurrentSite.checked }) - else if (!r.disableReddit != disableRedditAllSites.checked) browser.storage.local.set({ disableReddit: !disableRedditAllSites.checked }) - - if (!r.disableSearch != disableSearchCurrentSite.checked) browser.storage.local.set({ disableSearch: !disableSearchCurrentSite.checked }) - else if (!r.disableSearch != disableSearchAllSites.checked) browser.storage.local.set({ disableSearch: !disableSearchAllSites.checked }) - - if (!r.translateDisable != disableTranslateCurrentSite.checked) browser.storage.local.set({ translateDisable: !disableTranslateCurrentSite.checked }) - else if (!r.translateDisable != disableTranslateAllSites.checked) browser.storage.local.set({ translateDisable: !disableTranslateAllSites.checked }) - - if (!r.disableWikipedia != disableWikipediaCurrentSite.checked) browser.storage.local.set({ disableWikipedia: !disableWikipediaCurrentSite.checked }) - else if (!r.disableWikipedia != disableWikipediaAllSites.checked) browser.storage.local.set({ disableWikipedia: !disableWikipediaAllSites.checked }) - - if (!r.disableImgur != disableImgurCurrentSite.checked) browser.storage.local.set({ disableImgur: !disableImgurCurrentSite.checked }) - else if (!r.disableImgur != disableImgurAllSites.checked) browser.storage.local.set({ disableImgur: !disableImgurAllSites.checked }) - - if (!r.disableTiktok != disableTiktokCurrentSite.checked) browser.storage.local.set({ disableTiktok: !disableTiktokCurrentSite.checked }) - else if (!r.disableTiktok != disableTiktokAllSites.checked) browser.storage.local.set({ disableTiktok: !disableTiktokAllSites.checked }) - - if (!r.disableMedium != disableMediumCurrentSite.checked) browser.storage.local.set({ disableMedium: !disableMediumCurrentSite.checked }) - else if (!r.disableMedium != disableMediumAllSites.checked) browser.storage.local.set({ disableMedium: !disableMediumAllSites.checked }) - - if (!r.disableQuora != disableQuoraCurrentSite.checked) browser.storage.local.set({ disableQuora: !disableQuoraCurrentSite.checked }) - else if (!r.disableQuora != disableQuoraAllSites.checked) browser.storage.local.set({ disableQuora: !disableQuoraAllSites.checked }) - - if (!r.disableImdb != disableImdbCurrentSite.checked) browser.storage.local.set({ disableImdb: !disableImdbCurrentSite.checked }) - else if (!r.disableImdb != disableImdbAllSites.checked) browser.storage.local.set({ disableImdb: !disableImdbAllSites.checked }) - - if (!r.disableReuters != disableReutersCurrentSite.checked) browser.storage.local.set({ disableReuters: !disableReutersCurrentSite.checked }) - else if (!r.disableReuters != disableReutersAllSites.checked) browser.storage.local.set({ disableReuters: !disableReutersAllSites.checked }) - - if (!r.disablePeertubeTargets != disablePeertubeTargetsCurrentSite.checked) browser.storage.local.set({ disablePeertubeTargets: !disablePeertubeTargetsCurrentSite.checked }) - else if (!r.disablePeertubeTargets != disablePeertubeTargetsAllSites.checked) browser.storage.local.set({ disablePeertubeTargets: !disablePeertubeTargetsAllSites.checked }) - - if (!r.disableLbryTargets != disableLbryTargetsCurrentSite.checked) browser.storage.local.set({ disableLbryTargets: !disableLbryTargetsCurrentSite.checked }) - else if (!r.disableLbryTargets != disableLbryTargetsAllSites.checked) browser.storage.local.set({ disableLbryTargets: !disableLbryTargetsAllSites.checked }) - - if (!r.disableSendTarget != disableSendTargetsCurrentSite.checked) browser.storage.local.set({ disableSendTarget: !disableSendTargetsCurrentSite.checked }) - else if (!r.disableSendTarget != disableSendTargetsAllSites.checked) browser.storage.local.set({ disableSendTarget: !disableSendTargetsAllSites.checked }) - }) + browser.storage.local.get( + [ + "disableTwitter", + "disableYoutube", + "disableYoutubeMusic", + "disableInstagram", + "disableMaps", + "disableReddit", + "disableSearch", + "translateDisable", + "disableWikipedia", + "disableImgur", + "disableTiktok", + "disableMedium", + "disableQuora", + "disableImdb", + "disableReuters", + "disablePeertubeTargets", + "disableLbryTargets", + "disableSendTarget", + ], + r => { + if (!r.disableTwitter != disableTwitterCurrentSite.checked) + browser.storage.local.set({ + disableTwitter: !disableTwitterCurrentSite.checked, + }) + else if (!r.disableTwitter != disableTwitterAllSites.checked) + browser.storage.local.set({ + disableTwitter: !disableTwitterAllSites.checked, + }) + + if (!r.disableYoutube != disableYoutubeCurrentSite.checked) + browser.storage.local.set({ + disableYoutube: !disableYoutubeCurrentSite.checked, + }) + else if (!r.disableYoutube != disableYoutubeAllSites.checked) + browser.storage.local.set({ + disableYoutube: !disableYoutubeAllSites.checked, + }) + + if (!r.disableYoutubeMusic != disableYoutubeMusicCurrentSite.checked) + browser.storage.local.set({ + disableYoutubeMusic: !disableYoutubeMusicCurrentSite.checked, + }) + else if (!r.disableYoutubeMusic != disableYoutubeMusicAllSites.checked) + browser.storage.local.set({ + disableYoutubeMusic: !disableYoutubeMusicAllSites.checked, + }) + + if (!r.disableInstagram != disableInstagramCurrentSite.checked) + browser.storage.local.set({ + disableInstagram: !disableInstagramCurrentSite.checked, + }) + else if (!r.disableInstagram != disableInstagramAllSites.checked) + browser.storage.local.set({ + disableInstagram: !disableInstagramAllSites.checked, + }) + + if (!r.disableMaps != disableMapsCurrentSite.checked) + browser.storage.local.set({ + disableMaps: !disableMapsCurrentSite.checked, + }) + else if (!r.disableMaps != disableMapsAllSites.checked) + browser.storage.local.set({ + disableMaps: !disableMapsAllSites.checked, + }) + + if (!r.disableReddit != disableRedditCurrentSite.checked) + browser.storage.local.set({ + disableReddit: !disableRedditCurrentSite.checked, + }) + else if (!r.disableReddit != disableRedditAllSites.checked) + browser.storage.local.set({ + disableReddit: !disableRedditAllSites.checked, + }) + + if (!r.disableSearch != disableSearchCurrentSite.checked) + browser.storage.local.set({ + disableSearch: !disableSearchCurrentSite.checked, + }) + else if (!r.disableSearch != disableSearchAllSites.checked) + browser.storage.local.set({ + disableSearch: !disableSearchAllSites.checked, + }) + + if (!r.translateDisable != disableTranslateCurrentSite.checked) + browser.storage.local.set({ + translateDisable: !disableTranslateCurrentSite.checked, + }) + else if (!r.translateDisable != disableTranslateAllSites.checked) + browser.storage.local.set({ + translateDisable: !disableTranslateAllSites.checked, + }) + + if (!r.disableWikipedia != disableWikipediaCurrentSite.checked) + browser.storage.local.set({ + disableWikipedia: !disableWikipediaCurrentSite.checked, + }) + else if (!r.disableWikipedia != disableWikipediaAllSites.checked) + browser.storage.local.set({ + disableWikipedia: !disableWikipediaAllSites.checked, + }) + + if (!r.disableImgur != disableImgurCurrentSite.checked) + browser.storage.local.set({ + disableImgur: !disableImgurCurrentSite.checked, + }) + else if (!r.disableImgur != disableImgurAllSites.checked) + browser.storage.local.set({ + disableImgur: !disableImgurAllSites.checked, + }) + + if (!r.disableTiktok != disableTiktokCurrentSite.checked) + browser.storage.local.set({ + disableTiktok: !disableTiktokCurrentSite.checked, + }) + else if (!r.disableTiktok != disableTiktokAllSites.checked) + browser.storage.local.set({ + disableTiktok: !disableTiktokAllSites.checked, + }) + + if (!r.disableMedium != disableMediumCurrentSite.checked) + browser.storage.local.set({ + disableMedium: !disableMediumCurrentSite.checked, + }) + else if (!r.disableMedium != disableMediumAllSites.checked) + browser.storage.local.set({ + disableMedium: !disableMediumAllSites.checked, + }) + + if (!r.disableQuora != disableQuoraCurrentSite.checked) + browser.storage.local.set({ + disableQuora: !disableQuoraCurrentSite.checked, + }) + else if (!r.disableQuora != disableQuoraAllSites.checked) + browser.storage.local.set({ + disableQuora: !disableQuoraAllSites.checked, + }) + + if (!r.disableImdb != disableImdbCurrentSite.checked) + browser.storage.local.set({ + disableImdb: !disableImdbCurrentSite.checked, + }) + else if (!r.disableImdb != disableImdbAllSites.checked) + browser.storage.local.set({ + disableImdb: !disableImdbAllSites.checked, + }) + + if (!r.disableReuters != disableReutersCurrentSite.checked) + browser.storage.local.set({ + disableReuters: !disableReutersCurrentSite.checked, + }) + else if (!r.disableReuters != disableReutersAllSites.checked) + browser.storage.local.set({ + disableReuters: !disableReutersAllSites.checked, + }) + + if (!r.disablePeertubeTargets != disablePeertubeTargetsCurrentSite.checked) + browser.storage.local.set({ + disablePeertubeTargets: !disablePeertubeTargetsCurrentSite.checked, + }) + else if (!r.disablePeertubeTargets != disablePeertubeTargetsAllSites.checked) + browser.storage.local.set({ + disablePeertubeTargets: !disablePeertubeTargetsAllSites.checked, + }) + + if (!r.disableLbryTargets != disableLbryTargetsCurrentSite.checked) + browser.storage.local.set({ + disableLbryTargets: !disableLbryTargetsCurrentSite.checked, + }) + else if (!r.disableLbryTargets != disableLbryTargetsAllSites.checked) + browser.storage.local.set({ + disableLbryTargets: !disableLbryTargetsAllSites.checked, + }) + + if (!r.disableSendTarget != disableSendTargetsCurrentSite.checked) + browser.storage.local.set({ + disableSendTarget: !disableSendTargetsCurrentSite.checked, + }) + else if (!r.disableSendTarget != disableSendTargetsAllSites.checked) + browser.storage.local.set({ + disableSendTarget: !disableSendTargetsAllSites.checked, + }) + } + ) }) -for (const a of document.getElementsByTagName('a')) { - a.addEventListener('click', e => { - if (!a.classList.contains('prevent')) { - browser.tabs.create({ url: a.getAttribute('href') }); - e.preventDefault(); - } - }) +for (const a of document.getElementsByTagName("a")) { + a.addEventListener("click", e => { + if (!a.classList.contains("prevent")) { + browser.tabs.create({ url: a.getAttribute("href") }) + e.preventDefault() + } + }) } diff --git a/src/pages/popup/popup.pug b/src/pages/popup/popup.pug index 13eb66a5..cd4d3713 100644 --- a/src/pages/popup/popup.pug +++ b/src/pages/popup/popup.pug @@ -119,7 +119,8 @@ html(lang="en") body(dir="auto") .current_site +services - hr + #current_site_divider + hr .all_sites +services hr @@ -151,4 +152,4 @@ html(lang="en") .space script(type="module" src="../options/init.js") - script(type="module" src="./popup.js") \ No newline at end of file + script(type="module" src="./popup.js") diff --git a/src/pages/popup/style.css b/src/pages/popup/style.css index 8136237a..0cb27912 100644 --- a/src/pages/popup/style.css +++ b/src/pages/popup/style.css @@ -1,23 +1,24 @@ body { - width: 230px; - min-height: auto; + width: 230px; + min-height: auto; } -html, body { - margin: 0; +html, +body { + margin: 0; } .hide { - display: none !important; + display: none !important; } .button { - display: flex; - margin: 0 auto; - justify-content: space-between; - width: 100%; + display: flex; + margin: 0 auto; + justify-content: space-between; + width: 100%; } .space { - height: 10px; -} \ No newline at end of file + height: 10px; +} diff --git a/src/pages/stylesheets/styles.css b/src/pages/stylesheets/styles.css index 67b0229d..06abab3a 100644 --- a/src/pages/stylesheets/styles.css +++ b/src/pages/stylesheets/styles.css @@ -1,465 +1,466 @@ body { - --text: #fff; - --bg-main: #121212; - --bg-secondary: #202020; - --active: #fbc117; - --space: 5px; - --danger: #f04141; - --danger-light: #f9d0d5; - --dark-grey: #767676; - --light-grey: #c3c3c3; + --text: #fff; + --bg-main: #121212; + --bg-secondary: #202020; + --active: #fbc117; + --space: 5px; + --danger: #f04141; + --danger-light: #f9d0d5; + --dark-grey: #767676; + --light-grey: #c3c3c3; } @font-face { - font-family: 'Inter'; - src: url('Inter-VariableFont_slnt,wght.ttf'); - font-weight: normal; - font-style: normal; + font-family: "Inter"; + src: url("Inter-VariableFont_slnt,wght.ttf"); + font-weight: normal; + font-style: normal; } @font-face { - font-family: 'Vazirmatn'; - src: url('Vazirmatn-VariableFont_wght.ttf'); - font-weight: normal; - font-style: normal; + font-family: "Vazirmatn"; + src: url("Vazirmatn-VariableFont_wght.ttf"); + font-weight: normal; + font-style: normal; } body { - margin: auto; - padding: 0; - font-family: 'Inter'; - background-color: var(--bg-main); - color: var(--text); - overflow-x: hidden + margin: auto; + padding: 0; + font-family: "Inter"; + background-color: var(--bg-main); + color: var(--text); + overflow-x: hidden; } body.rtl { - font-family: 'Vazirmatn'; - /* line-height: 1; */ + font-family: "Vazirmatn"; + /* line-height: 1; */ } div.some-block input[type="checkbox"] { - appearance: none; - -moz-appearance: none; - -webkit-appearance: none; + appearance: none; + -moz-appearance: none; + -webkit-appearance: none; } .title { - display: flex; - align-items: center; - text-decoration: none; - color: var(--text); + display: flex; + align-items: center; + text-decoration: none; + color: var(--text); } -img, svg { - margin-right: 10px; - height: 26px; - width: 26px; - color: var(--text); +img, +svg { + margin-right: 10px; + height: 26px; + width: 26px; + color: var(--text); } -body.rtl img, body.rtl svg { - margin-right: 0px; - margin-left: 10px; +body.rtl img, +body.rtl svg { + margin-right: 0px; + margin-left: 10px; } input[type="url"], input[type="text"], select { - font-weight: bold; - box-sizing: border-box; - border-style: solid; - border-color: #767676; - color: var(--text); - font-size: 16px; - padding: 8px; - background-color: var(--bg-secondary); - border: none; - margin: 0; - max-width: 500px; - border-radius: 3px; + font-weight: bold; + box-sizing: border-box; + border-style: solid; + border-color: #767676; + color: var(--text); + font-size: 16px; + padding: 8px; + background-color: var(--bg-secondary); + border: none; + margin: 0; + max-width: 500px; + border-radius: 3px; } input[type="url"], input[type="text"] { - width: 400px; + width: 400px; } input:invalid { - color: var(--danger); - border-color: var(--danger); + color: var(--danger); + border-color: var(--danger); } .button svg { - height: 18px; - width: 18px; + height: 18px; + width: 18px; } section.option-block { - width: 750px; - margin: 0 50px; + width: 750px; + margin: 0 50px; } section.option-block h2 { - margin: 0; + margin: 0; } body.option { - display: flex; - padding: 40px; - width: 900px; + display: flex; + padding: 40px; + width: 900px; } section.links div { - margin: 20px 0; - width: max-content; + margin: 20px 0; + width: max-content; } a { - color: var(--active); + color: var(--active); } section.links a { - display: flex; - align-items: center; - font-size: 18px; - text-decoration: none; - color: white; - transition: 0.1s; + display: flex; + align-items: center; + font-size: 18px; + text-decoration: none; + color: white; + transition: 0.1s; } section.links a:hover, section.links a.selected { - color: var(--active); + color: var(--active); } input[type="range"] { - -webkit-appearance: none; - width: 350px; - height: 7px; - border-radius: 50px; - background: var(--text); + -webkit-appearance: none; + width: 350px; + height: 7px; + border-radius: 50px; + background: var(--text); } input[type="range"]:hover { - background: var(--light-grey); + background: var(--light-grey); } input[type="range"]::-webkit-slider-thumb { - appearance: none; - width: 20px; - height: 20px; - border-radius: 50%; - background: var(--active); - border: none; + appearance: none; + width: 20px; + height: 20px; + border-radius: 50%; + background: var(--active); + border: none; } input[type="range"]::-moz-range-thumb { - width: 20px; - height: 20px; - border-radius: 50%; - background: var(--active); - border: none; + width: 20px; + height: 20px; + border-radius: 50%; + background: var(--active); + border: none; } ::placeholder { - color: var(--text); - opacity: 0.7; + color: var(--text); + opacity: 0.7; } #volume-value { - color: var(--active); + color: var(--active); } /* \25BE */ hr { - height: 2px; - margin: 0 15px; - background-color: rgb(77, 77, 77); - border: none; + height: 2px; + margin: 0 15px; + background-color: rgb(77, 77, 77); + border: none; } div.some-block { - padding: 0 15px; - justify-content: space-between; - display: flex; - align-items: center; - margin-top: 10px; - margin-bottom: 10px; + padding: 0 15px; + justify-content: space-between; + display: flex; + align-items: center; + margin-top: 10px; + margin-bottom: 10px; } div.option-block { - margin: 30px 0; + margin: 30px 0; } h4 { - margin: 10px 0; - font-size: 18px; + margin: 10px 0; + font-size: 18px; } div.some-block h4 { - margin: 0; + margin: 0; } div.option-block h4 { - margin-right: 5px; - width: 80%; - min-width: 150px; - font-size: 18px; + margin-right: 5px; + width: 80%; + min-width: 150px; + font-size: 18px; } div.option-block h1 { - margin: 0; - font-size: 28px; - color: var(--text); + margin: 0; + font-size: 28px; + color: var(--text); } div.option-block div { - text-align: center; + text-align: center; } div.some-block input[type="checkbox"] { - width: 46px; - height: 23px; - background-color: var(--light-grey); - border-radius: 50px; - transition: .4s; - cursor: pointer; + width: 46px; + height: 23px; + background-color: var(--light-grey); + border-radius: 50px; + transition: 0.4s; + cursor: pointer; } div.some-block input[type="checkbox"]:checked { - background-color: var(--active); + background-color: var(--active); } div.some-block input[type="checkbox"]::before { - content: ""; - display: inline-block; - width: 18px; - height: 18px; - box-sizing: border-box; - position: relative; - top: 2.5px; - left: 3.5px; - background-color: white; - border-radius: 50%; - transition: .3s; + content: ""; + display: inline-block; + width: 18px; + height: 18px; + box-sizing: border-box; + position: relative; + top: 2.5px; + left: 3.5px; + background-color: white; + border-radius: 50%; + transition: 0.3s; } body.rtl div.some-block input[type="checkbox"]::before { - left: auto; - right: 4px; + left: auto; + right: 4px; } div.some-block input[type="checkbox"]:checked::before { - left: 24px; + left: 24px; } body.rtl div.some-block input[type="checkbox"]:checked::before { - left: auto; - right: 24px; + left: auto; + right: 24px; } div.buttons { - display: flex; - margin: 0 15px; - margin-bottom: 15px; - margin-top: 15px; - flex-wrap: wrap; - align-items: center; + display: flex; + margin: 0 15px; + margin-bottom: 15px; + margin-top: 15px; + flex-wrap: wrap; + align-items: center; } div.buttons-popup { - border-radius: 5px; - display: flex; - flex-wrap: wrap; - margin: 0 10px 7px 10px; - justify-content: start; - align-items: center; + border-radius: 5px; + display: flex; + flex-wrap: wrap; + margin: 0 10px 7px 10px; + justify-content: start; + align-items: center; } .button { - color: var(--text); - font-size: 16px; - font-weight: bold; - text-decoration: none; - cursor: pointer; - transition-duration: 0.1s; + color: var(--text); + font-size: 16px; + font-weight: bold; + text-decoration: none; + cursor: pointer; + transition-duration: 0.1s; } .button:hover { - color: var(--active); + color: var(--active); } .button svg { - width: auto; - height: auto; - padding: 0; - margin-right: 5px; + width: auto; + height: auto; + padding: 0; + margin-right: 5px; } .button:hover svg { - color: var(--active); + color: var(--active); } div.buttons-inline { - display: flex; - justify-content: start; - /* padding: 0 15px; */ + display: flex; + justify-content: start; + /* padding: 0 15px; */ } .button-inline { - display: inline-flex; - align-items: center; - margin: 7.5px 0; - background-color: var(--bg-secondary); - border-radius: 5px; - padding: 10px; + display: inline-flex; + align-items: center; + margin: 7.5px 0; + background-color: var(--bg-secondary); + border-radius: 5px; + padding: 10px; } .button:active { - transform: translateY(1px); + transform: translateY(1px); } button.default { - margin-left: 30px; - background-color: transparent; - border: none; - color: white; - padding: 5px; - width: 34px; - height: 34px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; - margin: 4px 2px; - cursor: pointer; + margin-left: 30px; + background-color: transparent; + border: none; + color: white; + padding: 5px; + width: 34px; + height: 34px; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 16px; + margin: 4px 2px; + cursor: pointer; } button svg { - color: var(--text); + color: var(--text); } -div.checklist{ -direction: ltr; +div.checklist { + direction: ltr; } div.checklist div { - justify-content: space-between; - margin: 5px 15px; - padding: 10px 0; - word-wrap: break-word; - display: flex; - + justify-content: space-between; + margin: 5px 15px; + padding: 10px 0; + word-wrap: break-word; + display: flex; } div.checklist a { - text-decoration: none; - color: var(--text); + text-decoration: none; + color: var(--text); } div.checklist a:hover { - text-decoration: underline; + text-decoration: underline; } div.checklist-popup div { - justify-content: space-between; - margin: 5px 15px; - padding: 5px 0; - max-width: 200px; - display: flex; - align-items: center; + justify-content: space-between; + margin: 5px 15px; + padding: 5px 0; + max-width: 200px; + display: flex; + align-items: center; } div.checklist-popup div div { - margin: 0; + margin: 0; } button.add { - background-color: transparent; - border: none; - padding: 0; - margin: 0; - text-decoration: none; - display: inline-block; - cursor: pointer; + background-color: transparent; + border: none; + padding: 0; + margin: 0; + text-decoration: none; + display: inline-block; + cursor: pointer; } div.disabled { - background-color: rgb(39, 39, 39); - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; + background-color: rgb(39, 39, 39); + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; } .light-theme.popup, .light-theme .popup { - background-color: var(--bg-secondary); + background-color: var(--bg-secondary); } body.light-theme { - --text: black; - --bg-main: white; - --bg-secondary: #fff; - --active: #fb9817; + --text: black; + --bg-main: white; + --bg-secondary: #fff; + --active: #fb9817; } body.light-theme select { - border: 1px solid black; + border: 1px solid black; } body.light-theme textarea { - color: black; - border: 1px solid #767676; + color: black; + border: 1px solid #767676; } body.light-theme textarea:focus { - outline: none; + outline: none; } body.light-theme a { - color: black; + color: black; } section.general { - display: flex; - flex-wrap: wrap; - margin-right: 0; - width: 100%; - justify-content: space-between; + display: flex; + flex-wrap: wrap; + margin-right: 0; + width: 100%; + justify-content: space-between; } section.general div { - margin-right: 20px; + margin-right: 20px; } #customize-popup { - width: 250px; + width: 250px; } button { - background-color:transparent; - color: var(--text); - border: none; - padding: 10px 5px; - text-decoration: none; - display: inline-block; - cursor: pointer; - border-radius: 5px; + background-color: transparent; + color: var(--text); + border: none; + padding: 10px 5px; + text-decoration: none; + display: inline-block; + cursor: pointer; + border-radius: 5px; } body div section { - display: none; + display: none; } -div.about > div{ - justify-content: start; - width: 520px; +div.about > div { + justify-content: start; + width: 520px; } div.about h4 { - width: auto; -} \ No newline at end of file + width: auto; +} |