aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2022-02-10 00:04:00 +0300
committerManeraKai <manerakai@protonmail.com>2022-02-10 00:04:00 +0300
commit23ae536550334a359b1472a5afb2616815390c92 (patch)
tree6d7d3a30dc53d724e803d018c7cd5f855358f4c0
parentStricting targets #21 (diff)
downloadlibredirect-23ae536550334a359b1472a5afb2616815390c92.zip
Added ProxiTok #22
Diffstat (limited to '')
-rw-r--r--src/assets/javascripts/helpers/search.js94
-rw-r--r--src/assets/javascripts/helpers/tiktok.js107
-rw-r--r--src/pages/background/background.js4
-rw-r--r--src/pages/popup/popup.html5
-rw-r--r--src/pages/popup/popup.js8
5 files changed, 213 insertions, 5 deletions
diff --git a/src/assets/javascripts/helpers/search.js b/src/assets/javascripts/helpers/search.js
index a51361eb..c48a0edb 100644
--- a/src/assets/javascripts/helpers/search.js
+++ b/src/assets/javascripts/helpers/search.js
@@ -1,18 +1,102 @@
import commonHelper from './common.js'
const targets = [
- /https?:\/\/(www\.|maps\.|search\.|)google\.com(\/search\?q=..*|\/$|)/,
+ /https?:\/\/(www\.|maps\.|search\.|)google\.com(\/search\?q=..*|\/$)/,
];
let redirects = {
"searx": {
"normal": [
- "https://a.searx.space",
"https://anon.sx",
- "https://beezboo.com",
"https://darmarit.org/searx",
"https://dynabyte.ca",
"https://engo.mint.lgbt",
-
+ "https://jsearch.pw",
+ "https://metasearch.nl",
+ "https://nibblehole.com",
+ "https://northboot.xyz",
+ "https://paulgo.io",
+ "https://procurx.pt",
+ "https://s.zhaocloud.net",
+ "https://search.antonkling.se",
+ "https://search.asynchronousexchange.com",
+ "https://search.biboumail.fr",
+ "https://search.bus-hit.me",
+ "https://search.disroot.org",
+ "https://search.ethibox.fr",
+ "https://search.jpope.org",
+ "https://search.mdosch.de",
+ "https://search.neet.works",
+ "https://search.ononoki.org",
+ "https://search.snopyta.org",
+ "https://search.st8.at",
+ "https://search.stinpriza.org",
+ "https://search.trom.tf",
+ "https://search.zdechov.net",
+ "https://searx-private-search.de",
+ "https://searx.bar",
+ "https://searx.be",
+ "https://searx.bissisoft.com",
+ "https://searx.divided-by-zero.eu",
+ "https://searx.dresden.network",
+ "https://searx.esmailelbob.xyz",
+ "https://searx.everdot.org",
+ "https://searx.fmac.xyz",
+ "https://searx.fossencdi.org",
+ "https://searx.gnous.eu",
+ "https://searx.gnu.style",
+ "https://searx.hardwired.link",
+ "https://searx.hummel-web.at",
+ "https://searx.lavatech.top",
+ "https://searx.mastodontech.de",
+ "https://searx.mha.fi",
+ "https://searx.mxchange.org",
+ "https://searx.nakhan.net",
+ "https://searx.netzspielplatz.de",
+ "https://searx.nevrlands.de",
+ "https://searx.ninja",
+ "https://searx.nixnet.services",
+ "https://searx.openhoofd.nl",
+ "https://searx.operationtulip.com",
+ "https://searx.org",
+ "https://searx.prvcy.eu",
+ "https://searx.pwoss.org",
+ "https://searx.rasp.fr",
+ "https://searx.roughs.ru",
+ "https://searx.ru",
+ "https://searx.run",
+ "https://searx.sadblog.xyz",
+ "https://searx.semipvt.com",
+ "https://searx.slash-dev.de",
+ "https://searx.solusar.de",
+ "https://searx.sp-codes.de",
+ "https://searx.stuehieyr.com",
+ "https://searx.theanonymouse.xyz",
+ "https://searx.thegreenwebfoundation.org",
+ "https://searx.tiekoetter.com",
+ "https://searx.tk",
+ "https://searx.tux.land",
+ "https://searx.tuxcloud.net",
+ "https://searx.tyil.nl",
+ "https://searx.vitanetworks.link",
+ "https://searx.webheberg.info",
+ "https://searx.xkek.net",
+ "https://searx.xyz",
+ "https://searx.zackptg5.com",
+ "https://searx.zapashcanon.fr",
+ "https://searx.zecircle.xyz",
+ "https://serx.cf",
+ "https://spot.ecloud.global",
+ "https://suche.dasnetzundich.de",
+ "https://suche.uferwerk.org",
+ "https://swag.pw",
+ "https://sx.catgirl.cloud",
+ "https://sx.fedi.tech",
+ "https://timdor.noip.me/searx",
+ "https://trovu.komun.org",
+ "https://www.gruble.de",
+ "https://www.webrats.xyz",
+ "https://xeek.com",
+ "https://searx.roflcopter.fr",
],
"onion": [
"http://3afisqjw2rxm6z7mmstyt5rx75qfqrgxnkzftknbp2vhipr2nrmrjdyd.onion",
@@ -145,7 +229,7 @@ function redirect(url, initiator) {
}
let searchQuery = "";
- url.search.slice(1).split("&").forEach(function (input) {
+ url.search.slice(1).split("&").forEach((input) => {
if (input.startsWith("q=")) searchQuery = input;
});
return `${randomInstance}${path}?${searchQuery}`;
diff --git a/src/assets/javascripts/helpers/tiktok.js b/src/assets/javascripts/helpers/tiktok.js
new file mode 100644
index 00000000..c2eb2fb6
--- /dev/null
+++ b/src/assets/javascripts/helpers/tiktok.js
@@ -0,0 +1,107 @@
+import commonHelper from './common.js'
+
+const targets = [
+ /^https?:\/\/(www\.|)tiktok\.com.*/
+];
+
+let redirects = {
+ "proxiTok": {
+ "normal": [
+ "https://proxitok.herokuapp.com",
+ ]
+ }
+}
+
+const getRedirects = () => redirects;
+function setRedirects(val) {
+ redirects.proxiTok = val;
+ browser.storage.sync.set({ tiktokRedirects: redirects })
+ console.log("tiktokRedirects: ", val)
+ for (const item of proxiTokRedirectsChecks)
+ if (!redirects.proxiTok.normal.includes(item)) {
+ var index = proxiTokRedirectsChecks.indexOf(item);
+ if (index !== -1) proxiTokRedirectsChecks.splice(index, 1);
+ }
+ setProxiTokRedirectsChecks(proxiTokRedirectsChecks);
+}
+
+let proxiTokRedirectsChecks;
+const getProxiTokRedirectsChecks = () => proxiTokRedirectsChecks;
+function setProxiTokRedirectsChecks(val) {
+ proxiTokRedirectsChecks = val;
+ browser.storage.sync.set({ proxiTokRedirectsChecks })
+ console.log("proxiTokRedirectsChecks: ", val)
+}
+
+let proxiTokCustomRedirects = [];
+const getProxiTokCustomRedirects = () => proxiTokCustomRedirects;
+function setProxiTokCustomRedirects(val) {
+ proxiTokCustomRedirects = val;
+ browser.storage.sync.set({ proxiTokCustomRedirects })
+ console.log("proxiTokCustomRedirects: ", val)
+}
+
+let disableTiktok;
+const getDisableTiktok = () => disableTiktok;
+function setDisableTiktok(val) {
+ disableTiktok = val;
+ browser.storage.sync.set({ disableTiktok })
+}
+
+function redirect(url, initiator, type) {
+ // https://www.tiktok.com/@keysikaspol/video/7061265241887345946
+ // https://www.tiktok.com/@keysikaspol
+
+ if (disableTiktok) return null;
+
+ if (type != "main_frame" && "sub_frame" && "xmlhttprequest") return null;
+
+ let instancesList = [...proxiTokRedirectsChecks, ...proxiTokCustomRedirects];
+ if (instancesList.length === 0) return null;
+ let randomInstance = commonHelper.getRandomInstance(instancesList)
+
+ if (initiator && (instancesList.includes(initiator.origin) || targets.includes(initiator.host))) return null;
+
+ let pathName = url.pathname.replace(new RegExp(/@.*\/(?=video)/), "")
+
+ return `${randomInstance}${pathName}`;
+}
+
+function isTiktok(url) {
+ return targets.some((rx) => rx.test(url.href));
+}
+
+async function init() {
+ let result = await browser.storage.sync.get([
+ "disableTiktok",
+ "tiktokRedirects",
+ "proxiTokRedirectsChecks",
+ "proxiTokCustomRedirects",
+ ])
+ disableTiktok = result.disableTiktok ?? false;
+ if (result.tiktokRedirects)
+ redirects = result.tiktokRedirects;
+
+ proxiTokRedirectsChecks = result.proxiTokRedirectsChecks ?? [...redirects.proxiTok.normal];
+ proxiTokCustomRedirects = result.proxiTokCustomRedirects ?? [];
+}
+
+export default {
+ targets,
+
+ getRedirects,
+ setRedirects,
+
+ getDisableTiktok,
+ setDisableTiktok,
+
+ getProxiTokRedirectsChecks,
+ setProxiTokRedirectsChecks,
+
+ getProxiTokCustomRedirects,
+ setProxiTokCustomRedirects,
+
+ redirect,
+ isTiktok,
+ init,
+};
diff --git a/src/pages/background/background.js b/src/pages/background/background.js
index e9d2f395..140f1719 100644
--- a/src/pages/background/background.js
+++ b/src/pages/background/background.js
@@ -10,6 +10,7 @@ import mapsHelper from "../../assets/javascripts/helpers/maps.js";
import wikipediaHelper from "../../assets/javascripts/helpers/wikipedia.js";
import mediumHelper from "../../assets/javascripts/helpers/medium.js";
import imgurHelper from "../../assets/javascripts/helpers/imgur.js";
+import tiktokHelper from "../../assets/javascripts/helpers/tiktok.js";
window.browser = window.browser || window.chrome;
@@ -24,6 +25,7 @@ function wholeInit() {
wikipediaHelper.init()
youtubeHelper.init()
imgurHelper.init()
+ tiktokHelper.init()
}
wholeInit();
@@ -55,6 +57,8 @@ browser.webRequest.onBeforeRequest.addListener(
else if (imgurHelper.isImgur(url)) newUrl = imgurHelper.redirect(url, initiator, details.type);
+ else if (tiktokHelper.isTiktok(url)) newUrl = tiktokHelper.redirect(url, initiator, details.type);
+
else if (translateHelper.isTranslate(url)) newUrl = translateHelper.redirect(url, initiator);
else if (searchHelper.isSearch(url)) newUrl = searchHelper.redirect(url, initiator)
diff --git a/src/pages/popup/popup.html b/src/pages/popup/popup.html
index 7a604f8b..126912a4 100644
--- a/src/pages/popup/popup.html
+++ b/src/pages/popup/popup.html
@@ -55,6 +55,11 @@
</div>
<div class="some-block">
+ <h4>TikTok</h4>
+ <input id="disable-tiktok" type="checkbox" checked />
+ </div>
+
+ <div class="some-block">
<h4>Medium</h4>
<input id="disable-medium" type="checkbox" checked />
</div>
diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js
index 9b5422d9..8d7a7bb5 100644
--- a/src/pages/popup/popup.js
+++ b/src/pages/popup/popup.js
@@ -12,6 +12,7 @@ import translateHelper from "../../assets/javascripts/helpers/translate.js";
import wikipediaHelper from "../../assets/javascripts/helpers/wikipedia.js";
import mediumHelper from "../../assets/javascripts/helpers/medium.js";
import imgurHelper from "../../assets/javascripts/helpers/imgur.js";
+import tiktokHelper from "../../assets/javascripts/helpers/tiktok.js";
let disableTwitterElement = document.querySelector("#disable-nitter");
let disableYoutubeElement = document.querySelector("#disable-invidious");
@@ -23,6 +24,7 @@ let disableTranslateElement = document.querySelector("#disable-simplyTranslate")
let disableWikipediaElement = document.querySelector("#disable-wikipedia");
let disableMediumElement = document.querySelector("#disable-medium");
let disableImgurElement = document.querySelector("#disable-imgur");
+let disableTiktokElement = document.querySelector("#disable-tiktok");
window.browser = window.browser || window.chrome;
@@ -36,6 +38,7 @@ async function wholeInit() {
await translateHelper.init();
await wikipediaHelper.init();
await imgurHelper.init();
+ await tiktokHelper.init();
await mediumHelper.init();
};
@@ -50,6 +53,7 @@ wholeInit().then(() => {
disableTranslateElement.checked = !translateHelper.getDisableTranslate();
disableWikipediaElement.checked = !wikipediaHelper.getDisableWikipedia();
disableImgurElement.checked = !imgurHelper.getDisableImgur();
+ disableTiktokElement.checked = !tiktokHelper.getDisableTiktok();
disableMediumElement.checked = !mediumHelper.getDisableMedium();
})
@@ -89,6 +93,10 @@ disableImgurElement.addEventListener("change",
(event) => imgurHelper.setDisableImgur(!event.target.checked)
);
+disableTiktokElement.addEventListener("change",
+ (event) => tiktokHelper.setDisableTiktok(!event.target.checked)
+);
+
disableMediumElement.addEventListener("change",
(event) => mediumHelper.setDisableMedium(!event.target.checked)
);