diff options
author | ManeraKai <manerakai@protonmail.com> | 2022-02-23 20:21:19 +0300 |
---|---|---|
committer | ManeraKai <manerakai@protonmail.com> | 2022-02-23 20:21:19 +0300 |
commit | c5ef434b2835905ba5e21153411e2c2ec4c1f770 (patch) | |
tree | 1ccc315bddb452dafd9230aeb5174c56a9229207 /src | |
parent | Added translate tor support #32 (diff) | |
download | libredirect-c5ef434b2835905ba5e21153411e2c2ec4c1f770.zip |
Added imgur, tiktok tor support #32
Diffstat (limited to 'src')
-rw-r--r-- | src/assets/javascripts/helpers/imgur.js | 113 | ||||
-rw-r--r-- | src/assets/javascripts/helpers/instagram.js | 4 | ||||
-rw-r--r-- | src/assets/javascripts/helpers/tiktok.js | 99 | ||||
-rw-r--r-- | src/assets/javascripts/helpers/twitter.js | 8 | ||||
-rw-r--r-- | src/pages/options/imgur/imgur.html | 283 | ||||
-rw-r--r-- | src/pages/options/imgur/imgur.js | 41 | ||||
-rw-r--r-- | src/pages/options/tiktok/tiktok.html | 283 | ||||
-rw-r--r-- | src/pages/options/tiktok/tiktok.js | 37 |
8 files changed, 552 insertions, 316 deletions
diff --git a/src/assets/javascripts/helpers/imgur.js b/src/assets/javascripts/helpers/imgur.js index f54ec52c..560c396d 100644 --- a/src/assets/javascripts/helpers/imgur.js +++ b/src/assets/javascripts/helpers/imgur.js @@ -3,23 +3,13 @@ window.browser = window.browser || window.chrome; import commonHelper from './common.js' const targets = [ - /^https?:\/\/(i|).?imgur.com/ + /^https?:\/\/(i|).?imgur\.com(\/.*)?$/ ]; let redirects = { "rimgo": { - "normal": [ - "https://i.bcow.xyz", - "https://rimgo.bcow.xyz", - "https://rimgo.pussthecat.org", - "https://img.riverside.rocks", - "https://rimgo.totaldarkness.net", - "https://rimgo.bus-hit.me" - ], - "tor": [ - "http://l4d4owboqr6xcmd6lf64gbegel62kbudu3x3jnldz2mx6mhn3bsv3zyd.onion", - "http://jx3dpcwedpzu2mh54obk5gvl64i2ln7pt5mrzd75s4jnndkqwzaim7ad.onion" - ] + "normal": [], + "tor": [] } } @@ -28,7 +18,8 @@ const getRedirects = () => redirects; const getCustomRedirects = function () { return { "rimgo": { - "normal": [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects] + "normal": [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects], + "tor": [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects] }, }; }; @@ -43,6 +34,13 @@ function setRedirects(val) { if (index !== -1) rimgoNormalRedirectsChecks.splice(index, 1); } setRimgoNormalRedirectsChecks(rimgoNormalRedirectsChecks); + + for (const item of rimgoTorRedirectsChecks) + if (!redirects.rimgo.normal.includes(item)) { + var index = rimgoTorRedirectsChecks.indexOf(item); + if (index !== -1) rimgoTorRedirectsChecks.splice(index, 1); + } + setRimgoTorRedirectsChecks(rimgoTorRedirectsChecks); } let rimgoNormalRedirectsChecks; @@ -53,6 +51,14 @@ function setRimgoNormalRedirectsChecks(val) { console.log("rimgoNormalRedirectsChecks: ", val) } +let rimgoTorRedirectsChecks; +const getRimgoTorRedirectsChecks = () => rimgoTorRedirectsChecks; +function setRimgoTorRedirectsChecks(val) { + rimgoTorRedirectsChecks = val; + browser.storage.local.set({ rimgoTorRedirectsChecks }) + console.log("rimgoTorRedirectsChecks: ", val) +} + let rimgoNormalCustomRedirects = []; const getRimgoNormalCustomRedirects = () => rimgoNormalCustomRedirects; function setRimgoNormalCustomRedirects(val) { @@ -61,6 +67,14 @@ function setRimgoNormalCustomRedirects(val) { console.log("rimgoNormalCustomRedirects: ", val) } +let rimgoTorCustomRedirects = []; +const getRimgoTorCustomRedirects = () => rimgoTorCustomRedirects; +function setRimgoTorCustomRedirects(val) { + rimgoTorCustomRedirects = val; + browser.storage.local.set({ rimgoTorCustomRedirects }) + console.log("rimgoTorCustomRedirects: ", val) +} + let disable; const getDisable = () => disable; function setDisable(val) { @@ -68,6 +82,14 @@ function setDisable(val) { browser.storage.local.set({ disableImgur: disable }) } +let protocol; +const getProtocol = () => protocol; +function setProtocol(val) { + protocol = val; + browser.storage.local.set({ imgurProtocol: val }) + console.log("imgurProtocol: ", val) +} + function isImgur(url, initiator) { if (disable) return false; if (url.pathname == "/") return false; @@ -85,9 +107,11 @@ function redirect(url, type) { // https://imgur.com/gallery/cTRwaJU // https://i.imgur.com/CFSQArP.jpeg - if (type != "main_frame" && "sub_frame" && "xmlhttprequest" && "other") return null; + if (type != "main_frame" && type != "sub_frame" && type != "xmlhttprequest" && type != "other") return null; - let instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects]; + let instancesList; + if (protocol == 'normal') instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects]; + if (protocol == 'tor') instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects]; if (instancesList.length === 0) return null; let randomInstance = commonHelper.getRandomInstance(instancesList) @@ -96,24 +120,38 @@ function redirect(url, type) { async function init() { return new Promise((resolve) => { - browser.storage.local.get( - [ - "disableImgur", - "imgurRedirects", - "rimgoNormalRedirectsChecks", - "rimgoNormalCustomRedirects", - ], - (result) => { - disable = result.disableImgur ?? false; - - if (result.imgurRedirects) redirects = result.imgurRedirects; - - rimgoNormalRedirectsChecks = result.rimgoNormalRedirectsChecks ?? [...redirects.rimgo.normal]; - rimgoNormalCustomRedirects = result.rimgoNormalCustomRedirects ?? []; - - resolve(); - } - ) + fetch('/instances/data.json').then(response => response.text()).then(data => { + let dataJson = JSON.parse(data); + browser.storage.local.get( + [ + "disableImgur", + "imgurRedirects", + + "rimgoNormalRedirectsChecks", + "rimgoNormalCustomRedirects", + "rimgoTorRedirectsChecks", + "rimgoTorCustomRedirects", + + "imgurProtocol", + ], + (result) => { + disable = result.disableImgur ?? false; + + protocol = result.imgurProtocol ?? "normal"; + + redirects.rimgo = dataJson.rimgo; + if (result.imgurRedirects) redirects = result.imgurRedirects; + + rimgoNormalRedirectsChecks = result.rimgoNormalRedirectsChecks ?? [...redirects.rimgo.normal]; + rimgoNormalCustomRedirects = result.rimgoNormalCustomRedirects ?? []; + + rimgoTorRedirectsChecks = result.rimgoTorRedirectsChecks ?? [...redirects.rimgo.tor]; + rimgoTorCustomRedirects = result.rimgoTorCustomRedirects ?? []; + + resolve(); + } + ) + }); }); } @@ -125,11 +163,18 @@ export default { getDisable, setDisable, + getProtocol, + setProtocol, + getRimgoNormalRedirectsChecks, setRimgoNormalRedirectsChecks, + getRimgoTorRedirectsChecks, + setRimgoTorRedirectsChecks, getRimgoNormalCustomRedirects, setRimgoNormalCustomRedirects, + getRimgoTorCustomRedirects, + setRimgoTorCustomRedirects, redirect, isImgur, diff --git a/src/assets/javascripts/helpers/instagram.js b/src/assets/javascripts/helpers/instagram.js index 3145fb65..9aeeebc0 100644 --- a/src/assets/javascripts/helpers/instagram.js +++ b/src/assets/javascripts/helpers/instagram.js @@ -150,7 +150,7 @@ async function init() { "bibliogramNormalCustomRedirects", "bibliogramTorCustomRedirects", - "bibliogramProtocol" + "instagramProtocol" ], (result) => { disable = result.disableInstagram ?? false; @@ -165,7 +165,7 @@ async function init() { bibliogramTorRedirectsChecks = result.bibliogramTorRedirectsChecks ?? [...redirects.bibliogram.tor]; bibliogramTorCustomRedirects = result.bibliogramTorCustomRedirects ?? []; - protocol = result.bibliogramProtocol ?? "normal"; + protocol = result.instagramProtocol ?? "normal"; resolve(); } diff --git a/src/assets/javascripts/helpers/tiktok.js b/src/assets/javascripts/helpers/tiktok.js index 1ad35be9..fe0c31e0 100644 --- a/src/assets/javascripts/helpers/tiktok.js +++ b/src/assets/javascripts/helpers/tiktok.js @@ -9,8 +9,9 @@ const targets = [ let redirects = { "proxiTok": { "normal": [ - "https://proxitok.herokuapp.com", - ] + "https://proxitok.herokuapp.com" + ], + "tor": [] } } @@ -33,6 +34,13 @@ function setRedirects(val) { if (index !== -1) proxiTokNormalRedirectsChecks.splice(index, 1); } setProxiTokNormalRedirectsChecks(proxiTokNormalRedirectsChecks); + + for (const item of proxiTokTorRedirectsChecks) + if (!redirects.proxiTok.normal.includes(item)) { + var index = proxiTokTorRedirectsChecks.indexOf(item); + if (index !== -1) proxiTokTorRedirectsChecks.splice(index, 1); + } + setProxiTokTorRedirectsChecks(proxiTokTorRedirectsChecks); } let proxiTokNormalRedirectsChecks; @@ -43,6 +51,14 @@ function setProxiTokNormalRedirectsChecks(val) { console.log("proxiTokNormalRedirectsChecks: ", val) } +let proxiTokTorRedirectsChecks; +const getProxiTokTorRedirectsChecks = () => proxiTokTorRedirectsChecks; +function setProxiTokTorRedirectsChecks(val) { + proxiTokTorRedirectsChecks = val; + browser.storage.local.set({ proxiTokTorRedirectsChecks }) + console.log("proxiTokTorRedirectsChecks: ", val) +} + let proxiTokNormalCustomRedirects = []; const getProxiTokNormalCustomRedirects = () => proxiTokNormalCustomRedirects; function setProxiTokNormalCustomRedirects(val) { @@ -51,6 +67,14 @@ function setProxiTokNormalCustomRedirects(val) { console.log("proxiTokNormalCustomRedirects: ", val) } +let proxiTokTorCustomRedirects = []; +const getProxiTokTorCustomRedirects = () => proxiTokTorCustomRedirects; +function setProxiTokTorCustomRedirects(val) { + proxiTokTorCustomRedirects = val; + browser.storage.local.set({ proxiTokTorCustomRedirects }) + console.log("proxiTokTorCustomRedirects: ", val) +} + let disable; const getDisable = () => disable; function setDisable(val) { @@ -58,6 +82,14 @@ function setDisable(val) { browser.storage.local.set({ disableTiktok: disable }) } +let protocol; +const getProtocol = () => protocol; +function setProtocol(val) { + protocol = val; + browser.storage.local.set({ tiktokProtocol: val }) + console.log("tiktokProtocol: ", val) +} + function isTiktok(url, initiator) { if (disable) return false; if (initiator && ([...redirects.proxiTok.normal, ...proxiTokNormalCustomRedirects].includes(initiator.origin) || targets.includes(initiator.host))) return false; @@ -70,7 +102,9 @@ function redirect(url, type) { if (type != "main_frame" && "sub_frame" && "xmlhttprequest") return null; - let instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]; + let instancesList; + if (protocol == 'normal') instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]; + if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]; if (instancesList.length === 0) return null; let randomInstance = commonHelper.getRandomInstance(instancesList); @@ -81,25 +115,39 @@ function redirect(url, type) { async function init() { return new Promise((resolve) => { - browser.storage.local.get( - [ - "disableTiktok", - "tiktokRedirects", - "proxiTokNormalRedirectsChecks", - "proxiTokNormalCustomRedirects", - ], - (result) => { - disable = result.disableTiktok ?? false; - - if (result.tiktokRedirects) redirects = result.tiktokRedirects; - - proxiTokNormalRedirectsChecks = result.proxiTokNormalRedirectsChecks ?? [...redirects.proxiTok.normal]; - proxiTokNormalCustomRedirects = result.proxiTokNormalCustomRedirects ?? []; - - resolve(); - } - ) - }) + fetch('/instances/data.json').then(response => response.text()).then(data => { + let dataJson = JSON.parse(data); + browser.storage.local.get( + [ + "disableTiktok", + "tiktokRedirects", + + "proxiTokNormalRedirectsChecks", + "proxiTokNormalCustomRedirects", + + "proxiTokTorRedirectsChecks", + "proxiTokTorCustomRedirects", + + "tiktokProtocol" + ], + (result) => { + disable = result.disableTiktok ?? false; + + protocol = result.tiktokProtocol ?? "normal"; + + if (result.tiktokRedirects) redirects = result.tiktokRedirects; + + proxiTokNormalRedirectsChecks = result.proxiTokNormalRedirectsChecks ?? [...redirects.proxiTok.normal]; + proxiTokNormalCustomRedirects = result.proxiTokNormalCustomRedirects ?? []; + + proxiTokTorRedirectsChecks = result.proxiTokTorRedirectsChecks ?? [...redirects.proxiTok.tor]; + proxiTokTorCustomRedirects = result.proxiTokTorCustomRedirects ?? []; + + resolve(); + } + ) + }); + }); } export default { @@ -111,9 +159,16 @@ export default { getDisable, setDisable, + getProtocol, + setProtocol, + getProxiTokNormalRedirectsChecks, setProxiTokNormalRedirectsChecks, + getProxiTokTorRedirectsChecks, + setProxiTokTorRedirectsChecks, + getProxiTokTorCustomRedirects, + setProxiTokTorCustomRedirects, getProxiTokNormalCustomRedirects, setProxiTokNormalCustomRedirects, diff --git a/src/assets/javascripts/helpers/twitter.js b/src/assets/javascripts/helpers/twitter.js index a1b9979b..3757edc4 100644 --- a/src/assets/javascripts/helpers/twitter.js +++ b/src/assets/javascripts/helpers/twitter.js @@ -91,8 +91,8 @@ let protocol; const getProtocol = () => protocol; function setProtocol(val) { protocol = val; - browser.storage.local.set({ nitterProtocol: val }) - console.log("nitterProtocol: ", val) + browser.storage.local.set({ twitterProtocol: val }) + console.log("twitterProtocol: ", val) } function isTwitter(url, initiator) { @@ -144,12 +144,12 @@ async function init() { "nitterNormalCustomRedirects", "nitterTorRedirectsChecks", "nitterTorCustomRedirects", - "nitterProtocol", + "twitterProtocol", ], (result) => { disable = result.disableTwitter ?? false; - protocol = result.nitterProtocol ?? "normal"; + protocol = result.twitterProtocol ?? "normal"; redirects.nitter = dataJson.nitter; if (result.twitterRedirects) redirects = result.twitterRedirects; diff --git a/src/pages/options/imgur/imgur.html b/src/pages/options/imgur/imgur.html index 405cf6a1..5418cb05 100644 --- a/src/pages/options/imgur/imgur.html +++ b/src/pages/options/imgur/imgur.html @@ -2,146 +2,177 @@ <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.0"> - <link rel="icon" type="image/x-icon" href="../../../assets/images/libredirect.svg" /> - <link href="../../stylesheets/styles.css" rel="stylesheet" /> - <title>LibRedirect Options: Imgur</title> + <meta charset="UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="icon" type="image/x-icon" href="../../../assets/images/libredirect.svg" /> + <link href="../../stylesheets/styles.css" rel="stylesheet" /> + <title>LibRedirect Options: Imgur</title> </head> <body class="option"> - <section class="links"> - <div class="title"> - <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> - <path d="M0 0h24v24H0V0z" fill="none" /> - <path d="M12 5.69l5 4.5V18h-2v-6H9v6H7v-7.81l5-4.5M12 3L2 12h3v8h6v-6h2v6h6v-8h3L12 3z" /> - </svg> - <a href="../general/general.html">General</a> - </div> - <div class="title"> - <img src="../../../assets/images/youtube-icon.png" /> - <a href="../youtube/youtube.html">YouTube</a> - </div> - <div class="title"> - <img src="../../../assets/images/twitter-icon.png" /> - <a href="../twitter/twitter.html">Twitter</a> - </div> - <div class="title"> - <img src="../../../assets/images/instagram-icon.png" /> - <a href="../instagram/instagram.html">Instagram</a> - </div> - <div class="title"> - <img src="../../../assets/images/tiktok-icon.png" /> - <a href="../tiktok/tiktok.html">TikTok</a> - </div> - <div class="title"> - <img src="../../../assets/images/reddit-icon.png" /> - <a href="../reddit/reddit.html">Reddit</a> - </div> - <div class="title"> - <img src="../../../assets/images/imgur-icon.png" /> - <a href="../imgur/imgur.html" class="selected">Imgur</a> - </div> - <div class="title"> - <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"> - <path d="M0 0h24v24H0V0z" fill="none" /> - <path - d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" /> - </svg> - <a href="../search/search.html">Search</a> - </div> - <div class="title"> - <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> - <path d="M0 0h24v24H0V0z" fill="none" /> - <path - d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z" /> - </svg> - <a href="../translate/translate.html">Translate</a> - </div> - <div class="title"> - <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> - <path d="M0 0h24v24H0V0z" fill="none" /> + <section class="links"> + <div class="title"> + <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> + <path d="M0 0h24v24H0V0z" fill="none" /> + <path d="M12 5.69l5 4.5V18h-2v-6H9v6H7v-7.81l5-4.5M12 3L2 12h3v8h6v-6h2v6h6v-8h3L12 3z" /> + </svg> + <a href="../general/general.html">General</a> + </div> + <div class="title"> + <img src="../../../assets/images/youtube-icon.png" /> + <a href="../youtube/youtube.html">YouTube</a> + </div> + <div class="title"> + <img src="../../../assets/images/twitter-icon.png" /> + <a href="../twitter/twitter.html">Twitter</a> + </div> + <div class="title"> + <img src="../../../assets/images/instagram-icon.png" /> + <a href="../instagram/instagram.html">Instagram</a> + </div> + <div class="title"> + <img src="../../../assets/images/tiktok-icon.png" /> + <a href="../tiktok/tiktok.html">TikTok</a> + </div> + <div class="title"> + <img src="../../../assets/images/reddit-icon.png" /> + <a href="../reddit/reddit.html">Reddit</a> + </div> + <div class="title"> + <img src="../../../assets/images/imgur-icon.png" /> + <a href="../imgur/imgur.html" class="selected">Imgur</a> + </div> + <div class="title"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"> + <path d="M0 0h24v24H0V0z" fill="none" /> + <path + d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" /> + </svg> + <a href="../search/search.html">Search</a> + </div> + <div class="title"> + <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> + <path d="M0 0h24v24H0V0z" fill="none" /> + <path + d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z" /> + </svg> + <a href="../translate/translate.html">Translate</a> + </div> + <div class="title"> + <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> + <path d="M0 0h24v24H0V0z" fill="none" /> + <path + d="M20.5 3l-.16.03L15 5.1 9 3 3.36 4.9c-.21.07-.36.25-.36.48V20.5c0 .28.22.5.5.5l.16-.03L9 18.9l6 2.1 5.64-1.9c.21-.07.36-.25.36-.48V3.5c0-.28-.22-.5-.5-.5zM10 5.47l4 1.4v11.66l-4-1.4V5.47zm-5 .99l3-1.01v11.7l-3 1.16V6.46zm14 11.08l-3 1.01V6.86l3-1.16v11.84z" /> + </svg> + <a href="../maps/maps.html">Maps</a> + </div> + <div class="title"> + <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" + width="24px" fill="currentColor"> + <g> + <rect fill="none" height="24" width="24" /> + </g> + <g> + <g /> + <g> <path - d="M20.5 3l-.16.03L15 5.1 9 3 3.36 4.9c-.21.07-.36.25-.36.48V20.5c0 .28.22.5.5.5l.16-.03L9 18.9l6 2.1 5.64-1.9c.21-.07.36-.25.36-.48V3.5c0-.28-.22-.5-.5-.5zM10 5.47l4 1.4v11.66l-4-1.4V5.47zm-5 .99l3-1.01v11.7l-3 1.16V6.46zm14 11.08l-3 1.01V6.86l3-1.16v11.84z" /> - </svg> - <a href="../maps/maps.html">Maps</a> - </div> - <div class="title"> - <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" - width="24px" fill="currentColor"> - <g> - <rect fill="none" height="24" width="24" /> - </g> - <g> - <g /> - <g> - <path - d="M21,5c-1.11-0.35-2.33-0.5-3.5-0.5c-1.95,0-4.05,0.4-5.5,1.5c-1.45-1.1-3.55-1.5-5.5-1.5S2.45,4.9,1,6v14.65 c0,0.25,0.25,0.5,0.5,0.5c0.1,0,0.15-0.05,0.25-0.05C3.1,20.45,5.05,20,6.5,20c1.95,0,4.05,0.4,5.5,1.5c1.35-0.85,3.8-1.5,5.5-1.5 c1.65,0,3.35,0.3,4.75,1.05c0.1,0.05,0.15,0.05,0.25,0.05c0.25,0,0.5-0.25,0.5-0.5V6C22.4,5.55,21.75,5.25,21,5z M21,18.5 c-1.1-0.35-2.3-0.5-3.5-0.5c-1.7,0-4.15,0.65-5.5,1.5V8c1.35-0.85,3.8-1.5,5.5-1.5c1.2,0,2.4,0.15,3.5,0.5V18.5z" /> - <g> - <path - d="M17.5,10.5c0.88,0,1.73,0.09,2.5,0.26V9.24C19.21,9.09,18.36,9,17.5,9c-1.7,0-3.24,0.29-4.5,0.83v1.66 C14.13,10.85,15.7,10.5,17.5,10.5z" /> - <path - d="M13,12.49v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26V11.9c-0.79-0.15-1.64-0.24-2.5-0.24 C15.8,11.66,14.26,11.96,13,12.49z" /> - <path - d="M17.5,14.33c-1.7,0-3.24,0.29-4.5,0.83v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26v-1.52 C19.21,14.41,18.36,14.33,17.5,14.33z" /> - </g> - </g> - </g> - </svg> - <a href="../wikipedia/wikipedia.html">Wikipedia</a> - </div> - <div class="title"> - <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" - width="24px" fill="currentColor"> + d="M21,5c-1.11-0.35-2.33-0.5-3.5-0.5c-1.95,0-4.05,0.4-5.5,1.5c-1.45-1.1-3.55-1.5-5.5-1.5S2.45,4.9,1,6v14.65 c0,0.25,0.25,0.5,0.5,0.5c0.1,0,0.15-0.05,0.25-0.05C3.1,20.45,5.05,20,6.5,20c1.95,0,4.05,0.4,5.5,1.5c1.35-0.85,3.8-1.5,5.5-1.5 c1.65,0,3.35,0.3,4.75,1.05c0.1,0.05,0.15,0.05,0.25,0.05c0.25,0,0.5-0.25,0.5-0.5V6C22.4,5.55,21.75,5.25,21,5z M21,18.5 c-1.1-0.35-2.3-0.5-3.5-0.5c-1.7,0-4.15,0.65-5.5,1.5V8c1.35-0.85,3.8-1.5,5.5-1.5c1.2,0,2.4,0.15,3.5,0.5V18.5z" /> <g> - <rect fill="none" height="24" width="24" /> - <g> - <path - d="M19,5v14H5V5H19 M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3L19,3z" /> - </g> - <path d="M14,17H7v-2h7V17z M17,13H7v-2h10V13z M17,9H7V7h10V9z" /> + <path + d="M17.5,10.5c0.88,0,1.73,0.09,2.5,0.26V9.24C19.21,9.09,18.36,9,17.5,9c-1.7,0-3.24,0.29-4.5,0.83v1.66 C14.13,10.85,15.7,10.5,17.5,10.5z" /> + <path + d="M13,12.49v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26V11.9c-0.79-0.15-1.64-0.24-2.5-0.24 C15.8,11.66,14.26,11.96,13,12.49z" /> + <path + d="M17.5,14.33c-1.7,0-3.24,0.29-4.5,0.83v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26v-1.52 C19.21,14.41,18.36,14.33,17.5,14.33z" /> </g> - </svg> - <a href="../medium/medium.html">Medium</a> - </div> - </section> + </g> + </g> + </svg> + <a href="../wikipedia/wikipedia.html">Wikipedia</a> + </div> + <div class="title"> + <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" + width="24px" fill="currentColor"> + <g> + <rect fill="none" height="24" width="24" /> + <g> + <path + d="M19,5v14H5V5H19 M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3L19,3z" /> + </g> + <path d="M14,17H7v-2h7V17z M17,13H7v-2h10V13z M17,9H7V7h10V9z" /> + </g> + </svg> + <a href="../medium/medium.html">Medium</a> + </div> + </section> - <section class="option-block"> - <div class="some-block option-block"> - <h4>Enable</h4> - <input id="disable-imgur" type="checkbox" checked /> - </div> + <section class="option-block"> + <div class="some-block option-block"> + <h4>Enable</h4> + <input id="disable-imgur" type="checkbox" checked /> + </div> + + <div class="some-block option-block"> + <h4>Protocol</h4> + <select id="protocol"> + <option value="normal">Normal</option> + <option value="tor">Tor</option> + </select> + </div> - <hr> + <hr> + <div id="normal"> + <div class="some-block option-block"> + <h4>Default Instances</h4> + </div> + <div class="checklist" id="rimgo-normal-checklist"></div> + <hr> + <div class="some-block option-block"> + <h4>Custom Instances</h4> + </div> + <form id="custom-rimgo-normal-instance-form"> <div class="some-block option-block"> - <h4>Default Instances</h4> + <input id="rimgo-normal-custom-instance" placeholder="https://rimgo.com" type="url" /> + <button type="submit" class="add" id="rimgo-normal-add-instance"> + <svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M0 0h24v24H0V0z" fill="none" /> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" /> + </svg> + </button> </div> - <div class="checklist" id="rimgo-normal-checklist"></div> - <hr> + </form> + <div class="checklist" id="rimgo-normal-custom-checklist"></div> + </div> + <div id="tor"> + <div class="some-block option-block"> + <h4>Default Instances</h4> + </div> + <div class="checklist" id="rimgo-tor-checklist"></div> + <hr> + <div class="some-block option-block"> + <h4>Custom Instances</h4> + </div> + <form id="custom-rimgo-tor-instance-form"> <div class="some-block option-block"> - <h4>Custom Instances</h4> + <input id="rimgo-tor-custom-instance" placeholder="https://rimgo.com" type="url" /> + <button type="submit" class="add" id="rimgo-tor-add-instance"> + <svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M0 0h24v24H0V0z" fill="none" /> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" /> + </svg> + </button> </div> - <form id="custom-rimgo-normal-instance-form"> - <div class="some-block option-block"> - <input id="rimgo-normal-custom-instance" placeholder="https://rimgo.com" type="url" /> - <button type="submit" class="add" id="rimgo-normal-add-instance"> - <svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" - fill="currentColor"> - <path d="M0 0h24v24H0V0z" fill="none" /> - <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" /> - </svg> - </button> - </div> - </form> - <div class="checklist" id="rimgo-normal-custom-checklist"></div> - </section> + </form> + <div class="checklist" id="rimgo-tor-custom-checklist"></div> + </div> + </section> - <script type="module" src="../init.js"></script> - <script type="module" src="./imgur.js"></script> - <!-- <script src="../../assets/javascripts/localise.js"></script> --> + <script type="module" src="../init.js"></script> + <script type="module" src="./imgur.js"></script> + <!-- <script src="../../assets/javascripts/localise.js"></script> --> </body> -</html> +</html> \ No newline at end of file diff --git a/src/pages/options/imgur/imgur.js b/src/pages/options/imgur/imgur.js index 2c190591..25fd8914 100644 --- a/src/pages/options/imgur/imgur.js +++ b/src/pages/options/imgur/imgur.js @@ -6,9 +6,35 @@ disableImgurElement.addEventListener("change", (event) => imgurHelper.setDisable(!event.target.checked) ); +let protocolElement = document.getElementById("protocol") +protocolElement.addEventListener("change", + (event) => { + let protocol = event.target.options[protocolElement.selectedIndex].value + imgurHelper.setProtocol(protocol); + changeProtocolSettings(protocol); + } +); + +function changeProtocolSettings(protocol) { + let normalDiv = document.getElementById("normal"); + let torDiv = document.getElementById("tor"); + if (protocol == 'normal') { + normalDiv.style.display = 'block'; + torDiv.style.display = 'none'; + } + else if (protocol == 'tor') { + normalDiv.style.display = 'none'; + torDiv.style.display = 'block'; + } +} + imgurHelper.init().then(() => { disableImgurElement.checked = !imgurHelper.getDisable(); + let protocol = imgurHelper.getProtocol(); + protocolElement.value = protocol; + changeProtocolSettings(protocol); + commonHelper.processDefaultCustomInstances( 'rimgo', 'normal', @@ -18,5 +44,16 @@ imgurHelper.init().then(() => { imgurHelper.setRimgoNormalRedirectsChecks, imgurHelper.getRimgoNormalCustomRedirects, imgurHelper.setRimgoNormalCustomRedirects - ) -}) \ No newline at end of file + ); + + commonHelper.processDefaultCustomInstances( + 'rimgo', + 'tor', + imgurHelper, + document, + imgurHelper.getRimgoTorRedirectsChecks, + imgurHelper.setRimgoTorRedirectsChecks, + imgurHelper.getRimgoTorCustomRedirects, + imgurHelper.setRimgoTorCustomRedirects + ); +}); \ No newline at end of file diff --git a/src/pages/options/tiktok/tiktok.html b/src/pages/options/tiktok/tiktok.html index 8bec525f..a0cb11cc 100644 --- a/src/pages/options/tiktok/tiktok.html +++ b/src/pages/options/tiktok/tiktok.html @@ -2,146 +2,177 @@ <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.0"> - <link rel="icon" type="image/x-icon" href="../../../assets/images/libredirect.svg" /> - <link href="../../stylesheets/styles.css" rel="stylesheet" /> - <title>LibRedirect Options: TikTok</title> + <meta charset="UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="icon" type="image/x-icon" href="../../../assets/images/libredirect.svg" /> + <link href="../../stylesheets/styles.css" rel="stylesheet" /> + <title>LibRedirect Options: TikTok</title> </head> <body class="option"> - <section class="links"> - <div class="title"> - <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> - <path d="M0 0h24v24H0V0z" fill="none" /> - <path d="M12 5.69l5 4.5V18h-2v-6H9v6H7v-7.81l5-4.5M12 3L2 12h3v8h6v-6h2v6h6v-8h3L12 3z" /> - </svg> - <a href="../general/general.html">General</a> - </div> - <div class="title"> - <img src="../../../assets/images/youtube-icon.png" /> - <a href="../youtube/youtube.html">YouTube</a> - </div> - <div class="title"> - <img src="../../../assets/images/twitter-icon.png" /> - <a href="../twitter/twitter.html">Twitter</a> - </div> - <div class="title"> - <img src="../../../assets/images/instagram-icon.png" /> - <a href="../instagram/instagram.html">Instagram</a> - </div> - <div class="title"> - <img src="../../../assets/images/tiktok-icon.png" /> - <a href="../tiktok/tiktok.html" class="selected">TikTok</a> - </div> - <div class="title"> - <img src="../../../assets/images/reddit-icon.png" /> - <a href="../reddit/reddit.html">Reddit</a> - </div> - <div class="title"> - <img src="../../../assets/images/imgur-icon.png" /> - <a href="../imgur/imgur.html">Imgur</a> - </div> - <div class="title"> - <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"> - <path d="M0 0h24v24H0V0z" fill="none" /> - <path - d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" /> - </svg> - <a href="../search/search.html">Search</a> - </div> - <div class="title"> - <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> - <path d="M0 0h24v24H0V0z" fill="none" /> - <path - d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z" /> - </svg> - <a href="../translate/translate.html">Translate</a> - </div> - <div class="title"> - <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> - <path d="M0 0h24v24H0V0z" fill="none" /> + <section class="links"> + <div class="title"> + <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> + <path d="M0 0h24v24H0V0z" fill="none" /> + <path d="M12 5.69l5 4.5V18h-2v-6H9v6H7v-7.81l5-4.5M12 3L2 12h3v8h6v-6h2v6h6v-8h3L12 3z" /> + </svg> + <a href="../general/general.html">General</a> + </div> + <div class="title"> + <img src="../../../assets/images/youtube-icon.png" /> + <a href="../youtube/youtube.html">YouTube</a> + </div> + <div class="title"> + <img src="../../../assets/images/twitter-icon.png" /> + <a href="../twitter/twitter.html">Twitter</a> + </div> + <div class="title"> + <img src="../../../assets/images/instagram-icon.png" /> + <a href="../instagram/instagram.html">Instagram</a> + </div> + <div class="title"> + <img src="../../../assets/images/tiktok-icon.png" /> + <a href="../tiktok/tiktok.html" class="selected">TikTok</a> + </div> + <div class="title"> + <img src="../../../assets/images/reddit-icon.png" /> + <a href="../reddit/reddit.html">Reddit</a> + </div> + <div class="title"> + <img src="../../../assets/images/imgur-icon.png" /> + <a href="../imgur/imgur.html">Imgur</a> + </div> + <div class="title"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"> + <path d="M0 0h24v24H0V0z" fill="none" /> + <path + d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" /> + </svg> + <a href="../search/search.html">Search</a> + </div> + <div class="title"> + <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> + <path d="M0 0h24v24H0V0z" fill="none" /> + <path + d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z" /> + </svg> + <a href="../translate/translate.html">Translate</a> + </div> + <div class="title"> + <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> + <path d="M0 0h24v24H0V0z" fill="none" /> + <path + d="M20.5 3l-.16.03L15 5.1 9 3 3.36 4.9c-.21.07-.36.25-.36.48V20.5c0 .28.22.5.5.5l.16-.03L9 18.9l6 2.1 5.64-1.9c.21-.07.36-.25.36-.48V3.5c0-.28-.22-.5-.5-.5zM10 5.47l4 1.4v11.66l-4-1.4V5.47zm-5 .99l3-1.01v11.7l-3 1.16V6.46zm14 11.08l-3 1.01V6.86l3-1.16v11.84z" /> + </svg> + <a href="../maps/maps.html">Maps</a> + </div> + <div class="title"> + <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" + width="24px" fill="currentColor"> + <g> + <rect fill="none" height="24" width="24" /> + </g> + <g> + <g /> + <g> <path - d="M20.5 3l-.16.03L15 5.1 9 3 3.36 4.9c-.21.07-.36.25-.36.48V20.5c0 .28.22.5.5.5l.16-.03L9 18.9l6 2.1 5.64-1.9c.21-.07.36-.25.36-.48V3.5c0-.28-.22-.5-.5-.5zM10 5.47l4 1.4v11.66l-4-1.4V5.47zm-5 .99l3-1.01v11.7l-3 1.16V6.46zm14 11.08l-3 1.01V6.86l3-1.16v11.84z" /> - </svg> - <a href="../maps/maps.html">Maps</a> - </div> - <div class="title"> - <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" - width="24px" fill="currentColor"> - <g> - <rect fill="none" height="24" width="24" /> - </g> - <g> - <g /> - <g> - <path - d="M21,5c-1.11-0.35-2.33-0.5-3.5-0.5c-1.95,0-4.05,0.4-5.5,1.5c-1.45-1.1-3.55-1.5-5.5-1.5S2.45,4.9,1,6v14.65 c0,0.25,0.25,0.5,0.5,0.5c0.1,0,0.15-0.05,0.25-0.05C3.1,20.45,5.05,20,6.5,20c1.95,0,4.05,0.4,5.5,1.5c1.35-0.85,3.8-1.5,5.5-1.5 c1.65,0,3.35,0.3,4.75,1.05c0.1,0.05,0.15,0.05,0.25,0.05c0.25,0,0.5-0.25,0.5-0.5V6C22.4,5.55,21.75,5.25,21,5z M21,18.5 c-1.1-0.35-2.3-0.5-3.5-0.5c-1.7,0-4.15,0.65-5.5,1.5V8c1.35-0.85,3.8-1.5,5.5-1.5c1.2,0,2.4,0.15,3.5,0.5V18.5z" /> - <g> - <path - d="M17.5,10.5c0.88,0,1.73,0.09,2.5,0.26V9.24C19.21,9.09,18.36,9,17.5,9c-1.7,0-3.24,0.29-4.5,0.83v1.66 C14.13,10.85,15.7,10.5,17.5,10.5z" /> - <path - d="M13,12.49v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26V11.9c-0.79-0.15-1.64-0.24-2.5-0.24 C15.8,11.66,14.26,11.96,13,12.49z" /> - <path - d="M17.5,14.33c-1.7,0-3.24,0.29-4.5,0.83v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26v-1.52 C19.21,14.41,18.36,14.33,17.5,14.33z" /> - </g> - </g> - </g> - </svg> - <a href="../wikipedia/wikipedia.html">Wikipedia</a> - </div> - <div class="title"> - <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" - width="24px" fill="currentColor"> + d="M21,5c-1.11-0.35-2.33-0.5-3.5-0.5c-1.95,0-4.05,0.4-5.5,1.5c-1.45-1.1-3.55-1.5-5.5-1.5S2.45,4.9,1,6v14.65 c0,0.25,0.25,0.5,0.5,0.5c0.1,0,0.15-0.05,0.25-0.05C3.1,20.45,5.05,20,6.5,20c1.95,0,4.05,0.4,5.5,1.5c1.35-0.85,3.8-1.5,5.5-1.5 c1.65,0,3.35,0.3,4.75,1.05c0.1,0.05,0.15,0.05,0.25,0.05c0.25,0,0.5-0.25,0.5-0.5V6C22.4,5.55,21.75,5.25,21,5z M21,18.5 c-1.1-0.35-2.3-0.5-3.5-0.5c-1.7,0-4.15,0.65-5.5,1.5V8c1.35-0.85,3.8-1.5,5.5-1.5c1.2,0,2.4,0.15,3.5,0.5V18.5z" /> <g> - <rect fill="none" height="24" width="24" /> - <g> - <path - d="M19,5v14H5V5H19 M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3L19,3z" /> - </g> - <path d="M14,17H7v-2h7V17z M17,13H7v-2h10V13z M17,9H7V7h10V9z" /> + <path + d="M17.5,10.5c0.88,0,1.73,0.09,2.5,0.26V9.24C19.21,9.09,18.36,9,17.5,9c-1.7,0-3.24,0.29-4.5,0.83v1.66 C14.13,10.85,15.7,10.5,17.5,10.5z" /> + <path + d="M13,12.49v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26V11.9c-0.79-0.15-1.64-0.24-2.5-0.24 C15.8,11.66,14.26,11.96,13,12.49z" /> + <path + d="M17.5,14.33c-1.7,0-3.24,0.29-4.5,0.83v1.66c1.13-0.64,2.7-0.99,4.5-0.99c0.88,0,1.73,0.09,2.5,0.26v-1.52 C19.21,14.41,18.36,14.33,17.5,14.33z" /> </g> - </svg> - <a href="../medium/medium.html">Medium</a> - </div> - </section> + </g> + </g> + </svg> + <a href="../wikipedia/wikipedia.html">Wikipedia</a> + </div> + <div class="title"> + <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" + width="24px" fill="currentColor"> + <g> + <rect fill="none" height="24" width="24" /> + <g> + <path + d="M19,5v14H5V5H19 M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3L19,3z" /> + </g> + <path d="M14,17H7v-2h7V17z M17,13H7v-2h10V13z M17,9H7V7h10V9z" /> + </g> + </svg> + <a href="../medium/medium.html">Medium</a> + </div> + </section> - <section class="option-block"> - <div class="some-block option-block"> - <h4>Enable</h4> - <input id="disable-tiktok" type="checkbox" checked /> - </div> + <section class="option-block"> + <div class="some-block option-block"> + <h4>Enable</h4> + <input id="disable-tiktok" type="checkbox" checked /> + </div> + + <div class="some-block option-block"> + <h4>Protocol</h4> + <select id="protocol"> + <option value="normal">Normal</option> + <option value="tor">Tor</option> + </select> + </div> - <hr> + <hr> + <div id="normal"> + <div class="some-block option-block"> + <h4>Default Instances</h4> + </div> + <div class="checklist" id="proxiTok-normal-checklist"></div> + <hr> + <div class="some-block option-block"> + <h4>Custom Instances</h4> + </div> + <form id="custom-proxiTok-normal-instance-form"> <div class="some-block option-block"> - <h4>Default Instances</h4> + <input id="proxiTok-normal-custom-instance" placeholder="https://proxiTok.com" type="url" /> + <button type="submit" class="add" id="proxiTok-normal-add-instance"> + <svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M0 0h24v24H0V0z" fill="none" /> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" /> + </svg> + </button> </div> - <div class="checklist" id="proxiTok-normal-checklist"></div> - <hr> + </form> + <div class="checklist" id="proxiTok-normal-custom-checklist"></div> + </div> + <div id="tor"> + <div class="some-block option-block"> + <h4>Default Instances</h4> + </div> + <div class="checklist" id="proxiTok-tor-checklist"></div> + <hr> + <div class="some-block option-block"> + <h4>Custom Instances</h4> + </div> + <form id="custom-proxiTok-tor-instance-form"> <div class="some-block option-block"> - <h4>Custom Instances</h4> + <input id="proxiTok-tor-custom-instance" placeholder="https://proxiTok.com" type="url" /> + <button type="submit" class="add" id="proxiTok-tor-add-instance"> + <svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M0 0h24v24H0V0z" fill="none" /> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" /> + </svg> + </button> </div> - <form id="custom-proxiTok-normal-instance-form"> - <div class="some-block option-block"> - <input id="proxiTok-normal-custom-instance" placeholder="https://proxiTok.com" type="url" /> - <button type="submit" class="add" id="proxiTok-normal-add-instance"> - <svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" - fill="currentColor"> - <path d="M0 0h24v24H0V0z" fill="none" /> - <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" /> - </svg> - </button> - </div> - </form> - <div class="checklist" id="proxiTok-normal-custom-checklist"></div> - </section> + </form> + <div class="checklist" id="proxiTok-tor-custom-checklist"></div> + </div> + </section> - <script type="module" src="../init.js"></script> - <script type="module" src="./tiktok.js"></script> - <!-- <script src="../../assets/javascripts/localise.js"></script> --> + <script type="module" src="../init.js"></script> + <script type="module" src="./tiktok.js"></script> + <!-- <script src="../../assets/javascripts/localise.js"></script> --> </body> -</html> +</html> \ No newline at end of file diff --git a/src/pages/options/tiktok/tiktok.js b/src/pages/options/tiktok/tiktok.js index d66d0453..13de04d8 100644 --- a/src/pages/options/tiktok/tiktok.js +++ b/src/pages/options/tiktok/tiktok.js @@ -6,9 +6,35 @@ disableTiktokElement.addEventListener("change", (event) => tiktokHelper.setDisable(!event.target.checked) ); +let protocolElement = document.getElementById("protocol") +protocolElement.addEventListener("change", + (event) => { + let protocol = event.target.options[protocolElement.selectedIndex].value + tiktokHelper.setProtocol(protocol); + changeProtocolSettings(protocol); + } +); + +function changeProtocolSettings(protocol) { + let normalDiv = document.getElementById("normal"); + let torDiv = document.getElementById("tor"); + if (protocol == 'normal') { + normalDiv.style.display = 'block'; + torDiv.style.display = 'none'; + } + else if (protocol == 'tor') { + normalDiv.style.display = 'none'; + torDiv.style.display = 'block'; + } +} + tiktokHelper.init().then(() => { disableTiktokElement.checked = !tiktokHelper.getDisable(); + let protocol = tiktokHelper.getProtocol(); + protocolElement.value = protocol; + changeProtocolSettings(protocol); + commonHelper.processDefaultCustomInstances( 'proxiTok', 'normal', @@ -18,5 +44,16 @@ tiktokHelper.init().then(() => { tiktokHelper.setProxiTokNormalRedirectsChecks, tiktokHelper.getProxiTokNormalCustomRedirects, tiktokHelper.setProxiTokNormalCustomRedirects + ); + + commonHelper.processDefaultCustomInstances( + 'proxiTok', + 'tor', + tiktokHelper, + document, + tiktokHelper.getProxiTokTorRedirectsChecks, + tiktokHelper.setProxiTokTorRedirectsChecks, + tiktokHelper.getProxiTokTorCustomRedirects, + tiktokHelper.setProxiTokTorCustomRedirects ) }) \ No newline at end of file |