Many things
Made all instances updateable Added hyperpipe Closes https://github.com/libredirect/libredirect/issues/398 Added cloudtube Closes https://github.com/libredirect/libredirect/issues/397 Start using prettier
This commit is contained in:
parent
b7859ac2a4
commit
2a0596f08f
|
@ -13,12 +13,12 @@ name: "CodeQL"
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
branches: [master]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
branches: [master]
|
||||
schedule:
|
||||
- cron: '43 18 * * 3'
|
||||
- cron: "43 18 * * 3"
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
|
@ -32,39 +32,39 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'javascript' ]
|
||||
language: ["javascript"]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
|
|
|
@ -2,21 +2,21 @@ name: instances-updater
|
|||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '10 22 */3 * *'
|
||||
|
||||
- cron: "10 22 */3 * *"
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
steps:
|
||||
- name: get repo content
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: setup python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.8' # install the python version needed
|
||||
python-version: "3.8" # install the python version needed
|
||||
|
||||
- name: install python packages
|
||||
run: |
|
||||
|
@ -24,7 +24,7 @@ jobs:
|
|||
pip install requests bs4 colorama
|
||||
- name: run script
|
||||
run: python src/instances/get_instances.py
|
||||
|
||||
|
||||
- name: commit files
|
||||
run: |
|
||||
git config --local user.email "action@github.com"
|
||||
|
|
|
@ -9,6 +9,6 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
node-version: "16"
|
||||
- run: npm install
|
||||
- run: npm test
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
web-ext-artifacts/
|
||||
.DS_Store
|
||||
nod
|
||||
node_modules
|
||||
package-lock.json
|
||||
src/instances/data.json
|
||||
src/instances/blacklist.json
|
||||
src/pages/options/*.html
|
||||
src/pages/popup/*.html
|
||||
src/_locales/
|
||||
.vscode
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"semi": false,
|
||||
"tabWidth": 2,
|
||||
"useTabs": true,
|
||||
"arrowParens": "avoid",
|
||||
"printWidth": 200,
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.js", "*.json"],
|
||||
"options": {
|
||||
"tabWidth": 2,
|
||||
"singleQuote": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["*.html", "*.py"],
|
||||
"options": {
|
||||
"tabWidth": 4,
|
||||
"singleQuote": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,11 +1,13 @@
|
|||
## Data collected
|
||||
* LibRedirect does not collect any Personal Information of any kind.
|
||||
* LibRedirect doesn't embed any kind of analytics in its code.
|
||||
* All aspects of the extension work locally in your browser, with the exception of
|
||||
OpenStreetMap (OSM) reverse geocoding, done via the [OSM Nomantim API](https://nominatim.org/release-docs/develop/api/Overview/),
|
||||
used as part of OSM redirects, which can be disabled by toggling the OSM redirects.
|
||||
* It also connects to [this url](https://raw.githubusercontent.com/libredirect/libredirect/master/src/instances/data.json) to update the Instances List. Though this only gets triggered when the user presses the `Update Instances` button.
|
||||
* For bibliogram instances. To set a cookie you should send an http request to the server as the server stores settings values itself and gives you a token to access them.
|
||||
|
||||
- LibRedirect does not collect any Personal Information of any kind.
|
||||
- LibRedirect doesn't embed any kind of analytics in its code.
|
||||
- All aspects of the extension work locally in your browser, with the exception of
|
||||
OpenStreetMap (OSM) reverse geocoding, done via the [OSM Nomantim API](https://nominatim.org/release-docs/develop/api/Overview/),
|
||||
used as part of OSM redirects, which can be disabled by toggling the OSM redirects.
|
||||
- It also connects to [this url](https://raw.githubusercontent.com/libredirect/libredirect/master/src/instances/data.json) to update the Instances List. Though this only gets triggered when the user presses the `Update Instances` button.
|
||||
- For bibliogram instances. To set a cookie you should send an http request to the server as the server stores settings values itself and gives you a token to access them.
|
||||
|
||||
## Future Changes
|
||||
|
||||
If we decide to change our privacy policy, we will post those changes on this page.
|
||||
|
|
20
README.md
20
README.md
|
@ -8,10 +8,10 @@ A web extension that redirects YouTube, Twitter, Instagram... requests to altern
|
|||
|
||||
[![Firefox Add-on](./img/badge-amo.png)](https://addons.mozilla.org/firefox/addon/libredirect/)
|
||||
<a href="https://microsoftedge.microsoft.com/addons/detail/libredirect/aodffkeankebfonljgbcfbbaljopcpdb">
|
||||
<img src="./img/badge-ms.png" height=60>
|
||||
<img src="./img/badge-ms.png" height=60>
|
||||
</a>
|
||||
<a href="./chromium.md">
|
||||
<img src ="./img/badge-chromium.png" height=60 >
|
||||
<img src ="./img/badge-chromium.png" height=60 >
|
||||
</a>
|
||||
|
||||
<img src ="./img/1.png" width=350>
|
||||
|
@ -42,6 +42,7 @@ Send Files => [Send](https://gitlab.com/timvisee/send)
|
|||
[FAQ](https://libredirect.github.io/faq.html)
|
||||
|
||||
## Donate
|
||||
|
||||
[![Liberapay](./img/liberapay.svg)](https://liberapay.com/LibRedirect)
|
||||
[![Patreon](./img/patreon.svg)](https://patreon.com/LibRedirect)
|
||||
[![Buy me a coffee](./img/bmc.svg)](https://www.buymeacoffee.com/libredirect)
|
||||
|
@ -52,47 +53,59 @@ ETH: 0x896E5796Da76E49A400A9186E1c459CD2C64b4E8\
|
|||
XMR: 4AM5CVfaGsnEXQQjZSzJvaWufe7pT86ubcZPr83fCjb2Hn3iwcForTWFy2Z3ugXcufUwHaGcucfPMFgPXBFSYGFvNrmV5XR
|
||||
|
||||
## Mirror Repos
|
||||
|
||||
[![GitHub](https://raw.githubusercontent.com/ManeraKai/manerakai/main/icons/github.svg)](https://github.com/libredirect/libredirect/)
|
||||
[![Codeberg](https://raw.githubusercontent.com/ManeraKai/manerakai/main/icons/codeberg.svg)](https://codeberg.org/LibRedirect/libredirect)
|
||||
|
||||
## Translate
|
||||
|
||||
[![Weblate](./img/weblate.svg)](https://hosted.weblate.org/projects/libredirect/extension)
|
||||
|
||||
## Development
|
||||
|
||||
### Install Dependencies
|
||||
|
||||
[Node.js](https://nodejs.org/) latest LTS is recommended
|
||||
|
||||
```
|
||||
npm update
|
||||
npm install
|
||||
```
|
||||
|
||||
If you are modifying any files ending with .pug, the pug cli needs to be installed with the following command (with root privileges):
|
||||
|
||||
```
|
||||
npm install -g pug-cli
|
||||
```
|
||||
and then run `./script.sh` to generate pages in the background.
|
||||
|
||||
and then run `npm run pug` to generate pages in the background.
|
||||
|
||||
### Build
|
||||
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```
|
||||
npm run test
|
||||
```
|
||||
|
||||
### Test in Firefox
|
||||
|
||||
```
|
||||
npm run start
|
||||
```
|
||||
|
||||
### Install temporarily
|
||||
|
||||
open `about:addons`\
|
||||
click on the settings button below the addon search bar and select `debug add-on`\
|
||||
press `load temporarily addon`
|
||||
|
||||
### Install in Firefox ESR, Developer Edition, Nightly
|
||||
|
||||
open `about:config`\
|
||||
set `xpinstall.signatures.required` to `false`\
|
||||
open `about:addons`\
|
||||
|
@ -100,6 +113,7 @@ click on the gear shaped `settings` button and select `Install Add-on From File.
|
|||
select `libredirect-VERSION.zip` from `web-ext-artifacts` folder
|
||||
|
||||
### Install in Chromium browsers
|
||||
|
||||
open `chrome://extensions`\
|
||||
enable `dev mode`\
|
||||
select `load unpacked extension`\
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
## Linux
|
||||
|
||||
- Download the latest `.crx` file: [libredirect-2.2.1.crx](https://github.com/libredirect/libredirect/releases/download/v2.2.1/libredirect-2.2.1.crx)
|
||||
- Open `chrome://extensions`
|
||||
- Enable `dev mode`
|
||||
|
@ -8,6 +9,7 @@
|
|||
Updates are automatic
|
||||
|
||||
## Windows, MacOS
|
||||
|
||||
- Download the latest release [libredirect-2.2.1.zip](https://github.com/libredirect/libredirect/releases/download/v2.2.1/libredirect-2.2.1.zip)
|
||||
- Unzip it with `Auto detect subfolder`
|
||||
- Open `chrome://extensions`
|
||||
|
|
58
package.json
58
package.json
|
@ -1,29 +1,33 @@
|
|||
{
|
||||
"name": "libredirect",
|
||||
"description": "Redirects YouTube, Twitter, Instagram and more to privacy friendly frontends.",
|
||||
"engines": {
|
||||
"node": ">=16.13.1",
|
||||
"npm": ">=8.1.2"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "web-ext run --browser-console --source-dir ./src/",
|
||||
"build": "web-ext build --overwrite-dest --source-dir ./src/",
|
||||
"test": "web-ext lint --source-dir ./src/ || true"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/LibRedirect/LibRedirect.git"
|
||||
},
|
||||
"author": "LibRedirect",
|
||||
"license": "GPL-3.0-only",
|
||||
"bugs": {
|
||||
"url": "https://github.com/LibRedirect/LibRedirect/issues"
|
||||
},
|
||||
"homepage": "https://github.com/LibRedirect/LibRedirect",
|
||||
"devDependencies": {
|
||||
"web-ext": "^6.7.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"buffer": "^6.0.3"
|
||||
}
|
||||
"name": "libredirect",
|
||||
"description": "Redirects YouTube, Twitter, Instagram and more to privacy friendly frontends.",
|
||||
"engines": {
|
||||
"node": ">=16.13.1",
|
||||
"npm": ">=8.1.2"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "web-ext run --browser-console --source-dir ./src/",
|
||||
"build": "web-ext build --overwrite-dest --source-dir ./src/",
|
||||
"test": "web-ext lint --source-dir ./src/ || true",
|
||||
"pug": "pug ./src/pages/options/*.pug ./src/pages/popup/ -P -w",
|
||||
"prettier": "npx prettier --write .",
|
||||
"instances": "python3 src/instances/get_instances.py; git update-index --assume-unchanged src/instances/blacklist.json src/instances/data.json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/LibRedirect/LibRedirect.git"
|
||||
},
|
||||
"author": "LibRedirect",
|
||||
"license": "GPL-3.0-only",
|
||||
"bugs": {
|
||||
"url": "https://github.com/LibRedirect/LibRedirect/issues"
|
||||
},
|
||||
"homepage": "https://github.com/LibRedirect/LibRedirect",
|
||||
"devDependencies": {
|
||||
"prettier": "2.7.1",
|
||||
"web-ext": "^6.7.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"buffer": "^6.0.3"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,78 +1,66 @@
|
|||
"use strict";
|
||||
window.browser = window.browser || window.chrome;
|
||||
"use strict"
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
function isException(url) {
|
||||
for (const item of exceptions.url)
|
||||
if (item == `${url.protocol}//${url.host}`) return true;
|
||||
for (const item of exceptions.regex)
|
||||
if (new RegExp(item).test(url.href)) return true;
|
||||
return false;
|
||||
for (const item of exceptions.url) if (item == `${url.protocol}//${url.host}`) return true
|
||||
for (const item of exceptions.regex) if (new RegExp(item).test(url.href)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
let exceptions;
|
||||
let exceptions
|
||||
|
||||
function init() {
|
||||
browser.storage.local.get(
|
||||
'exceptions',
|
||||
r => {
|
||||
exceptions = r.exceptions;
|
||||
}
|
||||
)
|
||||
browser.storage.local.get("exceptions", r => {
|
||||
exceptions = r.exceptions
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
async function initDefaults() {
|
||||
return new Promise(resolve =>
|
||||
browser.storage.local.set({
|
||||
exceptions: {
|
||||
"url": [],
|
||||
"regex": [],
|
||||
},
|
||||
theme: "DEFAULT",
|
||||
popupFrontends: [
|
||||
"youtube",
|
||||
"twitter",
|
||||
"instagram",
|
||||
"tiktok",
|
||||
"imgur",
|
||||
"reddit",
|
||||
"quora",
|
||||
"translate",
|
||||
"maps",
|
||||
],
|
||||
autoRedirect: false,
|
||||
firstPartyIsolate: false,
|
||||
protocol: "normal",
|
||||
protocolFallback: true
|
||||
}, () => resolve())
|
||||
)
|
||||
return new Promise(resolve =>
|
||||
browser.storage.local.set(
|
||||
{
|
||||
exceptions: {
|
||||
url: [],
|
||||
regex: [],
|
||||
},
|
||||
theme: "DEFAULT",
|
||||
popupFrontends: ["youtube", "twitter", "instagram", "tiktok", "imgur", "reddit", "quora", "translate", "maps"],
|
||||
autoRedirect: false,
|
||||
firstPartyIsolate: false,
|
||||
protocol: "normal",
|
||||
protocolFallback: true,
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
const allPopupFrontends = [
|
||||
"youtube",
|
||||
"youtubeMusic",
|
||||
"twitter",
|
||||
"instagram",
|
||||
"tiktok",
|
||||
"imgur",
|
||||
"reddit",
|
||||
"search",
|
||||
"translate",
|
||||
"maps",
|
||||
"wikipedia",
|
||||
"medium",
|
||||
"quora",
|
||||
"imdb",
|
||||
"reuters",
|
||||
"peertube",
|
||||
"lbry",
|
||||
"sendTargets"
|
||||
];
|
||||
"youtube",
|
||||
"youtubeMusic",
|
||||
"twitter",
|
||||
"instagram",
|
||||
"tiktok",
|
||||
"imgur",
|
||||
"reddit",
|
||||
"search",
|
||||
"translate",
|
||||
"maps",
|
||||
"wikipedia",
|
||||
"medium",
|
||||
"quora",
|
||||
"imdb",
|
||||
"reuters",
|
||||
"peertube",
|
||||
"lbry",
|
||||
"sendTargets",
|
||||
]
|
||||
|
||||
export default {
|
||||
isException,
|
||||
initDefaults,
|
||||
allPopupFrontends,
|
||||
isException,
|
||||
initDefaults,
|
||||
allPopupFrontends,
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
import utils from './utils.js'
|
||||
import utils from "./utils.js"
|
||||
|
||||
const targets = [
|
||||
/^https?:\/{2}(?:www\.|)imdb\.com.*/
|
||||
];
|
||||
const targets = [/^https?:\/{2}(?:www\.|)imdb\.com.*/]
|
||||
|
||||
const frontends = new Array("libremdb")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
@ -12,182 +10,197 @@ const protocols = new Array("normal", "tor", "i2p", "loki")
|
|||
let redirects = {}
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get('cloudflareBlackList', r => {
|
||||
redirects.libremdb = val;
|
||||
libremdbNormalRedirectsChecks = [...redirects.libremdb.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = libremdbNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) libremdbNormalRedirectsChecks.splice(a, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
imdbRedirects: redirects,
|
||||
libremdbNormalRedirectsChecks
|
||||
})
|
||||
})
|
||||
browser.storage.local.get("cloudflareBlackList", r => {
|
||||
redirects.libremdb = val
|
||||
libremdbNormalRedirectsChecks = [...redirects.libremdb.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = libremdbNormalRedirectsChecks.indexOf(instance)
|
||||
if (a > -1) libremdbNormalRedirectsChecks.splice(a, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
imdbRedirects: redirects,
|
||||
libremdbNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
disableImdb,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
imdbRedirects,
|
||||
libremdbNormalRedirectsChecks,
|
||||
libremdbNormalCustomRedirects,
|
||||
libremdbTorRedirectsChecks,
|
||||
libremdbTorCustomRedirects,
|
||||
libremdbI2pCustomRedirects,
|
||||
libremdbLokiCustomRedirects;
|
||||
let disableImdb,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
imdbRedirects,
|
||||
libremdbNormalRedirectsChecks,
|
||||
libremdbNormalCustomRedirects,
|
||||
libremdbTorRedirectsChecks,
|
||||
libremdbTorCustomRedirects,
|
||||
libremdbI2pCustomRedirects,
|
||||
libremdbLokiCustomRedirects
|
||||
|
||||
function init() {
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableImdb",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"imdbRedirects",
|
||||
"libremdbNormalRedirectsChecks",
|
||||
"libremdbNormalCustomRedirects",
|
||||
"libremdbTorRedirectsChecks",
|
||||
"libremdbTorCustomRedirects",
|
||||
"libremdbI2pCustomRedirects",
|
||||
"libremdbLokiCustomRedirects"
|
||||
],
|
||||
r => {
|
||||
disableImdb = r.disableImdb;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
imdbRedirects = r.imdbRedirects;
|
||||
libremdbNormalRedirectsChecks = r.libremdbNormalRedirectsChecks;
|
||||
libremdbNormalCustomRedirects = r.libremdbNormalCustomRedirects;
|
||||
libremdbTorRedirectsChecks = r.libremdbTorRedirectsChecks;
|
||||
libremdbTorCustomRedirects = r.libremdbTorCustomRedirects;
|
||||
libremdbI2pCustomRedirects = r.libremdbI2pCustomRedirects;
|
||||
libremdbLokiCustomRedirects = r.libremdbLokiCustomRedirects;
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableImdb",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"imdbRedirects",
|
||||
"libremdbNormalRedirectsChecks",
|
||||
"libremdbNormalCustomRedirects",
|
||||
"libremdbTorRedirectsChecks",
|
||||
"libremdbTorCustomRedirects",
|
||||
"libremdbI2pCustomRedirects",
|
||||
"libremdbLokiCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disableImdb = r.disableImdb
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
imdbRedirects = r.imdbRedirects
|
||||
libremdbNormalRedirectsChecks = r.libremdbNormalRedirectsChecks
|
||||
libremdbNormalCustomRedirects = r.libremdbNormalCustomRedirects
|
||||
libremdbTorRedirectsChecks = r.libremdbTorRedirectsChecks
|
||||
libremdbTorCustomRedirects = r.libremdbTorCustomRedirects
|
||||
libremdbI2pCustomRedirects = r.libremdbI2pCustomRedirects
|
||||
libremdbLokiCustomRedirects = r.libremdbLokiCustomRedirects
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function redirect(url, type, initiator, disableOverride) {
|
||||
if (disableImdb && !disableOverride) return;
|
||||
if (url.pathname == "/") return;
|
||||
if (type != "main_frame") return;
|
||||
const all = [
|
||||
...imdbRedirects.libremdb.normal,
|
||||
...libremdbNormalCustomRedirects
|
||||
];
|
||||
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return;
|
||||
if (!targets.some(rx => rx.test(url.href))) return;
|
||||
if (disableImdb && !disableOverride) return
|
||||
if (url.pathname == "/") return
|
||||
if (type != "main_frame") return
|
||||
const all = [...imdbRedirects.libremdb.normal, ...libremdbNormalCustomRedirects]
|
||||
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return
|
||||
if (!targets.some(rx => rx.test(url.href))) return
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...libremdbLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...libremdbI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...libremdbNormalRedirectsChecks, ...libremdbNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) { return; }
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...libremdbLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...libremdbI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...libremdbNormalRedirectsChecks, ...libremdbNormalCustomRedirects]
|
||||
}
|
||||
if (instancesList.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
return `${randomInstance}${url.pathname}`;
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
return `${randomInstance}${url.pathname}`
|
||||
}
|
||||
|
||||
function reverse(url) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
let protocolHost = utils.protocolHost(url);
|
||||
const all = [
|
||||
...imdbRedirects.libremdb.normal,
|
||||
...imdbRedirects.libremdb.tor,
|
||||
...libremdbNormalCustomRedirects,
|
||||
...libremdbTorCustomRedirects,
|
||||
...libremdbI2pCustomRedirects,
|
||||
...libremdbLokiCustomRedirects
|
||||
];
|
||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
let protocolHost = utils.protocolHost(url)
|
||||
const all = [
|
||||
...imdbRedirects.libremdb.normal,
|
||||
...imdbRedirects.libremdb.tor,
|
||||
...libremdbNormalCustomRedirects,
|
||||
...libremdbTorCustomRedirects,
|
||||
...libremdbI2pCustomRedirects,
|
||||
...libremdbLokiCustomRedirects,
|
||||
]
|
||||
if (!all.includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
resolve(`https://imdb.com${url.pathname}${url.search}`);
|
||||
})
|
||||
resolve(`https://imdb.com${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function switchInstance(url, disableOverride) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableImdb && !disableOverride) { resolve(); return; }
|
||||
let protocolHost = utils.protocolHost(url);
|
||||
const all = [
|
||||
...imdbRedirects.libremdb.tor,
|
||||
...imdbRedirects.libremdb.normal,
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableImdb && !disableOverride) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let protocolHost = utils.protocolHost(url)
|
||||
const all = [
|
||||
...imdbRedirects.libremdb.tor,
|
||||
...imdbRedirects.libremdb.normal,
|
||||
|
||||
...libremdbNormalCustomRedirects,
|
||||
...libremdbTorCustomRedirects,
|
||||
...libremdbI2pCustomRedirects,
|
||||
...libremdbLokiCustomRedirects
|
||||
];
|
||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
||||
...libremdbNormalCustomRedirects,
|
||||
...libremdbTorCustomRedirects,
|
||||
...libremdbI2pCustomRedirects,
|
||||
...libremdbLokiCustomRedirects,
|
||||
]
|
||||
if (!all.includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...libremdbLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...libremdbI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...libremdbNormalRedirectsChecks, ...libremdbNormalCustomRedirects];
|
||||
}
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...libremdbLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...libremdbI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...libremdbNormalRedirectsChecks, ...libremdbNormalCustomRedirects]
|
||||
}
|
||||
|
||||
const i = instancesList.indexOf(protocolHost);
|
||||
if (i > -1) instancesList.splice(i, 1);
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
const i = instancesList.indexOf(protocolHost)
|
||||
if (i > -1) instancesList.splice(i, 1)
|
||||
if (instancesList.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
})
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(async resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.set({
|
||||
disableImdb: true,
|
||||
imdbRedirects: redirects,
|
||||
return new Promise(async resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(async data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
disableImdb: true,
|
||||
imdbRedirects: redirects,
|
||||
|
||||
libremdbNormalRedirectsChecks: [...redirects.libremdb.normal],
|
||||
libremdbNormalCustomRedirects: [],
|
||||
libremdbNormalRedirectsChecks: [...redirects.libremdb.normal],
|
||||
libremdbNormalCustomRedirects: [],
|
||||
|
||||
libremdbTorRedirectsChecks: [...redirects.libremdb.tor],
|
||||
libremdbTorCustomRedirects: [],
|
||||
libremdbTorRedirectsChecks: [...redirects.libremdb.tor],
|
||||
libremdbTorCustomRedirects: [],
|
||||
|
||||
libremdbI2pRedirectsChecks: [],
|
||||
libremdbI2pCustomRedirects: [],
|
||||
libremdbI2pRedirectsChecks: [],
|
||||
libremdbI2pCustomRedirects: [],
|
||||
|
||||
libremdbLokiRedirectsChecks: [],
|
||||
libremdbLokiCustomRedirects: []
|
||||
}, () => resolve());
|
||||
});
|
||||
})
|
||||
libremdbLokiRedirectsChecks: [],
|
||||
libremdbLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
setRedirects,
|
||||
|
||||
redirect,
|
||||
reverse,
|
||||
switchInstance,
|
||||
redirect,
|
||||
reverse,
|
||||
switchInstance,
|
||||
|
||||
initDefaults
|
||||
};
|
||||
initDefaults,
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
import utils from './utils.js'
|
||||
import utils from "./utils.js"
|
||||
|
||||
const targets = /^https?:\/{2}([im]\.)?imgur\.(com|io)(\/|$)/
|
||||
|
||||
|
@ -10,91 +10,95 @@ const protocols = new Array("normal", "tor", "i2p", "loki")
|
|||
let redirects = {}
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
function setRedirects() {
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
redirects.rimgo = dataJson.rimgo;
|
||||
return new Promise(resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(async data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
redirects.rimgo = dataJson.rimgo
|
||||
|
||||
rimgoNormalRedirectsChecks = [...redirects.rimgo.normal];
|
||||
rimgoTorRedirectsChecks = [...redirects.rimgo.tor];
|
||||
rimgoI2pRedirectsChecks = [...redirects.rimgo.i2p];
|
||||
rimgoNormalRedirectsChecks = [...redirects.rimgo.normal]
|
||||
rimgoTorRedirectsChecks = [...redirects.rimgo.tor]
|
||||
rimgoI2pRedirectsChecks = [...redirects.rimgo.i2p]
|
||||
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = rimgoNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) rimgoNormalRedirectsChecks.splice(a, 1);
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = rimgoNormalRedirectsChecks.indexOf(instance)
|
||||
if (a > -1) rimgoNormalRedirectsChecks.splice(a, 1)
|
||||
|
||||
const b = rimgoTorRedirectsChecks.indexOf(instance);
|
||||
if (b > -1) rimgoTorRedirectsChecks.splice(b, 1);
|
||||
const b = rimgoTorRedirectsChecks.indexOf(instance)
|
||||
if (b > -1) rimgoTorRedirectsChecks.splice(b, 1)
|
||||
|
||||
const c = rimgoI2pRedirectsChecks.indexOf(instance);
|
||||
if (c > -1) rimgoI2pRedirectsChecks.splice(c, 1);
|
||||
}
|
||||
const c = rimgoI2pRedirectsChecks.indexOf(instance)
|
||||
if (c > -1) rimgoI2pRedirectsChecks.splice(c, 1)
|
||||
}
|
||||
|
||||
browser.storage.local.set({
|
||||
imgurRedirects: redirects,
|
||||
rimgoNormalRedirectsChecks,
|
||||
rimgoTorRedirectsChecks,
|
||||
rimgoI2pRedirectsChecks,
|
||||
}, () => resolve());
|
||||
})
|
||||
})
|
||||
browser.storage.local.set(
|
||||
{
|
||||
imgurRedirects: redirects,
|
||||
rimgoNormalRedirectsChecks,
|
||||
rimgoTorRedirectsChecks,
|
||||
rimgoI2pRedirectsChecks,
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
disableImgur,
|
||||
imgurRedirects,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
rimgoNormalRedirectsChecks,
|
||||
rimgoNormalCustomRedirects,
|
||||
rimgoTorRedirectsChecks,
|
||||
rimgoTorCustomRedirects,
|
||||
rimgoI2pRedirectsChecks,
|
||||
rimgoI2pCustomRedirects,
|
||||
rimgoLokiCustomRedirects;
|
||||
let disableImgur,
|
||||
imgurRedirects,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
rimgoNormalRedirectsChecks,
|
||||
rimgoNormalCustomRedirects,
|
||||
rimgoTorRedirectsChecks,
|
||||
rimgoTorCustomRedirects,
|
||||
rimgoI2pRedirectsChecks,
|
||||
rimgoI2pCustomRedirects,
|
||||
rimgoLokiCustomRedirects
|
||||
|
||||
function init() {
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableImgur",
|
||||
"imgurRedirects",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"rimgoNormalRedirectsChecks",
|
||||
"rimgoNormalCustomRedirects",
|
||||
"rimgoTorRedirectsChecks",
|
||||
"rimgoTorCustomRedirects",
|
||||
"rimgoI2pRedirectsChecks",
|
||||
"rimgoI2pCustomRedirects",
|
||||
"rimgoLokiCustomRedirects"
|
||||
],
|
||||
r => {
|
||||
disableImgur = r.disableImgur;
|
||||
imgurRedirects = r.imgurRedirects;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
rimgoNormalRedirectsChecks = r.rimgoNormalRedirectsChecks;
|
||||
rimgoNormalCustomRedirects = r.rimgoNormalCustomRedirects;
|
||||
rimgoTorRedirectsChecks = r.rimgoTorRedirectsChecks;
|
||||
rimgoTorCustomRedirects = r.rimgoTorCustomRedirects;
|
||||
rimgoI2pRedirectsChecks = r.rimgoI2pRedirectsChecks;
|
||||
rimgoI2pCustomRedirects = r.rimgoI2pCustomRedirects;
|
||||
rimgoLokiCustomRedirects = r.rimgoLokiCustomRedirects;
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableImgur",
|
||||
"imgurRedirects",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"rimgoNormalRedirectsChecks",
|
||||
"rimgoNormalCustomRedirects",
|
||||
"rimgoTorRedirectsChecks",
|
||||
"rimgoTorCustomRedirects",
|
||||
"rimgoI2pRedirectsChecks",
|
||||
"rimgoI2pCustomRedirects",
|
||||
"rimgoLokiCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disableImgur = r.disableImgur
|
||||
imgurRedirects = r.imgurRedirects
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
rimgoNormalRedirectsChecks = r.rimgoNormalRedirectsChecks
|
||||
rimgoNormalCustomRedirects = r.rimgoNormalCustomRedirects
|
||||
rimgoTorRedirectsChecks = r.rimgoTorRedirectsChecks
|
||||
rimgoTorCustomRedirects = r.rimgoTorCustomRedirects
|
||||
rimgoI2pRedirectsChecks = r.rimgoI2pRedirectsChecks
|
||||
rimgoI2pCustomRedirects = r.rimgoI2pCustomRedirects
|
||||
rimgoLokiCustomRedirects = r.rimgoLokiCustomRedirects
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
// https://imgur.com/gallery/s4WXQmn
|
||||
|
@ -104,108 +108,127 @@ browser.storage.onChanged.addListener(init)
|
|||
// https://i.imgur.com/CFSQArP.jpeg
|
||||
|
||||
function all() {
|
||||
return [
|
||||
...imgurRedirects.rimgo.normal,
|
||||
...imgurRedirects.rimgo.tor,
|
||||
...imgurRedirects.rimgo.i2p,
|
||||
...rimgoNormalCustomRedirects,
|
||||
...rimgoTorCustomRedirects,
|
||||
...rimgoI2pCustomRedirects,
|
||||
...rimgoLokiCustomRedirects
|
||||
];
|
||||
return [
|
||||
...imgurRedirects.rimgo.normal,
|
||||
...imgurRedirects.rimgo.tor,
|
||||
...imgurRedirects.rimgo.i2p,
|
||||
...rimgoNormalCustomRedirects,
|
||||
...rimgoTorCustomRedirects,
|
||||
...rimgoI2pCustomRedirects,
|
||||
...rimgoLokiCustomRedirects,
|
||||
]
|
||||
}
|
||||
|
||||
function redirect(url, type, initiator, disableOverride) {
|
||||
if (disableImgur && !disableOverride) return;
|
||||
if (url.pathname == "/" && !disableOverride) return;
|
||||
if (!["main_frame", "sub_frame", "xmlhttprequest", "other", "image", "media",].includes(type)) return;
|
||||
if (initiator && (all().includes(initiator.origin) || targets.test(initiator.host))) return;
|
||||
if (!targets.test(url.href)) return;
|
||||
if (url.pathname.includes("delete/")) return;
|
||||
if (disableImgur && !disableOverride) return
|
||||
if (url.pathname == "/" && !disableOverride) return
|
||||
if (!["main_frame", "sub_frame", "xmlhttprequest", "other", "image", "media"].includes(type)) return
|
||||
if (initiator && (all().includes(initiator.origin) || targets.test(initiator.host))) return
|
||||
if (!targets.test(url.href)) return
|
||||
if (url.pathname.includes("delete/")) return
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...rimgoLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks];
|
||||
else if (protocol == 'tor') instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) { return; }
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...rimgoLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks]
|
||||
else if (protocol == "tor") instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects]
|
||||
}
|
||||
if (instancesList.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
return `${randomInstance}${url.pathname}${url.search}`;
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
return `${randomInstance}${url.pathname}${url.search}`
|
||||
}
|
||||
|
||||
function reverse(url) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
const protocolHost = utils.protocolHost(url);
|
||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
||||
resolve(`https://imgur.com${url.pathname}${url.search}`);
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
const protocolHost = utils.protocolHost(url)
|
||||
if (!all().includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
resolve(`https://imgur.com${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function switchInstance(url, disableOverride) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableImgur && !disableOverride) { resolve(); return; }
|
||||
let protocolHost = utils.protocolHost(url);
|
||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...rimgoLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks];
|
||||
else if (protocol == 'tor') instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects];
|
||||
}
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableImgur && !disableOverride) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let protocolHost = utils.protocolHost(url)
|
||||
if (!all().includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...rimgoLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks]
|
||||
else if (protocol == "tor") instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects]
|
||||
}
|
||||
|
||||
const i = instancesList.indexOf(protocolHost);
|
||||
if (i > -1) instancesList.splice(i, 1);
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
const i = instancesList.indexOf(protocolHost)
|
||||
if (i > -1) instancesList.splice(i, 1)
|
||||
if (instancesList.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
})
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get('cloudflareBlackList', async r => {
|
||||
rimgoNormalRedirectsChecks = [...redirects.rimgo.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const i = rimgoNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) rimgoNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
disableImgur: false,
|
||||
imgurRedirects: redirects,
|
||||
return new Promise(resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(async data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||
rimgoNormalRedirectsChecks = [...redirects.rimgo.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const i = rimgoNormalRedirectsChecks.indexOf(instance)
|
||||
if (i > -1) rimgoNormalRedirectsChecks.splice(i, 1)
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
disableImgur: false,
|
||||
imgurRedirects: redirects,
|
||||
|
||||
rimgoNormalRedirectsChecks: rimgoNormalRedirectsChecks,
|
||||
rimgoNormalCustomRedirects: [],
|
||||
rimgoNormalRedirectsChecks: rimgoNormalRedirectsChecks,
|
||||
rimgoNormalCustomRedirects: [],
|
||||
|
||||
rimgoTorRedirectsChecks: [...redirects.rimgo.tor],
|
||||
rimgoTorCustomRedirects: [],
|
||||
rimgoTorRedirectsChecks: [...redirects.rimgo.tor],
|
||||
rimgoTorCustomRedirects: [],
|
||||
|
||||
rimgoI2pRedirectsChecks: [...redirects.rimgo.i2p],
|
||||
rimgoI2pCustomRedirects: [],
|
||||
rimgoI2pRedirectsChecks: [...redirects.rimgo.i2p],
|
||||
rimgoI2pCustomRedirects: [],
|
||||
|
||||
rimgoLokiRedirectsChecks: [...redirects.rimgo.loki],
|
||||
rimgoLokiCustomRedirects: []
|
||||
}, () => resolve());
|
||||
});
|
||||
});
|
||||
});
|
||||
rimgoLokiRedirectsChecks: [...redirects.rimgo.loki],
|
||||
rimgoLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
redirect,
|
||||
reverse,
|
||||
initDefaults,
|
||||
switchInstance,
|
||||
};
|
||||
setRedirects,
|
||||
redirect,
|
||||
reverse,
|
||||
initDefaults,
|
||||
switchInstance,
|
||||
}
|
||||
|
|
|
@ -1,200 +1,208 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
import utils from './utils.js'
|
||||
window.browser = window.browser || window.chrome
|
||||
import utils from "./utils.js"
|
||||
|
||||
const targets = [
|
||||
"instagram.com",
|
||||
"www.instagram.com",
|
||||
];
|
||||
const targets = ["instagram.com", "www.instagram.com"]
|
||||
|
||||
const frontends = new Array("bibliogram")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
||||
let redirects = {};
|
||||
let redirects = {}
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get('cloudflareBlackList', async r => {
|
||||
redirects.bibliogram = val;
|
||||
bibliogramNormalRedirectsChecks = [...redirects.bibliogram.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = bibliogramNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) bibliogramNormalRedirectsChecks.splice(a, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
instagramRedirects: redirects,
|
||||
bibliogramNormalRedirectsChecks
|
||||
})
|
||||
})
|
||||
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||
redirects.bibliogram = val
|
||||
bibliogramNormalRedirectsChecks = [...redirects.bibliogram.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = bibliogramNormalRedirectsChecks.indexOf(instance)
|
||||
if (a > -1) bibliogramNormalRedirectsChecks.splice(a, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
instagramRedirects: redirects,
|
||||
bibliogramNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
disableInstagram,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
instagramRedirects,
|
||||
bibliogramNormalRedirectsChecks,
|
||||
bibliogramTorRedirectsChecks,
|
||||
bibliogramNormalCustomRedirects,
|
||||
bibliogramTorCustomRedirects,
|
||||
bibliogramI2pCustomRedirects,
|
||||
bibliogramLokiCustomRedirects;
|
||||
let disableInstagram,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
instagramRedirects,
|
||||
bibliogramNormalRedirectsChecks,
|
||||
bibliogramTorRedirectsChecks,
|
||||
bibliogramNormalCustomRedirects,
|
||||
bibliogramTorCustomRedirects,
|
||||
bibliogramI2pCustomRedirects,
|
||||
bibliogramLokiCustomRedirects
|
||||
|
||||
function init() {
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableInstagram",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"instagramRedirects",
|
||||
"bibliogramNormalRedirectsChecks",
|
||||
"bibliogramTorRedirectsChecks",
|
||||
"bibliogramNormalCustomRedirects",
|
||||
"bibliogramTorCustomRedirects",
|
||||
"bibliogramI2pCustomRedirects",
|
||||
"bibliogramLokiCustomRedirects"
|
||||
],
|
||||
r => {
|
||||
disableInstagram = r.disableInstagram;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
instagramRedirects = r.instagramRedirects;
|
||||
bibliogramNormalRedirectsChecks = r.bibliogramNormalRedirectsChecks;
|
||||
bibliogramTorRedirectsChecks = r.bibliogramTorRedirectsChecks;
|
||||
bibliogramNormalCustomRedirects = r.bibliogramNormalCustomRedirects;
|
||||
bibliogramTorCustomRedirects = r.bibliogramTorCustomRedirects;
|
||||
bibliogramI2pCustomRedirects = r.bibliogramI2pCustomRedirects;
|
||||
bibliogramLokiCustomRedirects = r.bibliogramLokiCustomRedirects
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableInstagram",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"instagramRedirects",
|
||||
"bibliogramNormalRedirectsChecks",
|
||||
"bibliogramTorRedirectsChecks",
|
||||
"bibliogramNormalCustomRedirects",
|
||||
"bibliogramTorCustomRedirects",
|
||||
"bibliogramI2pCustomRedirects",
|
||||
"bibliogramLokiCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disableInstagram = r.disableInstagram
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
instagramRedirects = r.instagramRedirects
|
||||
bibliogramNormalRedirectsChecks = r.bibliogramNormalRedirectsChecks
|
||||
bibliogramTorRedirectsChecks = r.bibliogramTorRedirectsChecks
|
||||
bibliogramNormalCustomRedirects = r.bibliogramNormalCustomRedirects
|
||||
bibliogramTorCustomRedirects = r.bibliogramTorCustomRedirects
|
||||
bibliogramI2pCustomRedirects = r.bibliogramI2pCustomRedirects
|
||||
bibliogramLokiCustomRedirects = r.bibliogramLokiCustomRedirects
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function all() {
|
||||
return [
|
||||
...instagramRedirects.bibliogram.normal,
|
||||
...instagramRedirects.bibliogram.tor,
|
||||
...bibliogramNormalCustomRedirects,
|
||||
...bibliogramTorCustomRedirects,
|
||||
...bibliogramI2pCustomRedirects,
|
||||
...bibliogramLokiCustomRedirects
|
||||
]
|
||||
return [
|
||||
...instagramRedirects.bibliogram.normal,
|
||||
...instagramRedirects.bibliogram.tor,
|
||||
...bibliogramNormalCustomRedirects,
|
||||
...bibliogramTorCustomRedirects,
|
||||
...bibliogramI2pCustomRedirects,
|
||||
...bibliogramLokiCustomRedirects,
|
||||
]
|
||||
}
|
||||
|
||||
function redirect(url, type, initiator, disableOverride) {
|
||||
if (disableInstagram && !disableOverride) return;
|
||||
if (initiator && all().includes(initiator.origin)) return 'BYPASSTAB';
|
||||
if (!targets.includes(url.host)) return;
|
||||
if (!["main_frame", "sub_frame", "xmlhttprequest", "other", "image", "media"].includes(type)) return;
|
||||
if (disableInstagram && !disableOverride) return
|
||||
if (initiator && all().includes(initiator.origin)) return "BYPASSTAB"
|
||||
if (!targets.includes(url.host)) return
|
||||
if (!["main_frame", "sub_frame", "xmlhttprequest", "other", "image", "media"].includes(type)) return
|
||||
|
||||
const bypassPaths = [/about/, /explore/, /support/, /press/, /api/, /privacy/, /safety/, /admin/, /\/(accounts\/|embeds?.js)/];
|
||||
if (bypassPaths.some(rx => rx.test(url.pathname))) return;
|
||||
const bypassPaths = [/about/, /explore/, /support/, /press/, /api/, /privacy/, /safety/, /admin/, /\/(accounts\/|embeds?.js)/]
|
||||
if (bypassPaths.some(rx => rx.test(url.pathname))) return
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...bibliogramLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...bibliogramI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...bibliogramNormalRedirectsChecks, ...bibliogramNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) { return; }
|
||||
let randomInstance = utils.getRandomInstance(instancesList)
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...bibliogramLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...bibliogramI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...bibliogramNormalRedirectsChecks, ...bibliogramNormalCustomRedirects]
|
||||
}
|
||||
if (instancesList.length === 0) {
|
||||
return
|
||||
}
|
||||
let randomInstance = utils.getRandomInstance(instancesList)
|
||||
|
||||
const reservedPaths = ["u", "p", "privacy",];
|
||||
if (url.pathname === "/" || reservedPaths.includes(url.pathname.split("/")[1]))
|
||||
return `${randomInstance}${url.pathname}${url.search}`;
|
||||
if (url.pathname.startsWith("/reel") || url.pathname.startsWith("/tv"))
|
||||
return `${randomInstance}/p${url.pathname.replace(/\/reel|\/tv/i, '')}${url.search}`;
|
||||
else
|
||||
return `${randomInstance}/u${url.pathname}${url.search}`; // Likely a user profile, redirect to '/u/...'
|
||||
const reservedPaths = ["u", "p", "privacy"]
|
||||
if (url.pathname === "/" || reservedPaths.includes(url.pathname.split("/")[1])) return `${randomInstance}${url.pathname}${url.search}`
|
||||
if (url.pathname.startsWith("/reel") || url.pathname.startsWith("/tv")) return `${randomInstance}/p${url.pathname.replace(/\/reel|\/tv/i, "")}${url.search}`
|
||||
else return `${randomInstance}/u${url.pathname}${url.search}` // Likely a user profile, redirect to '/u/...'
|
||||
}
|
||||
|
||||
function reverse(url) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
const protocolHost = utils.protocolHost(url);
|
||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
const protocolHost = utils.protocolHost(url)
|
||||
if (!all().includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
if (url.pathname.startsWith('/p')) resolve(`https://instagram.com${url.pathname.replace('/p', '')}${url.search}`);
|
||||
if (url.pathname.startsWith('/u')) resolve(`https://instagram.com${url.pathname.replace('/u', '')}${url.search}`);
|
||||
resolve(`https://instagram.com${url.pathname}${url.search}`);
|
||||
})
|
||||
if (url.pathname.startsWith("/p")) resolve(`https://instagram.com${url.pathname.replace("/p", "")}${url.search}`)
|
||||
if (url.pathname.startsWith("/u")) resolve(`https://instagram.com${url.pathname.replace("/u", "")}${url.search}`)
|
||||
resolve(`https://instagram.com${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function switchInstance(url, disableOverride) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableInstagram && !disableOverride) { resolve(); return; }
|
||||
let protocolHost = utils.protocolHost(url);
|
||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableInstagram && !disableOverride) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let protocolHost = utils.protocolHost(url)
|
||||
if (!all().includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...bibliogramLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...bibliogramI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...bibliogramNormalRedirectsChecks, ...bibliogramNormalCustomRedirects];
|
||||
}
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...bibliogramLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...bibliogramI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...bibliogramNormalRedirectsChecks, ...bibliogramNormalCustomRedirects]
|
||||
}
|
||||
|
||||
const i = instancesList.indexOf(protocolHost);
|
||||
if (i > -1) instancesList.splice(i, 1);
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
const i = instancesList.indexOf(protocolHost)
|
||||
if (i > -1) instancesList.splice(i, 1)
|
||||
if (instancesList.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
})
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get('cloudflareBlackList', r => {
|
||||
bibliogramNormalRedirectsChecks = [...redirects.bibliogram.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const i = bibliogramNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) bibliogramNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
disableInstagram: false,
|
||||
instagramRedirects: redirects,
|
||||
return new Promise(resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get("cloudflareBlackList", r => {
|
||||
bibliogramNormalRedirectsChecks = [...redirects.bibliogram.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const i = bibliogramNormalRedirectsChecks.indexOf(instance)
|
||||
if (i > -1) bibliogramNormalRedirectsChecks.splice(i, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
disableInstagram: false,
|
||||
instagramRedirects: redirects,
|
||||
|
||||
bibliogramNormalRedirectsChecks: bibliogramNormalRedirectsChecks,
|
||||
bibliogramNormalCustomRedirects: [],
|
||||
bibliogramNormalRedirectsChecks: bibliogramNormalRedirectsChecks,
|
||||
bibliogramNormalCustomRedirects: [],
|
||||
|
||||
bibliogramTorRedirectsChecks: [...redirects.bibliogram.tor],
|
||||
bibliogramTorCustomRedirects: [],
|
||||
bibliogramTorRedirectsChecks: [...redirects.bibliogram.tor],
|
||||
bibliogramTorCustomRedirects: [],
|
||||
|
||||
bibliogramI2pRedirectsChecks: [...redirects.bibliogram.i2p],
|
||||
bibliogramI2pCustomRedirects: [],
|
||||
bibliogramI2pRedirectsChecks: [...redirects.bibliogram.i2p],
|
||||
bibliogramI2pCustomRedirects: [],
|
||||
|
||||
bibliogramLokiRedirectsChecks: [...redirects.bibliogram.loki],
|
||||
bibliogramLokiCustomRedirects: []
|
||||
})
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
bibliogramLokiRedirectsChecks: [...redirects.bibliogram.loki],
|
||||
bibliogramLokiCustomRedirects: [],
|
||||
})
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
reverse,
|
||||
redirect,
|
||||
initDefaults,
|
||||
switchInstance,
|
||||
};
|
||||
setRedirects,
|
||||
reverse,
|
||||
redirect,
|
||||
initDefaults,
|
||||
switchInstance,
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
import utils from './utils.js'
|
||||
import utils from "./utils.js"
|
||||
|
||||
let targets = ["odysee.com"];
|
||||
let targets = ["odysee.com"]
|
||||
|
||||
const frontends = new Array("librarian")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
@ -10,160 +10,166 @@ const protocols = new Array("normal", "tor", "i2p", "loki")
|
|||
let redirects = {}
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get('cloudflareBlackList', r => {
|
||||
redirects.librarian = val;
|
||||
librarianNormalRedirectsChecks = [...redirects.librarian.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = librarianNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) librarianNormalRedirectsChecks.splice(a, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
lbryTargetsRedirects: redirects,
|
||||
librarianNormalRedirectsChecks
|
||||
})
|
||||
})
|
||||
browser.storage.local.get("cloudflareBlackList", r => {
|
||||
redirects.librarian = val
|
||||
librarianNormalRedirectsChecks = [...redirects.librarian.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = librarianNormalRedirectsChecks.indexOf(instance)
|
||||
if (a > -1) librarianNormalRedirectsChecks.splice(a, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
lbryTargetsRedirects: redirects,
|
||||
librarianNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
disableLbryTargets,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
lbryTargetsRedirects,
|
||||
librarianNormalRedirectsChecks,
|
||||
librarianNormalCustomRedirects,
|
||||
librarianTorRedirectsChecks,
|
||||
librarianTorCustomRedirects,
|
||||
librarianI2pRedirectsChecks,
|
||||
librarianI2pCustomRedirects,
|
||||
librarianLokiCustomRedirects;
|
||||
let disableLbryTargets,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
lbryTargetsRedirects,
|
||||
librarianNormalRedirectsChecks,
|
||||
librarianNormalCustomRedirects,
|
||||
librarianTorRedirectsChecks,
|
||||
librarianTorCustomRedirects,
|
||||
librarianI2pRedirectsChecks,
|
||||
librarianI2pCustomRedirects,
|
||||
librarianLokiCustomRedirects
|
||||
|
||||
function init() {
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableLbryTargets",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"lbryTargetsRedirects",
|
||||
"librarianNormalRedirectsChecks",
|
||||
"librarianNormalCustomRedirects",
|
||||
"librarianTorRedirectsChecks",
|
||||
"librarianTorCustomRedirects",
|
||||
"librarianI2pRedirectsChecks",
|
||||
"librarianI2pCustomRedirects",
|
||||
"librarianLokiCustomRedirects"
|
||||
],
|
||||
r => {
|
||||
disableLbryTargets = r.disableLbryTargets;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
lbryTargetsRedirects = r.lbryTargetsRedirects;
|
||||
librarianNormalRedirectsChecks = r.librarianNormalRedirectsChecks;
|
||||
librarianNormalCustomRedirects = r.librarianNormalCustomRedirects;
|
||||
librarianTorRedirectsChecks = r.librarianTorRedirectsChecks;
|
||||
librarianTorCustomRedirects = r.librarianTorCustomRedirects;
|
||||
librarianI2pRedirectsChecks = r.librarianI2pRedirectsChecks;
|
||||
librarianI2pCustomRedirects = r.librarianI2pCustomRedirects;
|
||||
librarianLokiCustomRedirects = r.librarianLokiCustomRedirects;
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableLbryTargets",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"lbryTargetsRedirects",
|
||||
"librarianNormalRedirectsChecks",
|
||||
"librarianNormalCustomRedirects",
|
||||
"librarianTorRedirectsChecks",
|
||||
"librarianTorCustomRedirects",
|
||||
"librarianI2pRedirectsChecks",
|
||||
"librarianI2pCustomRedirects",
|
||||
"librarianLokiCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disableLbryTargets = r.disableLbryTargets
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
lbryTargetsRedirects = r.lbryTargetsRedirects
|
||||
librarianNormalRedirectsChecks = r.librarianNormalRedirectsChecks
|
||||
librarianNormalCustomRedirects = r.librarianNormalCustomRedirects
|
||||
librarianTorRedirectsChecks = r.librarianTorRedirectsChecks
|
||||
librarianTorCustomRedirects = r.librarianTorCustomRedirects
|
||||
librarianI2pRedirectsChecks = r.librarianI2pRedirectsChecks
|
||||
librarianI2pCustomRedirects = r.librarianI2pCustomRedirects
|
||||
librarianLokiCustomRedirects = r.librarianLokiCustomRedirects
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function all() {
|
||||
return [
|
||||
...redirects.librarian.normal,
|
||||
...redirects.librarian.tor,
|
||||
...librarianNormalCustomRedirects,
|
||||
...librarianTorCustomRedirects,
|
||||
...librarianI2pCustomRedirects,
|
||||
...librarianLokiCustomRedirects
|
||||
];
|
||||
return [...redirects.librarian.normal, ...redirects.librarian.tor, ...librarianNormalCustomRedirects, ...librarianTorCustomRedirects, ...librarianI2pCustomRedirects, ...librarianLokiCustomRedirects]
|
||||
}
|
||||
|
||||
function switchInstance(url, disableOverride) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableLbryTargets && !disableOverride) { resolve(); return; }
|
||||
const protocolHost = utils.protocolHost(url);
|
||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableLbryTargets && !disableOverride) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
const protocolHost = utils.protocolHost(url)
|
||||
if (!all().includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...librarianLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...librarianI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects];
|
||||
}
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...librarianLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...librarianI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects]
|
||||
}
|
||||
|
||||
const i = instancesList.indexOf(protocolHost);
|
||||
if (i > -1) instancesList.splice(i, 1);
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
const i = instancesList.indexOf(protocolHost)
|
||||
if (i > -1) instancesList.splice(i, 1)
|
||||
if (instancesList.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
})
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function redirect(url, type, initiator, disableOverride) {
|
||||
if (disableLbryTargets && !disableOverride) return;
|
||||
if (initiator && (all().includes(initiator.origin) || targets.includes(initiator.host))) return;
|
||||
if (!targets.includes(url.host)) return;
|
||||
if (type != "main_frame") return;
|
||||
if (disableLbryTargets && !disableOverride) return
|
||||
if (initiator && (all().includes(initiator.origin) || targets.includes(initiator.host))) return
|
||||
if (!targets.includes(url.host)) return
|
||||
if (type != "main_frame") return
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...librarianLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...librarianI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) return;
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...librarianLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...librarianI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects]
|
||||
}
|
||||
if (instancesList.length === 0) return
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
return `${randomInstance}${url.pathname}${url.search}`;
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
return `${randomInstance}${url.pathname}${url.search}`
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(async resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.set({
|
||||
disableLbryTargets: true,
|
||||
lbryTargetsRedirects: redirects,
|
||||
return new Promise(async resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(async data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
disableLbryTargets: true,
|
||||
lbryTargetsRedirects: redirects,
|
||||
|
||||
librarianNormalRedirectsChecks: [...redirects.librarian.normal],
|
||||
librarianNormalCustomRedirects: [],
|
||||
librarianNormalRedirectsChecks: [...redirects.librarian.normal],
|
||||
librarianNormalCustomRedirects: [],
|
||||
|
||||
librarianTorRedirectsChecks: [...redirects.librarian.tor],
|
||||
librarianTorCustomRedirects: [],
|
||||
librarianTorRedirectsChecks: [...redirects.librarian.tor],
|
||||
librarianTorCustomRedirects: [],
|
||||
|
||||
librarianI2pRedirectsChecks: [...redirects.librarian.i2p],
|
||||
librarianI2pCustomRedirects: [],
|
||||
librarianI2pRedirectsChecks: [...redirects.librarian.i2p],
|
||||
librarianI2pCustomRedirects: [],
|
||||
|
||||
librarianLokiRedirectsChecks: [...redirects.librarian.loki],
|
||||
librarianLokiCustomRedirects: []
|
||||
}, () => resolve());
|
||||
});
|
||||
})
|
||||
librarianLokiRedirectsChecks: [...redirects.librarian.loki],
|
||||
librarianLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
switchInstance,
|
||||
redirect,
|
||||
initDefaults,
|
||||
};
|
||||
setRedirects,
|
||||
switchInstance,
|
||||
redirect,
|
||||
initDefaults,
|
||||
}
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
function localisePage() {
|
||||
function getMessage(tag) {
|
||||
return tag.replace(/__MSG_(\w+)__/g, (_match, v1) => {
|
||||
return v1 ? browser.i18n.getMessage(v1) : null;
|
||||
});
|
||||
}
|
||||
function getMessage(tag) {
|
||||
return tag.replace(/__MSG_(\w+)__/g, (_match, v1) => {
|
||||
return v1 ? browser.i18n.getMessage(v1) : null
|
||||
})
|
||||
}
|
||||
|
||||
const elements = document.querySelectorAll("[data-localise]");
|
||||
for (let i in elements)
|
||||
if (elements.hasOwnProperty(i)) {
|
||||
const obj = elements[i];
|
||||
const tag = obj.getAttribute("data-localise").toString();
|
||||
const msg = getMessage(tag);
|
||||
if (msg && msg !== tag) obj.textContent = msg;
|
||||
}
|
||||
const elements = document.querySelectorAll("[data-localise]")
|
||||
for (let i in elements)
|
||||
if (elements.hasOwnProperty(i)) {
|
||||
const obj = elements[i]
|
||||
const tag = obj.getAttribute("data-localise").toString()
|
||||
const msg = getMessage(tag)
|
||||
if (msg && msg !== tag) obj.textContent = msg
|
||||
}
|
||||
|
||||
const placeholders = document.querySelectorAll("[data-localise-placeholder]");
|
||||
for (let i in placeholders)
|
||||
if (placeholders.hasOwnProperty(i)) {
|
||||
const obj = placeholders[i];
|
||||
const tag = obj.getAttribute("data-localise-placeholder").toString();
|
||||
const msg = getMessage(tag);
|
||||
if (msg && msg !== tag) obj.placeholder = msg;
|
||||
}
|
||||
const placeholders = document.querySelectorAll("[data-localise-placeholder]")
|
||||
for (let i in placeholders)
|
||||
if (placeholders.hasOwnProperty(i)) {
|
||||
const obj = placeholders[i]
|
||||
const tag = obj.getAttribute("data-localise-placeholder").toString()
|
||||
const msg = getMessage(tag)
|
||||
if (msg && msg !== tag) obj.placeholder = msg
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
localisePage
|
||||
localisePage,
|
||||
}
|
||||
|
|
|
@ -1,247 +1,294 @@
|
|||
"use strict";
|
||||
"use strict"
|
||||
|
||||
window.browser = window.browser || window.chrome;
|
||||
import utils from './utils.js'
|
||||
window.browser = window.browser || window.chrome
|
||||
import utils from "./utils.js"
|
||||
|
||||
const targets = /^https?:\/{2}(((www|maps)\.)?(google\.).*(\/maps)|maps\.(google\.).*)/;
|
||||
const targets = /^https?:\/{2}(((www|maps)\.)?(google\.).*(\/maps)|maps\.(google\.).*)/
|
||||
|
||||
let redirects = {
|
||||
'osm': {
|
||||
"normal": [
|
||||
"https://www.openstreetmap.org"
|
||||
]
|
||||
},
|
||||
'facil': {
|
||||
"normal": [
|
||||
"https://facilmap.org"
|
||||
],
|
||||
"tor": [],
|
||||
"i2p": [],
|
||||
"loki": []
|
||||
}
|
||||
};
|
||||
const frontends = new Array("facil")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
||||
let redirects = {}
|
||||
|
||||
let
|
||||
disableMaps,
|
||||
mapsFrontend,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
facilNormalRedirectsChecks,
|
||||
facilNormalCustomRedirects,
|
||||
facilTorCustomRedirects,
|
||||
facilI2pCustomRedirects,
|
||||
facilLokiCustomRedirects;
|
||||
|
||||
function init() {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableMaps",
|
||||
"mapsFrontend",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"facilNormalRedirectsChecks",
|
||||
"facilNormalCustomRedirects",
|
||||
"facilTorCustomRedirects",
|
||||
"facilI2pCustomRedirects",
|
||||
"facilLokiCustomRedirects"
|
||||
],
|
||||
r => {
|
||||
disableMaps = r.disableMaps;
|
||||
mapsFrontend = r.mapsFrontend;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
facilNormalRedirectsChecks = r.facilNormalRedirectsChecks;
|
||||
facilNormalCustomRedirects = r.facilNormalCustomRedirects;
|
||||
facilTorCustomRedirects = r.facilTorCustomRedirects;
|
||||
facilI2pCustomRedirects = r.facilI2pCustomRedirects;
|
||||
facilLokiCustomRedirects = r.facilLokiCustomRedirects;
|
||||
}
|
||||
)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
init();
|
||||
redirects.osm = {}
|
||||
redirects.osm.normal = ["https://www.openstreetmap.org"]
|
||||
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get("cloudflareBlackList", r => {
|
||||
redirects.facil = val
|
||||
facilNormalRedirectsChecks = [...redirects.facil.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = facilNormalRedirectsChecks.indexOf(instance)
|
||||
if (a > -1) facilNormalRedirectsChecks.splice(a, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
mapsRedirects: redirects,
|
||||
facilNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let disableMaps,
|
||||
mapsFrontend,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
facilNormalRedirectsChecks,
|
||||
facilNormalCustomRedirects,
|
||||
facilTorRedirectsChecks,
|
||||
facilTorCustomRedirects,
|
||||
facilI2pRedirectsChecks,
|
||||
facilI2pCustomRedirects,
|
||||
facilLokiRedirectsChecks,
|
||||
facilLokiCustomRedirects
|
||||
|
||||
function init() {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableMaps",
|
||||
"mapsFrontend",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"facilNormalRedirectsChecks",
|
||||
"facilNormalCustomRedirects",
|
||||
"facilTorRedirectsChecks",
|
||||
"facilTorCustomRedirects",
|
||||
"facilI2pRedirectsChecks",
|
||||
"facilI2pCustomRedirects",
|
||||
"facilLokiRedirectsChecks",
|
||||
"facilLokiCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disableMaps = r.disableMaps
|
||||
mapsFrontend = r.mapsFrontend
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
facilNormalRedirectsChecks = r.facilNormalRedirectsChecks
|
||||
facilNormalCustomRedirects = r.facilNormalCustomRedirects
|
||||
facilTorRedirectsChecks = r.facilTorRedirectsChecks
|
||||
facilTorCustomRedirects = r.facilTorCustomRedirects
|
||||
facilI2pRedirectsChecks = r.facilI2pRedirectsChecks
|
||||
facilI2pCustomRedirects = r.facilI2pCustomRedirects
|
||||
facilLokiRedirectsChecks = r.facilLokiRedirectsChecks
|
||||
facilLokiCustomRedirects = r.facilLokiCustomRedirects
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function redirect(url, initiator) {
|
||||
if (disableMaps) return;
|
||||
if (initiator && initiator.host === "earth.google.com") return;
|
||||
if (!url.href.match(targets)) return;
|
||||
const mapCentreRegex = /@(-?\d[0-9.]*),(-?\d[0-9.]*),(\d{1,2})[.z]/;
|
||||
const dataLatLngRegex = /!3d(-?[0-9]{1,}.[0-9]{1,})!4d(-?[0-9]{1,}.[0-9]{1,})/;
|
||||
const placeRegex = /\/place\/(.*)\//;
|
||||
const travelModes = {
|
||||
driving: "fossgis_osrm_car",
|
||||
walking: "fossgis_osrm_foot",
|
||||
bicycling: "fossgis_osrm_bike",
|
||||
transit: "fossgis_osrm_car", // not implemented on OSM, default to car.
|
||||
};
|
||||
const travelModesFacil = {
|
||||
driving: "car",
|
||||
walking: "pedestrian",
|
||||
bicycling: "bicycle",
|
||||
transit: "car", // not implemented on Facil, default to car.
|
||||
};
|
||||
const osmLayers = {
|
||||
none: "S",
|
||||
transit: "T",
|
||||
traffic: "S", // not implemented on OSM, default to standard.
|
||||
bicycling: "C",
|
||||
};
|
||||
function addressToLatLng(address) {
|
||||
const xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.open("GET", `https://nominatim.openstreetmap.org/search/${address}?format=json&limit=1`, false);
|
||||
xmlhttp.send();
|
||||
if (xmlhttp.status === 200) {
|
||||
const json = JSON.parse(xmlhttp.responseText)[0];
|
||||
if (json) {
|
||||
console.log('json', json)
|
||||
return [
|
||||
`${json.lat},${json.lon}`,
|
||||
`${json.boundingbox[2]},${json.boundingbox[1]},${json.boundingbox[3]},${json.boundingbox[0]}`,
|
||||
];
|
||||
}
|
||||
}
|
||||
console.info("Error: Status is " + xmlhttp.status);
|
||||
}
|
||||
if (disableMaps) return
|
||||
if (initiator && initiator.host === "earth.google.com") return
|
||||
if (!url.href.match(targets)) return
|
||||
const mapCentreRegex = /@(-?\d[0-9.]*),(-?\d[0-9.]*),(\d{1,2})[.z]/
|
||||
const dataLatLngRegex = /!3d(-?[0-9]{1,}.[0-9]{1,})!4d(-?[0-9]{1,}.[0-9]{1,})/
|
||||
const placeRegex = /\/place\/(.*)\//
|
||||
const travelModes = {
|
||||
driving: "fossgis_osrm_car",
|
||||
walking: "fossgis_osrm_foot",
|
||||
bicycling: "fossgis_osrm_bike",
|
||||
transit: "fossgis_osrm_car", // not implemented on OSM, default to car.
|
||||
}
|
||||
const travelModesFacil = {
|
||||
driving: "car",
|
||||
walking: "pedestrian",
|
||||
bicycling: "bicycle",
|
||||
transit: "car", // not implemented on Facil, default to car.
|
||||
}
|
||||
const osmLayers = {
|
||||
none: "S",
|
||||
transit: "T",
|
||||
traffic: "S", // not implemented on OSM, default to standard.
|
||||
bicycling: "C",
|
||||
}
|
||||
function addressToLatLng(address) {
|
||||
const xmlhttp = new XMLHttpRequest()
|
||||
xmlhttp.open("GET", `https://nominatim.openstreetmap.org/search/${address}?format=json&limit=1`, false)
|
||||
xmlhttp.send()
|
||||
if (xmlhttp.status === 200) {
|
||||
const json = JSON.parse(xmlhttp.responseText)[0]
|
||||
if (json) {
|
||||
console.log("json", json)
|
||||
return [`${json.lat},${json.lon}`, `${json.boundingbox[2]},${json.boundingbox[1]},${json.boundingbox[3]},${json.boundingbox[0]}`]
|
||||
}
|
||||
}
|
||||
console.info("Error: Status is " + xmlhttp.status)
|
||||
}
|
||||
|
||||
let randomInstance;
|
||||
if (mapsFrontend == 'osm') randomInstance = utils.getRandomInstance(redirects.osm.normal);
|
||||
let instancesList
|
||||
switch (mapsFrontend) {
|
||||
case "osm":
|
||||
instancesList = [...redirects.osm.normal]
|
||||
break
|
||||
case "facil":
|
||||
switch (protocol) {
|
||||
case "loki":
|
||||
instancesList = [...facilLokiRedirectsChecks, ...facilLokiCustomRedirects]
|
||||
break
|
||||
case "i2p":
|
||||
instancesList = [...facilI2pRedirectsChecks, ...facilI2pCustomRedirects]
|
||||
break
|
||||
case "tor":
|
||||
instancesList = [...facilTorRedirectsChecks, ...facilTorCustomRedirects]
|
||||
}
|
||||
if ((instancesList == "" && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...facilNormalRedirectsChecks, ...facilNormalCustomRedirects]
|
||||
}
|
||||
}
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
|
||||
if (mapsFrontend == 'facil') {
|
||||
if (protocol == 'loki') randomInstance = utils.getRandomInstance(...facilLokiCustomRedirects);
|
||||
else if (protocol == 'i2p') randomInstance = utils.getRandomInstance(...facilI2pCustomRedirects);
|
||||
else if (protocol == 'tor') randomInstance = utils.getRandomInstance(...facilTorCustomRedirects);
|
||||
if ((randomInstance == "" && protocolFallback) || protocol == 'normal') {
|
||||
randomInstance = utils.getRandomInstance([...facilNormalRedirectsChecks, ...facilNormalCustomRedirects]);
|
||||
}
|
||||
}
|
||||
let mapCentre = "#"
|
||||
let prefs = {}
|
||||
|
||||
let mapCentre = "#";
|
||||
let prefs = {};
|
||||
if (url.pathname.match(mapCentreRegex)) {
|
||||
// Set map centre if present
|
||||
var [, lat, lon, zoom] = url.pathname.match(mapCentreRegex)
|
||||
} else if (url.searchParams.has("center")) {
|
||||
var [lat, lon] = url.searchParams.get("center").split(",")
|
||||
var zoom = url.searchParams.get("zoom") ?? "17"
|
||||
}
|
||||
|
||||
if (url.pathname.match(mapCentreRegex)) { // Set map centre if present
|
||||
var [, lat, lon, zoom] = url.pathname.match(mapCentreRegex);
|
||||
} else if (url.searchParams.has("center")) {
|
||||
var [lat, lon] = url.searchParams.get("center").split(",");
|
||||
var zoom = url.searchParams.get("zoom") ?? "17";
|
||||
}
|
||||
if (lat && lon && zoom) {
|
||||
if (mapsFrontend == "osm") mapCentre = `#map=${zoom}/${lat}/${lon}`
|
||||
if (mapsFrontend == "facil") mapCentre = `#${zoom}/${lat}/${lon}`
|
||||
}
|
||||
|
||||
if (lat && lon && zoom) {
|
||||
if (mapsFrontend == 'osm') mapCentre = `#map=${zoom}/${lat}/${lon}`;
|
||||
if (mapsFrontend == 'facil') mapCentre = `#${zoom}/${lat}/${lon}`;
|
||||
}
|
||||
if (url.searchParams.get("layer")) prefs.layers = osmLayers[url.searchParams.get("layer")]
|
||||
|
||||
if (url.searchParams.get("layer")) prefs.layers = osmLayers[url.searchParams.get("layer")];
|
||||
if (url.pathname.includes("/embed")) {
|
||||
// Handle Google Maps Embed API
|
||||
// https://www.google.com/maps/embed/v1/place?key=AIzaSyD4iE2xVSpkLLOXoyqT-RuPwURN3ddScAI&q=Eiffel+Tower,Paris+France
|
||||
console.log("embed life")
|
||||
|
||||
if (url.pathname.includes("/embed")) { // Handle Google Maps Embed API
|
||||
// https://www.google.com/maps/embed/v1/place?key=AIzaSyD4iE2xVSpkLLOXoyqT-RuPwURN3ddScAI&q=Eiffel+Tower,Paris+France
|
||||
console.log("embed life");
|
||||
let query = ""
|
||||
if (url.searchParams.has("q")) query = url.searchParams.get("q")
|
||||
else if (url.searchParams.has("query")) query = url.searchParams.has("query")
|
||||
else if (url.searchParams.has("pb"))
|
||||
try {
|
||||
query = url.searchParams.get("pb").split(/!2s(.*?)!/)[1]
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} // Unable to find map marker in URL.
|
||||
|
||||
let query = "";
|
||||
if (url.searchParams.has("q")) query = url.searchParams.get("q");
|
||||
else if (url.searchParams.has("query")) query = url.searchParams.has("query");
|
||||
let [coords, boundingbox] = addressToLatLng(query)
|
||||
prefs.bbox = boundingbox
|
||||
prefs.marker = coords
|
||||
prefs.layer = "mapnik"
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString()
|
||||
if (mapsFrontend == "osm") return `${randomInstance}/export/embed.html?${prefsEncoded}`
|
||||
if (mapsFrontend == "facil") return `${randomInstance}/#q=${query}`
|
||||
} else if (url.pathname.includes("/dir")) {
|
||||
// Handle Google Maps Directions
|
||||
// https://www.google.com/maps/dir/?api=1&origin=Space+Needle+Seattle+WA&destination=Pike+Place+Market+Seattle+WA&travelmode=bicycling
|
||||
|
||||
else if (url.searchParams.has("pb"))
|
||||
try { query = url.searchParams.get("pb").split(/!2s(.*?)!/)[1]; }
|
||||
catch (error) { console.error(error); } // Unable to find map marker in URL.
|
||||
let travMod = url.searchParams.get("travelmode")
|
||||
if (url.searchParams.has("travelmode")) prefs.engine = travelModes[travMod]
|
||||
|
||||
let [coords, boundingbox] = addressToLatLng(query);
|
||||
prefs.bbox = boundingbox;
|
||||
prefs.marker = coords;
|
||||
prefs.layer = "mapnik";
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString();
|
||||
if (mapsFrontend == 'osm') return `${randomInstance}/export/embed.html?${prefsEncoded}`;
|
||||
if (mapsFrontend == 'facil') return `${randomInstance}/#q=${query}`;
|
||||
let orgVal = url.searchParams.get("origin")
|
||||
let destVal = url.searchParams.get("destination")
|
||||
|
||||
} else if (url.pathname.includes("/dir")) { // Handle Google Maps Directions
|
||||
// https://www.google.com/maps/dir/?api=1&origin=Space+Needle+Seattle+WA&destination=Pike+Place+Market+Seattle+WA&travelmode=bicycling
|
||||
let org
|
||||
addressToLatLng(orgVal, a => (org = a))
|
||||
let dest
|
||||
addressToLatLng(destVal, a => (dest = a))
|
||||
prefs.route = `${org};${dest}`
|
||||
|
||||
let travMod = url.searchParams.get("travelmode");
|
||||
if (url.searchParams.has("travelmode")) prefs.engine = travelModes[travMod];
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString()
|
||||
if (mapsFrontend == "osm") return `${randomInstance}/directions?${prefsEncoded}${mapCentre}`
|
||||
if (mapsFrontend == "facil") return `${randomInstance}/#q=${orgVal}%20to%20${destVal}%20by%20${travelModesFacil[travMod]}`
|
||||
} else if (url.pathname.includes("data=") && url.pathname.match(dataLatLngRegex)) {
|
||||
// Get marker from data attribute
|
||||
// https://www.google.com/maps/place/41%C2%B001'58.2%22N+40%C2%B029'18.2%22E/@41.032833,40.4862063,17z/data=!3m1!4b1!4m6!3m5!1s0x0:0xf64286eaf72fc49d!7e2!8m2!3d41.0328329!4d40.4883948
|
||||
console.log("data life")
|
||||
|
||||
let orgVal = url.searchParams.get("origin");
|
||||
let destVal = url.searchParams.get("destination");
|
||||
let [, mlat, mlon] = url.pathname.match(dataLatLngRegex)
|
||||
|
||||
let org; addressToLatLng(orgVal, a => org = a);
|
||||
let dest; addressToLatLng(destVal, a => dest = a);
|
||||
prefs.route = `${org};${dest}`;
|
||||
if (mapsFrontend == "osm") return `${randomInstance}/search?query=${mlat}%2C${mlon}`
|
||||
if (mapsFrontend == "facil") return `${randomInstance}/#q=${mlat}%2C${mlon}`
|
||||
} else if (url.searchParams.has("ll")) {
|
||||
// Get marker from ll param
|
||||
// https://maps.google.com/?ll=38.882147,-76.99017
|
||||
console.log("ll life")
|
||||
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString();
|
||||
if (mapsFrontend == 'osm') return `${randomInstance}/directions?${prefsEncoded}${mapCentre}`;
|
||||
if (mapsFrontend == 'facil') return `${randomInstance}/#q=${orgVal}%20to%20${destVal}%20by%20${travelModesFacil[travMod]}`;
|
||||
const [mlat, mlon] = url.searchParams.get("ll").split(",")
|
||||
|
||||
} else if (url.pathname.includes("data=") && url.pathname.match(dataLatLngRegex)) { // Get marker from data attribute
|
||||
// https://www.google.com/maps/place/41%C2%B001'58.2%22N+40%C2%B029'18.2%22E/@41.032833,40.4862063,17z/data=!3m1!4b1!4m6!3m5!1s0x0:0xf64286eaf72fc49d!7e2!8m2!3d41.0328329!4d40.4883948
|
||||
console.log("data life");
|
||||
if (mapsFrontend == "osm") return `${randomInstance}/search?query=${mlat}%2C${mlon}`
|
||||
if (mapsFrontend == "facil") return `${randomInstance}/#q=${mlat}%2C${mlon}`
|
||||
} else if (url.searchParams.has("viewpoint")) {
|
||||
// Get marker from viewpoint param.
|
||||
// https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=48.857832,2.295226&heading=-45&pitch=38&fov=80
|
||||
console.log("viewpoint life")
|
||||
|
||||
let [, mlat, mlon] = url.pathname.match(dataLatLngRegex);
|
||||
const [mlat, mlon] = url.searchParams.get("viewpoint").split(",")
|
||||
|
||||
if (mapsFrontend == 'osm') return `${randomInstance}/search?query=${mlat}%2C${mlon}`;
|
||||
if (mapsFrontend == 'facil') return `${randomInstance}/#q=${mlat}%2C${mlon}`;
|
||||
if (mapsFrontend == "osm") return `${randomInstance}/search?query=${mlat}%2C${mlon}`
|
||||
if (mapsFrontend == "facil") return `${randomInstance}/#q=${mlat}%2C${mlon}`
|
||||
} else {
|
||||
// Use query as search if present.
|
||||
console.log("normal life")
|
||||
|
||||
} else if (url.searchParams.has("ll")) { // Get marker from ll param
|
||||
// https://maps.google.com/?ll=38.882147,-76.99017
|
||||
console.log("ll life");
|
||||
let query
|
||||
if (url.searchParams.has("q")) query = url.searchParams.get("q")
|
||||
else if (url.searchParams.has("query")) query = url.searchParams.get("query")
|
||||
else if (url.pathname.match(placeRegex)) query = url.pathname.match(placeRegex)[1]
|
||||
|
||||
const [mlat, mlon] = url.searchParams.get("ll").split(",");
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString()
|
||||
if (query) {
|
||||
if (mapsFrontend == "osm") return `${randomInstance}/search?query="${query}${mapCentre}&${prefsEncoded}`
|
||||
if (mapsFrontend == "facil") return `${randomInstance}/${mapCentre}/Mpnk/${query}`
|
||||
}
|
||||
}
|
||||
|
||||
if (mapsFrontend == 'osm') return `${randomInstance}/search?query=${mlat}%2C${mlon}`;
|
||||
if (mapsFrontend == 'facil') return `${randomInstance}/#q=${mlat}%2C${mlon}`
|
||||
} else if (url.searchParams.has("viewpoint")) { // Get marker from viewpoint param.
|
||||
// https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=48.857832,2.295226&heading=-45&pitch=38&fov=80
|
||||
console.log("viewpoint life");
|
||||
|
||||
const [mlat, mlon] = url.searchParams.get("viewpoint").split(",");
|
||||
|
||||
if (mapsFrontend == 'osm') return `${randomInstance}/search?query=${mlat}%2C${mlon}`;
|
||||
if (mapsFrontend == 'facil') return `${randomInstance}/#q=${mlat}%2C${mlon}`;
|
||||
} else { // Use query as search if present.
|
||||
console.log("normal life");
|
||||
|
||||
let query;
|
||||
if (url.searchParams.has("q")) query = url.searchParams.get("q");
|
||||
else if (url.searchParams.has("query")) query = url.searchParams.get("query");
|
||||
else if (url.pathname.match(placeRegex)) query = url.pathname.match(placeRegex)[1];
|
||||
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString();
|
||||
if (query) {
|
||||
if (mapsFrontend == 'osm') return `${randomInstance}/search?query="${query}${mapCentre}&${prefsEncoded}`;
|
||||
if (mapsFrontend == 'facil') return `${randomInstance}/${mapCentre}/Mpnk/${query}`;
|
||||
}
|
||||
}
|
||||
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString();
|
||||
console.log("mapCentre", mapCentre);
|
||||
console.log("prefs", prefs);
|
||||
console.log("prefsEncoded", prefsEncoded);
|
||||
if (mapsFrontend == 'osm') return `${randomInstance}/${mapCentre}&${prefsEncoded}`;
|
||||
if (mapsFrontend == 'facil') return `${randomInstance}/${mapCentre}/Mpnk`;
|
||||
let prefsEncoded = new URLSearchParams(prefs).toString()
|
||||
console.log("mapCentre", mapCentre)
|
||||
console.log("prefs", prefs)
|
||||
console.log("prefsEncoded", prefsEncoded)
|
||||
if (mapsFrontend == "osm") return `${randomInstance}/${mapCentre}&${prefsEncoded}`
|
||||
if (mapsFrontend == "facil") return `${randomInstance}/${mapCentre}/Mpnk`
|
||||
}
|
||||
|
||||
async function initDefaults() {
|
||||
return new Promise(resolve =>
|
||||
browser.storage.local.set({
|
||||
disableMaps: false,
|
||||
mapsFrontend: 'osm',
|
||||
mapsRedirects: redirects,
|
||||
facilNormalRedirectsChecks: [...redirects.facil.normal],
|
||||
facilNormalCustomRedirects: [],
|
||||
function initDefaults() {
|
||||
return new Promise(async resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(async data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
disableMaps: false,
|
||||
mapsFrontend: "osm",
|
||||
mapsRedirects: redirects,
|
||||
facilNormalRedirectsChecks: [...redirects.facil.normal],
|
||||
facilNormalCustomRedirects: [],
|
||||
|
||||
facilTorRedirectsChecks: [...redirects.facil.tor],
|
||||
facilTorCustomRedirects: [],
|
||||
facilTorRedirectsChecks: [...redirects.facil.tor],
|
||||
facilTorCustomRedirects: [],
|
||||
|
||||
facilI2pRedirectsChecks: [...redirects.facil.i2p],
|
||||
facilI2pCustomRedirects: [],
|
||||
|
||||
facilLokiRedirectsChecks: [...redirects.facil.loki],
|
||||
facilLokiCustomRedirects: []
|
||||
}, () => resolve())
|
||||
)
|
||||
facilI2pRedirectsChecks: [...redirects.facil.i2p],
|
||||
facilI2pCustomRedirects: [],
|
||||
|
||||
facilLokiRedirectsChecks: [...redirects.facil.loki],
|
||||
facilLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
redirect,
|
||||
initDefaults,
|
||||
};
|
||||
setRedirects,
|
||||
redirect,
|
||||
initDefaults,
|
||||
}
|
||||
|
|
|
@ -1,207 +1,219 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
import utils from './utils.js'
|
||||
window.browser = window.browser || window.chrome
|
||||
import utils from "./utils.js"
|
||||
|
||||
const targets = [
|
||||
// /(?:.*\.)*(?<!(link\.|cdn\-images\-\d+\.))medium\.com(\/.*)?$/,
|
||||
/^medium\.com/,
|
||||
/.*\.medium\.com/,
|
||||
// // Other domains of medium blogs, source(s): https://findingtom.com/best-medium-blogs-to-follow/#1-forge
|
||||
// /(?:.*\.)*(?<!(link\.|cdn\-images\-\d+\.))medium\.com(\/.*)?$/,
|
||||
/^medium\.com/,
|
||||
/.*\.medium\.com/,
|
||||
// // Other domains of medium blogs, source(s): https://findingtom.com/best-medium-blogs-to-follow/#1-forge
|
||||
|
||||
/^towardsdatascience\.com/,
|
||||
/^uxdesign\.cc/,
|
||||
/^uxplanet\.org/,
|
||||
/^betterprogramming\.pub/,
|
||||
/^aninjusticemag\.com/,
|
||||
/^betterhumans\.pub/,
|
||||
/^psiloveyou\.xyz/,
|
||||
/^entrepreneurshandbook\.co/,
|
||||
/^blog\.coinbase\.com/,
|
||||
/^towardsdatascience\.com/,
|
||||
/^uxdesign\.cc/,
|
||||
/^uxplanet\.org/,
|
||||
/^betterprogramming\.pub/,
|
||||
/^aninjusticemag\.com/,
|
||||
/^betterhumans\.pub/,
|
||||
/^psiloveyou\.xyz/,
|
||||
/^entrepreneurshandbook\.co/,
|
||||
/^blog\.coinbase\.com/,
|
||||
|
||||
/^ levelup\.gitconnected\.com /,
|
||||
/^javascript\.plainenglish\.io /,
|
||||
/^blog\.bitsrc\.io /,
|
||||
/^ itnext\.io /,
|
||||
/^codeburst\.io /,
|
||||
/^infosecwriteups\.com /,
|
||||
/^ blog\.devgenius.io /,
|
||||
/^ writingcooperative\.com /,
|
||||
];
|
||||
/^ levelup\.gitconnected\.com /,
|
||||
/^javascript\.plainenglish\.io /,
|
||||
/^blog\.bitsrc\.io /,
|
||||
/^ itnext\.io /,
|
||||
/^codeburst\.io /,
|
||||
/^infosecwriteups\.com /,
|
||||
/^ blog\.devgenius.io /,
|
||||
/^ writingcooperative\.com /,
|
||||
]
|
||||
|
||||
const frontends = new Array("scribe")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
||||
let redirects = {};
|
||||
let redirects = {}
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get('cloudflareBlackList', r => {
|
||||
redirects.scribe = val;
|
||||
scribeNormalRedirectsChecks = [...redirects.scribe.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = scribeNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) scribeNormalRedirectsChecks.splice(a, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
mediumRedirects: redirects,
|
||||
scribeNormalRedirectsChecks
|
||||
})
|
||||
})
|
||||
browser.storage.local.get("cloudflareBlackList", r => {
|
||||
redirects.scribe = val
|
||||
scribeNormalRedirectsChecks = [...redirects.scribe.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = scribeNormalRedirectsChecks.indexOf(instance)
|
||||
if (a > -1) scribeNormalRedirectsChecks.splice(a, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
mediumRedirects: redirects,
|
||||
scribeNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
disableMedium,
|
||||
mediumRedirects,
|
||||
scribeNormalRedirectsChecks,
|
||||
scribeNormalCustomRedirects,
|
||||
scribeTorRedirectsChecks,
|
||||
scribeTorCustomRedirects,
|
||||
scribeI2pCustomRedirects,
|
||||
scribeLokiCustomRedirects,
|
||||
protocol,
|
||||
protocolFallback;
|
||||
let disableMedium,
|
||||
mediumRedirects,
|
||||
scribeNormalRedirectsChecks,
|
||||
scribeNormalCustomRedirects,
|
||||
scribeTorRedirectsChecks,
|
||||
scribeTorCustomRedirects,
|
||||
scribeI2pCustomRedirects,
|
||||
scribeLokiCustomRedirects,
|
||||
protocol,
|
||||
protocolFallback
|
||||
|
||||
function init() {
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableMedium",
|
||||
"mediumRedirects",
|
||||
"scribeNormalRedirectsChecks",
|
||||
"scribeNormalCustomRedirects",
|
||||
"scribeTorRedirectsChecks",
|
||||
"scribeTorCustomRedirects",
|
||||
"scribeI2pCustomRedirects",
|
||||
"scribeLokiCustomRedirects",
|
||||
"protocol",
|
||||
"protocolFallback"
|
||||
],
|
||||
r => {
|
||||
disableMedium = r.disableMedium;
|
||||
mediumRedirects = r.mediumRedirects;
|
||||
scribeNormalRedirectsChecks = r.scribeNormalRedirectsChecks;
|
||||
scribeNormalCustomRedirects = r.scribeNormalCustomRedirects;
|
||||
scribeTorRedirectsChecks = r.scribeTorRedirectsChecks;
|
||||
scribeTorCustomRedirects = r.scribeTorCustomRedirects;
|
||||
scribeI2pCustomRedirects = r.scribeI2pCustomRedirects;
|
||||
scribeLokiCustomRedirects = r.scribeLokiCustomRedirects;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableMedium",
|
||||
"mediumRedirects",
|
||||
"scribeNormalRedirectsChecks",
|
||||
"scribeNormalCustomRedirects",
|
||||
"scribeTorRedirectsChecks",
|
||||
"scribeTorCustomRedirects",
|
||||
"scribeI2pCustomRedirects",
|
||||
"scribeLokiCustomRedirects",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
],
|
||||
r => {
|
||||
disableMedium = r.disableMedium
|
||||
mediumRedirects = r.mediumRedirects
|
||||
scribeNormalRedirectsChecks = r.scribeNormalRedirectsChecks
|
||||
scribeNormalCustomRedirects = r.scribeNormalCustomRedirects
|
||||
scribeTorRedirectsChecks = r.scribeTorRedirectsChecks
|
||||
scribeTorCustomRedirects = r.scribeTorCustomRedirects
|
||||
scribeI2pCustomRedirects = r.scribeI2pCustomRedirects
|
||||
scribeLokiCustomRedirects = r.scribeLokiCustomRedirects
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function redirect(url, type, initiator, disableOverride) {
|
||||
if (disableMedium && !disableOverride) return;
|
||||
if (url.pathname == "/" && !disableOverride) return;
|
||||
if (type != "main_frame" && "sub_frame" && "xmlhttprequest" && "other") return;
|
||||
if (initiator && (
|
||||
[
|
||||
...mediumRedirects.scribe.normal,
|
||||
...mediumRedirects.scribe.tor,
|
||||
...scribeNormalCustomRedirects,
|
||||
...scribeTorCustomRedirects,
|
||||
...scribeI2pCustomRedirects,
|
||||
...scribeLokiCustomRedirects
|
||||
].includes(initiator.origin))) return;
|
||||
if (disableMedium && !disableOverride) return
|
||||
if (url.pathname == "/" && !disableOverride) return
|
||||
if (type != "main_frame" && "sub_frame" && "xmlhttprequest" && "other") return
|
||||
if (
|
||||
initiator &&
|
||||
[...mediumRedirects.scribe.normal, ...mediumRedirects.scribe.tor, ...scribeNormalCustomRedirects, ...scribeTorCustomRedirects, ...scribeI2pCustomRedirects, ...scribeLokiCustomRedirects].includes(
|
||||
initiator.origin
|
||||
)
|
||||
)
|
||||
return
|
||||
|
||||
if (!targets.some(rx => rx.test(url.host))) return;
|
||||
if (/^\/(@[a-zA-Z.]{0,}(\/|)$)/.test(url.pathname)) return;
|
||||
if (!targets.some(rx => rx.test(url.host))) return
|
||||
if (/^\/(@[a-zA-Z.]{0,}(\/|)$)/.test(url.pathname)) return
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...scribeLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...scribeI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) { return; }
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...scribeLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...scribeI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects]
|
||||
}
|
||||
if (instancesList.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
return `${randomInstance}${url.pathname}${url.search}`;
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
return `${randomInstance}${url.pathname}${url.search}`
|
||||
}
|
||||
|
||||
function switchInstance(url, disableOverride) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableMedium && !disableOverride) { resolve(); return; }
|
||||
let protocolHost = utils.protocolHost(url);
|
||||
const all = [
|
||||
...mediumRedirects.scribe.tor,
|
||||
...mediumRedirects.scribe.normal,
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableMedium && !disableOverride) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let protocolHost = utils.protocolHost(url)
|
||||
const all = [
|
||||
...mediumRedirects.scribe.tor,
|
||||
...mediumRedirects.scribe.normal,
|
||||
|
||||
...scribeNormalCustomRedirects,
|
||||
...scribeTorCustomRedirects,
|
||||
...scribeI2pCustomRedirects,
|
||||
...scribeLokiCustomRedirects
|
||||
];
|
||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
||||
...scribeNormalCustomRedirects,
|
||||
...scribeTorCustomRedirects,
|
||||
...scribeI2pCustomRedirects,
|
||||
...scribeLokiCustomRedirects,
|
||||
]
|
||||
if (!all.includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...scribeLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...scribeI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects];
|
||||
}
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...scribeLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...scribeI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects]
|
||||
}
|
||||
|
||||
const i = instancesList.indexOf(protocolHost);
|
||||
if (i > -1) instancesList.splice(i, 1);
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
const i = instancesList.indexOf(protocolHost)
|
||||
if (i > -1) instancesList.splice(i, 1)
|
||||
if (instancesList.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
})
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get('cloudflareBlackList',
|
||||
async r => {
|
||||
scribeNormalRedirectsChecks = [...redirects.scribe.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
let i = scribeNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) scribeNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
disableMedium: false,
|
||||
mediumRedirects: redirects,
|
||||
return new Promise(resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||
scribeNormalRedirectsChecks = [...redirects.scribe.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
let i = scribeNormalRedirectsChecks.indexOf(instance)
|
||||
if (i > -1) scribeNormalRedirectsChecks.splice(i, 1)
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
disableMedium: false,
|
||||
mediumRedirects: redirects,
|
||||
|
||||
scribeNormalRedirectsChecks: scribeNormalRedirectsChecks,
|
||||
scribeNormalCustomRedirects: [],
|
||||
scribeNormalRedirectsChecks: scribeNormalRedirectsChecks,
|
||||
scribeNormalCustomRedirects: [],
|
||||
|
||||
scribeTorRedirectsChecks: [...redirects.scribe.tor],
|
||||
scribeTorCustomRedirects: [],
|
||||
scribeTorRedirectsChecks: [...redirects.scribe.tor],
|
||||
scribeTorCustomRedirects: [],
|
||||
|
||||
scribeI2pRedirectsChecks: [...redirects.scribe.i2p],
|
||||
scribeI2pCustomRedirects: [],
|
||||
scribeI2pRedirectsChecks: [...redirects.scribe.i2p],
|
||||
scribeI2pCustomRedirects: [],
|
||||
|
||||
scribeLokiRedirectsChecks: [...redirects.scribe.loki],
|
||||
scribeLokiCustomRedirects: []
|
||||
}, () => resolve())
|
||||
})
|
||||
})
|
||||
})
|
||||
scribeLokiRedirectsChecks: [...redirects.scribe.loki],
|
||||
scribeLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
redirect,
|
||||
switchInstance,
|
||||
initDefaults,
|
||||
};
|
||||
setRedirects,
|
||||
redirect,
|
||||
switchInstance,
|
||||
initDefaults,
|
||||
}
|
||||
|
|
|
@ -1,180 +1,201 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
import utils from './utils.js'
|
||||
import utils from "./utils.js"
|
||||
|
||||
let redirects = {
|
||||
"simpleertube": {
|
||||
"normal": [
|
||||
"https://tube.simple-web.org",
|
||||
"https://tube.ftild3.org",
|
||||
"https://stube.alefvanoon.xyz",
|
||||
"https://st.phreedom.club",
|
||||
"https://simpleertube.esmailelbob.xyz",
|
||||
],
|
||||
"tor": [],
|
||||
"i2p": [],
|
||||
"loki": []
|
||||
}
|
||||
const frontends = new Array("simpleertube")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
||||
let redirects = {}
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
function setRedirects(val) {
|
||||
redirects.simpleertube = val;
|
||||
browser.storage.local.set({ peertubeTargetsRedirects: redirects })
|
||||
for (const item of simpleertubeNormalRedirectsChecks)
|
||||
if (!redirects.simpleertube.normal.includes(item)) {
|
||||
var index = simpleertubeNormalRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) simpleertubeNormalRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ simpleertubeNormalRedirectsChecks })
|
||||
|
||||
for (const item of simpleertubeTorRedirectsChecks)
|
||||
if (!redirects.simpleertube.normal.includes(item)) {
|
||||
var index = simpleertubeTorRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) simpleertubeTorRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ simpleertubeTorRedirectsChecks })
|
||||
browser.storage.local.get("cloudflareBlackList", r => {
|
||||
redirects.simpleertube = val
|
||||
simpleertubeNormalRedirectsChecks = [...redirects.simpleertube.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = simpleertubeNormalRedirectsChecks.indexOf(instance)
|
||||
if (a > -1) simpleertubeNormalRedirectsChecks.splice(a, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
peertubeRedirects: redirects,
|
||||
simpleertubeNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
disablePeertubeTargets,
|
||||
peertubeRedirects,
|
||||
simpleertubeNormalRedirectsChecks,
|
||||
simpleertubeNormalCustomRedirects,
|
||||
simpleertubeTorRedirectsChecks,
|
||||
simpleertubeTorCustomRedirects,
|
||||
simpleertubeI2pCustomRedirects,
|
||||
simpleertubeLokiCustomRedirects,
|
||||
peerTubeTargets,
|
||||
protocol,
|
||||
protocolFallback;
|
||||
let disablePeertubeTargets,
|
||||
peertubeRedirects,
|
||||
simpleertubeNormalRedirectsChecks,
|
||||
simpleertubeNormalCustomRedirects,
|
||||
simpleertubeTorRedirectsChecks,
|
||||
simpleertubeTorCustomRedirects,
|
||||
simpleertubeI2pRedirectsChecks,
|
||||
simpleertubeI2pCustomRedirects,
|
||||
simpleertubeLokiRedirectsChecks,
|
||||
simpleertubeLokiCustomRedirects,
|
||||
peerTubeTargets,
|
||||
protocol,
|
||||
protocolFallback
|
||||
|
||||
function init() {
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disablePeertubeTargets",
|
||||
"peertubeRedirects",
|
||||
"simpleertubeNormalRedirectsChecks",
|
||||
"simpleertubeNormalCustomRedirects",
|
||||
"simpleertubeTorRedirectsChecks",
|
||||
"simpleertubeTorCustomRedirects",
|
||||
"simpleertubeI2pCustomRedirects",
|
||||
"simpleertubeLokiCustomRedirects",
|
||||
"peerTubeTargets",
|
||||
"protocol",
|
||||
"protocolFallback"
|
||||
],
|
||||
r => {
|
||||
disablePeertubeTargets = r.disablePeertubeTargets;
|
||||
peertubeRedirects = r.peertubeRedirects;
|
||||
simpleertubeNormalRedirectsChecks = r.simpleertubeNormalRedirectsChecks;
|
||||
simpleertubeNormalCustomRedirects = r.simpleertubeNormalCustomRedirects;
|
||||
simpleertubeTorRedirectsChecks = r.simpleertubeTorRedirectsChecks;
|
||||
simpleertubeTorCustomRedirects = r.simpleertubeTorCustomRedirects;
|
||||
simpleertubeI2pCustomRedirects = r.simpleertubeI2pCustomRedirects;
|
||||
simpleertubeLokiCustomRedirects = r.simpleertubeLokiCustomRedirects;
|
||||
peerTubeTargets = r.peerTubeTargets;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disablePeertubeTargets",
|
||||
"peertubeRedirects",
|
||||
"simpleertubeNormalRedirectsChecks",
|
||||
"simpleertubeNormalCustomRedirects",
|
||||
"simpleertubeTorRedirectsChecks",
|
||||
"simpleertubeTorCustomRedirects",
|
||||
"simpleertubeI2pRedirectsChecks",
|
||||
"simpleertubeI2pCustomRedirects",
|
||||
"simpleertubeLokiRedirectsChecks",
|
||||
"simpleertubeLokiCustomRedirects",
|
||||
"peerTubeTargets",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
],
|
||||
r => {
|
||||
disablePeertubeTargets = r.disablePeertubeTargets
|
||||
peertubeRedirects = r.peertubeRedirects
|
||||
simpleertubeNormalRedirectsChecks = r.simpleertubeNormalRedirectsChecks
|
||||
simpleertubeNormalCustomRedirects = r.simpleertubeNormalCustomRedirects
|
||||
simpleertubeTorRedirectsChecks = r.simpleertubeTorRedirectsChecks
|
||||
simpleertubeTorCustomRedirects = r.simpleertubeTorCustomRedirects
|
||||
simpleertubeI2pRedirectsChecks = r.simpleertubeI2pRedirectsChecks
|
||||
simpleertubeI2pCustomRedirects = r.simpleertubeI2pCustomRedirects
|
||||
simpleertubeLokiRedirectsChecks = r.simpleertubeLokiRedirectsChecks
|
||||
simpleertubeLokiCustomRedirects = r.simpleertubeLokiCustomRedirects
|
||||
peerTubeTargets = r.peerTubeTargets
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function all() {
|
||||
return [
|
||||
...redirects.simpleertube.normal,
|
||||
...redirects.simpleertube.tor,
|
||||
...simpleertubeNormalCustomRedirects,
|
||||
...simpleertubeTorCustomRedirects,
|
||||
...simpleertubeI2pCustomRedirects,
|
||||
...simpleertubeLokiCustomRedirects
|
||||
];
|
||||
return [
|
||||
...simpleertubeNormalRedirectsChecks,
|
||||
...simpleertubeTorRedirectsChecks,
|
||||
...simpleertubeI2pRedirectsChecks,
|
||||
...simpleertubeLokiRedirectsChecks,
|
||||
...simpleertubeNormalCustomRedirects,
|
||||
...simpleertubeTorCustomRedirects,
|
||||
...simpleertubeI2pCustomRedirects,
|
||||
...simpleertubeLokiCustomRedirects,
|
||||
]
|
||||
}
|
||||
|
||||
function redirect(url, type, initiator, disableOverride) {
|
||||
if (disablePeertubeTargets && !disableOverride) return;
|
||||
if (initiator && (all().includes(initiator.origin) || peerTubeTargets.includes(initiator.host))) return;
|
||||
let protocolHost = utils.protocolHost(url);
|
||||
if (!peerTubeTargets.includes(protocolHost)) return;
|
||||
if (type != "main_frame") return;
|
||||
if (disablePeertubeTargets && !disableOverride) return
|
||||
if (initiator && (all().includes(initiator.origin) || peerTubeTargets.includes(initiator.host))) return
|
||||
let protocolHost = utils.protocolHost(url)
|
||||
if (!peerTubeTargets.includes(protocolHost)) return
|
||||
if (type != "main_frame") return
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...simpleertubeLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...simpleertubeI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) { return; }
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...simpleertubeLokiRedirectsChecks, ...simpleertubeLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...simpleertubeI2pRedirectsChecks, ...simpleertubeI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects]
|
||||
}
|
||||
if (instancesList.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
if (url.host == 'search.joinpeertube.org' || url.host == 'sepiasearch.org') return randomInstance;
|
||||
return `${randomInstance}/${url.host}${url.pathname}${url.search}`;
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
if (url.host == "search.joinpeertube.org" || url.host == "sepiasearch.org") return randomInstance
|
||||
return `${randomInstance}/${url.host}${url.pathname}${url.search}`
|
||||
}
|
||||
|
||||
function switchInstance(url, disableOverride) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disablePeertubeTargets && !disableOverride) { resolve(); return; }
|
||||
const protocolHost = utils.protocolHost(url);
|
||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disablePeertubeTargets && !disableOverride) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
const protocolHost = utils.protocolHost(url)
|
||||
if (!all().includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...simpleertubeLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...simpleertubeI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects];
|
||||
}
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...simpleertubeLokiRedirectsChecks, ...simpleertubeLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...simpleertubeI2pRedirectsChecks, ...simpleertubeI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects]
|
||||
}
|
||||
|
||||
const i = instancesList.indexOf(protocolHost);
|
||||
if (i > -1) instancesList.splice(i, 1);
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
const i = instancesList.indexOf(protocolHost)
|
||||
if (i > -1) instancesList.splice(i, 1)
|
||||
if (instancesList.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
})
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
browser.storage.local.get('cloudflareBlackList', async r => {
|
||||
simpleertubeNormalRedirectsChecks = [...redirects.simpleertube.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
let i = simpleertubeNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) simpleertubeNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
peerTubeTargets: ['https://search.joinpeertube.org', ...dataJson.peertube],
|
||||
disablePeertubeTargets: true,
|
||||
peertubeRedirects: redirects,
|
||||
return new Promise(resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||
simpleertubeNormalRedirectsChecks = [...redirects.simpleertube.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
let i = simpleertubeNormalRedirectsChecks.indexOf(instance)
|
||||
if (i > -1) simpleertubeNormalRedirectsChecks.splice(i, 1)
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
peerTubeTargets: ["https://search.joinpeertube.org", ...dataJson.peertube],
|
||||
disablePeertubeTargets: true,
|
||||
peertubeRedirects: redirects,
|
||||
|
||||
simpleertubeNormalRedirectsChecks: simpleertubeNormalRedirectsChecks,
|
||||
simpleertubeNormalCustomRedirects: [],
|
||||
simpleertubeNormalRedirectsChecks: simpleertubeNormalRedirectsChecks,
|
||||
simpleertubeNormalCustomRedirects: [],
|
||||
|
||||
simpleertubeTorRedirectsChecks: [...redirects.simpleertube.tor],
|
||||
simpleertubeTorCustomRedirects: [],
|
||||
simpleertubeTorRedirectsChecks: [...redirects.simpleertube.tor],
|
||||
simpleertubeTorCustomRedirects: [],
|
||||
|
||||
simpleertubeI2pRedirectsChecks: [...redirects.simpleertube.i2p],
|
||||
simpleertubeI2pCustomRedirects: [],
|
||||
simpleertubeI2pRedirectsChecks: [...redirects.simpleertube.i2p],
|
||||
simpleertubeI2pCustomRedirects: [],
|
||||
|
||||
simpleertubeLokiRedirectsChecks: [...redirects.simpleertube.loki],
|
||||
simpleertubeLokiCustomRedirects: []
|
||||
}, () => resolve());
|
||||
})
|
||||
})
|
||||
})
|
||||
simpleertubeLokiRedirectsChecks: [...redirects.simpleertube.loki],
|
||||
simpleertubeLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
switchInstance,
|
||||
redirect,
|
||||
initDefaults,
|
||||
};
|
||||
setRedirects,
|
||||
switchInstance,
|
||||
redirect,
|
||||
initDefaults,
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
import utils from './utils.js'
|
||||
import utils from "./utils.js"
|
||||
|
||||
const targets = [
|
||||
/^https?:\/{2}(www\.|)quora\.com.*/
|
||||
];
|
||||
const targets = [/^https?:\/{2}(www\.|)quora\.com.*/]
|
||||
|
||||
let redirects = {}
|
||||
|
||||
|
@ -12,183 +10,183 @@ const frontends = new Array("quetre")
|
|||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get('cloudflareBlackList', r => {
|
||||
redirects.quetre = val;
|
||||
quetreNormalRedirectsChecks = [...redirects.quetre.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = quetreNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) quetreNormalRedirectsChecks.splice(a, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
quoraRedirects: redirects,
|
||||
quetreNormalRedirectsChecks
|
||||
})
|
||||
})
|
||||
browser.storage.local.get("cloudflareBlackList", r => {
|
||||
redirects.quetre = val
|
||||
quetreNormalRedirectsChecks = [...redirects.quetre.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = quetreNormalRedirectsChecks.indexOf(instance)
|
||||
if (a > -1) quetreNormalRedirectsChecks.splice(a, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
quoraRedirects: redirects,
|
||||
quetreNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
disableQuora,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
quoraRedirects,
|
||||
quetreNormalRedirectsChecks,
|
||||
quetreNormalCustomRedirects,
|
||||
quetreTorRedirectsChecks,
|
||||
quetreTorCustomRedirects,
|
||||
quetreI2pCustomRedirects,
|
||||
quetreLokiCustomRedirects;
|
||||
let disableQuora,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
quoraRedirects,
|
||||
quetreNormalRedirectsChecks,
|
||||
quetreNormalCustomRedirects,
|
||||
quetreTorRedirectsChecks,
|
||||
quetreTorCustomRedirects,
|
||||
quetreI2pCustomRedirects,
|
||||
quetreLokiCustomRedirects
|
||||
|
||||
function init() {
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableQuora",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"quoraRedirects",
|
||||
"quetreNormalRedirectsChecks",
|
||||
"quetreNormalCustomRedirects",
|
||||
"quetreTorRedirectsChecks",
|
||||
"quetreTorCustomRedirects",
|
||||
"quetreI2pCustomRedirects",
|
||||
"quetreLokiCustomRedirects"
|
||||
],
|
||||
r => {
|
||||
disableQuora = r.disableQuora;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
quoraRedirects = r.quoraRedirects;
|
||||
quetreNormalRedirectsChecks = r.quetreNormalRedirectsChecks;
|
||||
quetreNormalCustomRedirects = r.quetreNormalCustomRedirects;
|
||||
quetreTorRedirectsChecks = r.quetreTorRedirectsChecks;
|
||||
quetreTorCustomRedirects = r.quetreTorCustomRedirects;
|
||||
quetreI2pCustomRedirects = r.quetreI2pCustomRedirects;
|
||||
quetreLokiCustomRedirects = r.quetreLokiCustomRedirects;
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableQuora",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"quoraRedirects",
|
||||
"quetreNormalRedirectsChecks",
|
||||
"quetreNormalCustomRedirects",
|
||||
"quetreTorRedirectsChecks",
|
||||
"quetreTorCustomRedirects",
|
||||
"quetreI2pCustomRedirects",
|
||||
"quetreLokiCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disableQuora = r.disableQuora
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
quoraRedirects = r.quoraRedirects
|
||||
quetreNormalRedirectsChecks = r.quetreNormalRedirectsChecks
|
||||
quetreNormalCustomRedirects = r.quetreNormalCustomRedirects
|
||||
quetreTorRedirectsChecks = r.quetreTorRedirectsChecks
|
||||
quetreTorCustomRedirects = r.quetreTorCustomRedirects
|
||||
quetreI2pCustomRedirects = r.quetreI2pCustomRedirects
|
||||
quetreLokiCustomRedirects = r.quetreLokiCustomRedirects
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function redirect(url, type, initiator, disableOverride) {
|
||||
if (disableQuora && !disableOverride) return;
|
||||
if (url.pathname == "/" && !disableOverride) return;
|
||||
if (type != "main_frame") return;
|
||||
const all = [
|
||||
...quoraRedirects.quetre.normal,
|
||||
...quetreNormalCustomRedirects
|
||||
];
|
||||
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return;
|
||||
if (!targets.some(rx => rx.test(url.href))) return;
|
||||
if (disableQuora && !disableOverride) return
|
||||
if (url.pathname == "/" && !disableOverride) return
|
||||
if (type != "main_frame") return
|
||||
const all = [...quoraRedirects.quetre.normal, ...quetreNormalCustomRedirects]
|
||||
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return
|
||||
if (!targets.some(rx => rx.test(url.href))) return
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...quetreLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...quetreI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...quetreNormalRedirectsChecks, ...quetreNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) { return; }
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...quetreLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...quetreI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...quetreNormalRedirectsChecks, ...quetreNormalCustomRedirects]
|
||||
}
|
||||
if (instancesList.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
return `${randomInstance}${url.pathname}`;
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
return `${randomInstance}${url.pathname}`
|
||||
}
|
||||
|
||||
function reverse(url) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
let protocolHost = utils.protocolHost(url);
|
||||
const all = [
|
||||
...quoraRedirects.quetre.normal,
|
||||
...quoraRedirects.quetre.tor,
|
||||
...quetreNormalCustomRedirects,
|
||||
...quetreTorCustomRedirects,
|
||||
...quetreI2pCustomRedirects,
|
||||
...quetreLokiCustomRedirects
|
||||
];
|
||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
let protocolHost = utils.protocolHost(url)
|
||||
const all = [...quoraRedirects.quetre.normal, ...quoraRedirects.quetre.tor, ...quetreNormalCustomRedirects, ...quetreTorCustomRedirects, ...quetreI2pCustomRedirects, ...quetreLokiCustomRedirects]
|
||||
if (!all.includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
resolve(`https://quora.com${url.pathname}${url.search}`);
|
||||
})
|
||||
resolve(`https://quora.com${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function switchInstance(url, disableOverride) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableQuora && !disableOverride) { resolve(); return; }
|
||||
let protocolHost = utils.protocolHost(url);
|
||||
const all = [
|
||||
...quoraRedirects.quetre.tor,
|
||||
...quoraRedirects.quetre.normal,
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableQuora && !disableOverride) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let protocolHost = utils.protocolHost(url)
|
||||
const all = [...quoraRedirects.quetre.tor, ...quoraRedirects.quetre.normal, ...quetreNormalCustomRedirects, ...quetreTorCustomRedirects, ...quetreI2pCustomRedirects, ...quetreLokiCustomRedirects]
|
||||
if (!all.includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
...quetreNormalCustomRedirects,
|
||||
...quetreTorCustomRedirects,
|
||||
...quetreI2pCustomRedirects,
|
||||
...quetreLokiCustomRedirects
|
||||
];
|
||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...quetreLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...quetreI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...quetreNormalRedirectsChecks, ...quetreNormalCustomRedirects]
|
||||
}
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...quetreLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...quetreI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...quetreNormalRedirectsChecks, ...quetreNormalCustomRedirects];
|
||||
}
|
||||
const i = instancesList.indexOf(protocolHost)
|
||||
if (i > -1) instancesList.splice(i, 1)
|
||||
if (instancesList.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
const i = instancesList.indexOf(protocolHost);
|
||||
if (i > -1) instancesList.splice(i, 1);
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
})
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(async resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.set({
|
||||
disableQuora: false,
|
||||
return new Promise(async resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(async data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
disableQuora: false,
|
||||
|
||||
quoraRedirects: redirects,
|
||||
quoraRedirects: redirects,
|
||||
|
||||
quetreNormalRedirectsChecks: [...redirects.quetre.normal],
|
||||
quetreNormalCustomRedirects: [],
|
||||
quetreNormalRedirectsChecks: [...redirects.quetre.normal],
|
||||
quetreNormalCustomRedirects: [],
|
||||
|
||||
quetreTorRedirectsChecks: [...redirects.quetre.tor],
|
||||
quetreTorCustomRedirects: [],
|
||||
quetreTorRedirectsChecks: [...redirects.quetre.tor],
|
||||
quetreTorCustomRedirects: [],
|
||||
|
||||
quetreI2pRedirectsChecks: [...redirects.quetre.i2p],
|
||||
quetreI2pCustomRedirects: [],
|
||||
quetreI2pRedirectsChecks: [...redirects.quetre.i2p],
|
||||
quetreI2pCustomRedirects: [],
|
||||
|
||||
quetreLokiRedirectsChecks: [...redirects.quetre.loki],
|
||||
quetreLokiCustomRedirects: []
|
||||
}, () => resolve());
|
||||
});
|
||||
})
|
||||
quetreLokiRedirectsChecks: [...redirects.quetre.loki],
|
||||
quetreLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
setRedirects,
|
||||
|
||||
redirect,
|
||||
reverse,
|
||||
switchInstance,
|
||||
redirect,
|
||||
reverse,
|
||||
switchInstance,
|
||||
|
||||
initDefaults
|
||||
};
|
||||
initDefaults,
|
||||
}
|
||||
|
|
|
@ -1,264 +1,261 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
import utils from './utils.js'
|
||||
import utils from "./utils.js"
|
||||
|
||||
const targets = [
|
||||
/^https?:\/{2}(www\.|old\.|np\.|new\.|amp\.|)reddit\.com/,
|
||||
/^https?:\/{2}(i\.|preview\.)redd\.it/,
|
||||
];
|
||||
let redirects = {};
|
||||
const targets = [/^https?:\/{2}(www\.|old\.|np\.|new\.|amp\.|)reddit\.com/, /^https?:\/{2}(i\.|preview\.)redd\.it/]
|
||||
let redirects = {}
|
||||
|
||||
const frontends = new Array("libreddit", "teddit")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get('cloudflareBlackList', r => {
|
||||
redirects = val;
|
||||
libredditNormalRedirectsChecks = [...redirects.libreddit.normal];
|
||||
tedditNormalRedirectsChecks = [...redirects.teddit.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = libredditNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) libredditNormalRedirectsChecks.splice(a, 1);
|
||||
browser.storage.local.get("cloudflareBlackList", r => {
|
||||
redirects = val
|
||||
libredditNormalRedirectsChecks = [...redirects.libreddit.normal]
|
||||
tedditNormalRedirectsChecks = [...redirects.teddit.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = libredditNormalRedirectsChecks.indexOf(instance)
|
||||
if (a > -1) libredditNormalRedirectsChecks.splice(a, 1)
|
||||
|
||||
const b = tedditNormalRedirectsChecks.indexOf(instance);
|
||||
if (b > -1) tedditNormalRedirectsChecks.splice(b, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
redditRedirects: redirects,
|
||||
libredditNormalRedirectsChecks,
|
||||
tedditNormalRedirectsChecks
|
||||
})
|
||||
})
|
||||
const b = tedditNormalRedirectsChecks.indexOf(instance)
|
||||
if (b > -1) tedditNormalRedirectsChecks.splice(b, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
redditRedirects: redirects,
|
||||
libredditNormalRedirectsChecks,
|
||||
tedditNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
disableReddit,
|
||||
redditFrontend,
|
||||
redditRedirects,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
|
||||
libredditNormalRedirectsChecks,
|
||||
libredditNormalCustomRedirects,
|
||||
|
||||
libredditTorRedirectsChecks,
|
||||
libredditTorCustomRedirects,
|
||||
|
||||
libredditI2pCustomRedirects,
|
||||
|
||||
libredditLokiCustomRedirects,
|
||||
|
||||
tedditNormalRedirectsChecks,
|
||||
tedditNormalCustomRedirects,
|
||||
|
||||
tedditTorRedirectsChecks,
|
||||
tedditTorCustomRedirects,
|
||||
|
||||
tedditI2pCustomRedirects,
|
||||
tedditLokiCustomRedirects;
|
||||
let disableReddit,
|
||||
redditFrontend,
|
||||
redditRedirects,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
libredditNormalRedirectsChecks,
|
||||
libredditNormalCustomRedirects,
|
||||
libredditTorRedirectsChecks,
|
||||
libredditTorCustomRedirects,
|
||||
libredditI2pCustomRedirects,
|
||||
libredditLokiCustomRedirects,
|
||||
tedditNormalRedirectsChecks,
|
||||
tedditNormalCustomRedirects,
|
||||
tedditTorRedirectsChecks,
|
||||
tedditTorCustomRedirects,
|
||||
tedditI2pCustomRedirects,
|
||||
tedditLokiCustomRedirects
|
||||
|
||||
function init() {
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableReddit",
|
||||
"redditFrontend",
|
||||
"redditRedirects",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"libredditNormalRedirectsChecks",
|
||||
"libredditNormalCustomRedirects",
|
||||
"libredditTorRedirectsChecks",
|
||||
"libredditTorCustomRedirects",
|
||||
"libredditI2pCustomRedirects",
|
||||
"libredditLokiCustomRedirects",
|
||||
"tedditNormalRedirectsChecks",
|
||||
"tedditNormalCustomRedirects",
|
||||
"tedditTorRedirectsChecks",
|
||||
"tedditTorCustomRedirects",
|
||||
"tedditI2pCustomRedirects",
|
||||
"tedditLokiCustomRedirects"
|
||||
],
|
||||
r => {
|
||||
disableReddit = r.disableReddit;
|
||||
redditFrontend = r.redditFrontend;
|
||||
redditRedirects = r.redditRedirects;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
libredditNormalRedirectsChecks = r.libredditNormalRedirectsChecks;
|
||||
libredditNormalCustomRedirects = r.libredditNormalCustomRedirects;
|
||||
libredditTorRedirectsChecks = r.libredditTorRedirectsChecks;
|
||||
libredditTorCustomRedirects = r.libredditTorCustomRedirects;
|
||||
libredditI2pCustomRedirects = r.libredditI2pCustomRedirects;
|
||||
libredditLokiCustomRedirects = r.libredditLokiCustomRedirects;
|
||||
tedditNormalRedirectsChecks = r.tedditNormalRedirectsChecks;
|
||||
tedditNormalCustomRedirects = r.tedditNormalCustomRedirects;
|
||||
tedditTorRedirectsChecks = r.tedditTorRedirectsChecks;
|
||||
tedditTorCustomRedirects = r.tedditTorCustomRedirects;
|
||||
tedditI2pCustomRedirects = r.tedditI2pCustomRedirects;
|
||||
tedditLokiCustomRedirects = r.tedditLokiCustomRedirects;
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableReddit",
|
||||
"redditFrontend",
|
||||
"redditRedirects",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"libredditNormalRedirectsChecks",
|
||||
"libredditNormalCustomRedirects",
|
||||
"libredditTorRedirectsChecks",
|
||||
"libredditTorCustomRedirects",
|
||||
"libredditI2pCustomRedirects",
|
||||
"libredditLokiCustomRedirects",
|
||||
"tedditNormalRedirectsChecks",
|
||||
"tedditNormalCustomRedirects",
|
||||
"tedditTorRedirectsChecks",
|
||||
"tedditTorCustomRedirects",
|
||||
"tedditI2pCustomRedirects",
|
||||
"tedditLokiCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disableReddit = r.disableReddit
|
||||
redditFrontend = r.redditFrontend
|
||||
redditRedirects = r.redditRedirects
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
libredditNormalRedirectsChecks = r.libredditNormalRedirectsChecks
|
||||
libredditNormalCustomRedirects = r.libredditNormalCustomRedirects
|
||||
libredditTorRedirectsChecks = r.libredditTorRedirectsChecks
|
||||
libredditTorCustomRedirects = r.libredditTorCustomRedirects
|
||||
libredditI2pCustomRedirects = r.libredditI2pCustomRedirects
|
||||
libredditLokiCustomRedirects = r.libredditLokiCustomRedirects
|
||||
tedditNormalRedirectsChecks = r.tedditNormalRedirectsChecks
|
||||
tedditNormalCustomRedirects = r.tedditNormalCustomRedirects
|
||||
tedditTorRedirectsChecks = r.tedditTorRedirectsChecks
|
||||
tedditTorCustomRedirects = r.tedditTorCustomRedirects
|
||||
tedditI2pCustomRedirects = r.tedditI2pCustomRedirects
|
||||
tedditLokiCustomRedirects = r.tedditLokiCustomRedirects
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function initLibredditCookies(test, from) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
const protocolHost = utils.protocolHost(from);
|
||||
if (![
|
||||
...libredditNormalRedirectsChecks,
|
||||
...libredditTorRedirectsChecks,
|
||||
...libredditNormalCustomRedirects,
|
||||
...libredditTorCustomRedirects,
|
||||
...libredditI2pCustomRedirects,
|
||||
...libredditLokiCustomRedirects
|
||||
].includes(protocolHost)) { resolve(); return; }
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
const protocolHost = utils.protocolHost(from)
|
||||
if (
|
||||
![
|
||||
...libredditNormalRedirectsChecks,
|
||||
...libredditTorRedirectsChecks,
|
||||
...libredditNormalCustomRedirects,
|
||||
...libredditTorCustomRedirects,
|
||||
...libredditI2pCustomRedirects,
|
||||
...libredditLokiCustomRedirects,
|
||||
].includes(protocolHost)
|
||||
) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
if (!test) {
|
||||
let checkedInstances = [];
|
||||
if (protocol == 'loki') checkedInstances = [...libredditLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') checkedInstances = [...libredditI2pCustomRedirects];
|
||||
else if (protocol == 'tor') checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects];
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects];
|
||||
}
|
||||
await utils.copyCookie('libreddit', from, checkedInstances, "theme");
|
||||
await utils.copyCookie('libreddit', from, checkedInstances, "front_page");
|
||||
await utils.copyCookie('libreddit', from, checkedInstances, "layout");
|
||||
await utils.copyCookie('libreddit', from, checkedInstances, "wide");
|
||||
await utils.copyCookie('libreddit', from, checkedInstances, "post_sort");
|
||||
await utils.copyCookie('libreddit', from, checkedInstances, "comment_sort");
|
||||
await utils.copyCookie('libreddit', from, checkedInstances, "show_nsfw");
|
||||
await utils.copyCookie('libreddit', from, checkedInstances, "autoplay_videos");
|
||||
await utils.copyCookie('libreddit', from, checkedInstances, "use_hls");
|
||||
await utils.copyCookie('libreddit', from, checkedInstances, "hide_hls_notification");
|
||||
await utils.copyCookie('libreddit', from, checkedInstances, "subscriptions");
|
||||
await utils.copyCookie('libreddit', from, checkedInstances, "filters");
|
||||
}
|
||||
resolve(true);
|
||||
})
|
||||
if (!test) {
|
||||
let checkedInstances = []
|
||||
if (protocol == "loki") checkedInstances = [...libredditLokiCustomRedirects]
|
||||
else if (protocol == "i2p") checkedInstances = [...libredditI2pCustomRedirects]
|
||||
else if (protocol == "tor") checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]
|
||||
}
|
||||
await utils.copyCookie("libreddit", from, checkedInstances, "theme")
|
||||
await utils.copyCookie("libreddit", from, checkedInstances, "front_page")
|
||||
await utils.copyCookie("libreddit", from, checkedInstances, "layout")
|
||||
await utils.copyCookie("libreddit", from, checkedInstances, "wide")
|
||||
await utils.copyCookie("libreddit", from, checkedInstances, "post_sort")
|
||||
await utils.copyCookie("libreddit", from, checkedInstances, "comment_sort")
|
||||
await utils.copyCookie("libreddit", from, checkedInstances, "show_nsfw")
|
||||
await utils.copyCookie("libreddit", from, checkedInstances, "autoplay_videos")
|
||||
await utils.copyCookie("libreddit", from, checkedInstances, "use_hls")
|
||||
await utils.copyCookie("libreddit", from, checkedInstances, "hide_hls_notification")
|
||||
await utils.copyCookie("libreddit", from, checkedInstances, "subscriptions")
|
||||
await utils.copyCookie("libreddit", from, checkedInstances, "filters")
|
||||
}
|
||||
resolve(true)
|
||||
})
|
||||
}
|
||||
|
||||
function pasteLibredditCookies() {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableReddit || redditFrontend != 'libreddit' || protocol === undefined) { resolve(); return; }
|
||||
let checkedInstances = [];
|
||||
if (protocol == 'loki') checkedInstances = [...libredditLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') checkedInstances = [...libredditI2pCustomRedirects];
|
||||
else if (protocol == 'tor') checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects];
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects];
|
||||
}
|
||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "theme");
|
||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "front_page");
|
||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "layout");
|
||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "wide");
|
||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "post_sort");
|
||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "comment_sort");
|
||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "show_nsfw");
|
||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "autoplay_videos");
|
||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "use_hls");
|
||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "hide_hls_notification");
|
||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "subscriptions");
|
||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "filters");
|
||||
resolve();
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableReddit || redditFrontend != "libreddit" || protocol === undefined) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let checkedInstances = []
|
||||
if (protocol == "loki") checkedInstances = [...libredditLokiCustomRedirects]
|
||||
else if (protocol == "i2p") checkedInstances = [...libredditI2pCustomRedirects]
|
||||
else if (protocol == "tor") checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]
|
||||
}
|
||||
utils.getCookiesFromStorage("libreddit", checkedInstances, "theme")
|
||||
utils.getCookiesFromStorage("libreddit", checkedInstances, "front_page")
|
||||
utils.getCookiesFromStorage("libreddit", checkedInstances, "layout")
|
||||
utils.getCookiesFromStorage("libreddit", checkedInstances, "wide")
|
||||
utils.getCookiesFromStorage("libreddit", checkedInstances, "post_sort")
|
||||
utils.getCookiesFromStorage("libreddit", checkedInstances, "comment_sort")
|
||||
utils.getCookiesFromStorage("libreddit", checkedInstances, "show_nsfw")
|
||||
utils.getCookiesFromStorage("libreddit", checkedInstances, "autoplay_videos")
|
||||
utils.getCookiesFromStorage("libreddit", checkedInstances, "use_hls")
|
||||
utils.getCookiesFromStorage("libreddit", checkedInstances, "hide_hls_notification")
|
||||
utils.getCookiesFromStorage("libreddit", checkedInstances, "subscriptions")
|
||||
utils.getCookiesFromStorage("libreddit", checkedInstances, "filters")
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
function initTedditCookies(test, from) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
let protocolHost = utils.protocolHost(from);
|
||||
if (![
|
||||
...tedditNormalRedirectsChecks,
|
||||
...tedditTorRedirectsChecks,
|
||||
...tedditNormalCustomRedirects,
|
||||
...tedditTorCustomRedirects,
|
||||
...tedditI2pCustomRedirects,
|
||||
...tedditI2pCustomRedirects
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
let protocolHost = utils.protocolHost(from)
|
||||
if (
|
||||
![...tedditNormalRedirectsChecks, ...tedditTorRedirectsChecks, ...tedditNormalCustomRedirects, ...tedditTorCustomRedirects, ...tedditI2pCustomRedirects, ...tedditI2pCustomRedirects].includes(
|
||||
protocolHost
|
||||
)
|
||||
)
|
||||
resolve()
|
||||
|
||||
].includes(protocolHost)) resolve();
|
||||
|
||||
if (!test) {
|
||||
let checkedInstances = [];
|
||||
if (protocol == 'loki') checkedInstances = [...tedditLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') checkedInstances = [...tedditI2pCustomRedirects];
|
||||
else if (protocol == 'tor') checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects];
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects];
|
||||
}
|
||||
await utils.copyCookie('teddit', from, checkedInstances, 'collapse_child_comments')
|
||||
await utils.copyCookie('teddit', from, checkedInstances, 'domain_instagram')
|
||||
await utils.copyCookie('teddit', from, checkedInstances, 'domain_twitter')
|
||||
await utils.copyCookie('teddit', from, checkedInstances, 'domain_youtube')
|
||||
await utils.copyCookie('teddit', from, checkedInstances, 'flairs')
|
||||
await utils.copyCookie('teddit', from, checkedInstances, 'highlight_controversial')
|
||||
await utils.copyCookie('teddit', from, checkedInstances, 'nsfw_enabled')
|
||||
await utils.copyCookie('teddit', from, checkedInstances, 'post_media_max_height')
|
||||
await utils.copyCookie('teddit', from, checkedInstances, 'show_upvoted_percentage')
|
||||
await utils.copyCookie('teddit', from, checkedInstances, 'show_upvotes')
|
||||
await utils.copyCookie('teddit', from, checkedInstances, 'theme')
|
||||
await utils.copyCookie('teddit', from, checkedInstances, 'videos_muted')
|
||||
}
|
||||
resolve(true);
|
||||
})
|
||||
if (!test) {
|
||||
let checkedInstances = []
|
||||
if (protocol == "loki") checkedInstances = [...tedditLokiCustomRedirects]
|
||||
else if (protocol == "i2p") checkedInstances = [...tedditI2pCustomRedirects]
|
||||
else if (protocol == "tor") checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]
|
||||
}
|
||||
await utils.copyCookie("teddit", from, checkedInstances, "collapse_child_comments")
|
||||
await utils.copyCookie("teddit", from, checkedInstances, "domain_instagram")
|
||||
await utils.copyCookie("teddit", from, checkedInstances, "domain_twitter")
|
||||
await utils.copyCookie("teddit", from, checkedInstances, "domain_youtube")
|
||||
await utils.copyCookie("teddit", from, checkedInstances, "flairs")
|
||||
await utils.copyCookie("teddit", from, checkedInstances, "highlight_controversial")
|
||||
await utils.copyCookie("teddit", from, checkedInstances, "nsfw_enabled")
|
||||
await utils.copyCookie("teddit", from, checkedInstances, "post_media_max_height")
|
||||
await utils.copyCookie("teddit", from, checkedInstances, "show_upvoted_percentage")
|
||||
await utils.copyCookie("teddit", from, checkedInstances, "show_upvotes")
|
||||
await utils.copyCookie("teddit", from, checkedInstances, "theme")
|
||||
await utils.copyCookie("teddit", from, checkedInstances, "videos_muted")
|
||||
}
|
||||
resolve(true)
|
||||
})
|
||||
}
|
||||
|
||||
function pasteTedditCookies() {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableReddit || redditFrontend != 'teddit' || protocol === undefined) { resolve(); return; }
|
||||
let checkedInstances = [];
|
||||
if (protocol == 'loki') checkedInstances = [...tedditLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') checkedInstances = [...tedditI2pCustomRedirects];
|
||||
else if (protocol == 'tor') checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects];
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects];
|
||||
}
|
||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'collapse_child_comments')
|
||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'domain_instagram')
|
||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'domain_twitter')
|
||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'domain_youtube')
|
||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'flairs')
|
||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'highlight_controversial')
|
||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'nsfw_enabled')
|
||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'post_media_max_height')
|
||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'show_upvoted_percentage')
|
||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'show_upvotes')
|
||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'theme')
|
||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'videos_muted')
|
||||
resolve();
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableReddit || redditFrontend != "teddit" || protocol === undefined) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let checkedInstances = []
|
||||
if (protocol == "loki") checkedInstances = [...tedditLokiCustomRedirects]
|
||||
else if (protocol == "i2p") checkedInstances = [...tedditI2pCustomRedirects]
|
||||
else if (protocol == "tor") checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]
|
||||
}
|
||||
utils.getCookiesFromStorage("teddit", checkedInstances, "collapse_child_comments")
|
||||
utils.getCookiesFromStorage("teddit", checkedInstances, "domain_instagram")
|
||||
utils.getCookiesFromStorage("teddit", checkedInstances, "domain_twitter")
|
||||
utils.getCookiesFromStorage("teddit", checkedInstances, "domain_youtube")
|
||||
utils.getCookiesFromStorage("teddit", checkedInstances, "flairs")
|
||||
utils.getCookiesFromStorage("teddit", checkedInstances, "highlight_controversial")
|
||||
utils.getCookiesFromStorage("teddit", checkedInstances, "nsfw_enabled")
|
||||
utils.getCookiesFromStorage("teddit", checkedInstances, "post_media_max_height")
|
||||
utils.getCookiesFromStorage("teddit", checkedInstances, "show_upvoted_percentage")
|
||||
utils.getCookiesFromStorage("teddit", checkedInstances, "show_upvotes")
|
||||
utils.getCookiesFromStorage("teddit", checkedInstances, "theme")
|
||||
utils.getCookiesFromStorage("teddit", checkedInstances, "videos_muted")
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
function all() {
|
||||
return [
|
||||
...redditRedirects.libreddit.normal,
|
||||
...redditRedirects.libreddit.tor,
|
||||
...redditRedirects.teddit.normal,
|
||||
...redditRedirects.teddit.tor,
|
||||
...libredditNormalCustomRedirects,
|
||||
...libredditTorCustomRedirects,
|
||||
...libredditI2pCustomRedirects,
|
||||
...libredditLokiCustomRedirects,
|
||||
...tedditNormalCustomRedirects,
|
||||
...tedditTorCustomRedirects,
|
||||
...tedditI2pCustomRedirects,
|
||||
...tedditLokiCustomRedirects
|
||||
];
|
||||
return [
|
||||
...redditRedirects.libreddit.normal,
|
||||
...redditRedirects.libreddit.tor,
|
||||
...redditRedirects.teddit.normal,
|
||||
...redditRedirects.teddit.tor,
|
||||
...libredditNormalCustomRedirects,
|
||||
...libredditTorCustomRedirects,
|
||||
...libredditI2pCustomRedirects,
|
||||
...libredditLokiCustomRedirects,
|
||||
...tedditNormalCustomRedirects,
|
||||
...tedditTorCustomRedirects,
|
||||
...tedditI2pCustomRedirects,
|
||||
...tedditLokiCustomRedirects,
|
||||
]
|
||||
}
|
||||
|
||||
// https://libreddit.exonip.de/vid/1mq8d0ma3yk81/720.mp4
|
||||
|
@ -267,188 +264,189 @@ function all() {
|
|||
// https://teddit.net/vids/1mq8d0ma3yk81.mp4
|
||||
// https://teddit.net/pics/w:null_4v3t1vgvrzk81.png
|
||||
|
||||
|
||||
// redd.it/t5379n
|
||||
// https://v.redd.it/z08avb339n801/DASH_1_2_M
|
||||
// https://i.redd.it/bfkhs659tzk81.jpg
|
||||
function redirect(url, type, initiator, disableOverride) {
|
||||
if (disableReddit && !disableOverride) return;
|
||||
if (!targets.some(rx => rx.test(url.href))) return;
|
||||
if (initiator && all().includes(initiator.origin)) return 'BYPASSTAB';
|
||||
if (!["main_frame", "xmlhttprequest", "other", "image", "media"].includes(type)) return;
|
||||
const bypassPaths = /\/(gallery\/poll\/rpan\/settings\/topics)/;
|
||||
if (url.pathname.match(bypassPaths)) return;
|
||||
if (disableReddit && !disableOverride) return
|
||||
if (!targets.some(rx => rx.test(url.href))) return
|
||||
if (initiator && all().includes(initiator.origin)) return "BYPASSTAB"
|
||||
if (!["main_frame", "xmlhttprequest", "other", "image", "media"].includes(type)) return
|
||||
const bypassPaths = /\/(gallery\/poll\/rpan\/settings\/topics)/
|
||||
if (url.pathname.match(bypassPaths)) return
|
||||
|
||||
let libredditInstancesList = [];
|
||||
let tedditInstancesList = [];
|
||||
let libredditInstancesList = []
|
||||
let tedditInstancesList = []
|
||||
|
||||
if (protocol == 'loki') {
|
||||
libredditInstancesList = [...libredditLokiCustomRedirects];
|
||||
tedditInstancesList = [...tedditLokiCustomRedirects];
|
||||
}
|
||||
else if (protocol == 'i2p') {
|
||||
libredditInstancesList = [...libredditI2pCustomRedirects];
|
||||
tedditInstancesList = [...tedditI2pCustomRedirects];
|
||||
}
|
||||
else if (protocol == 'tor') {
|
||||
libredditInstancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects];
|
||||
tedditInstancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects];
|
||||
}
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
libredditInstancesList = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects];
|
||||
tedditInstancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects];
|
||||
}
|
||||
if (protocol == "loki") {
|
||||
libredditInstancesList = [...libredditLokiCustomRedirects]
|
||||
tedditInstancesList = [...tedditLokiCustomRedirects]
|
||||
} else if (protocol == "i2p") {
|
||||
libredditInstancesList = [...libredditI2pCustomRedirects]
|
||||
tedditInstancesList = [...tedditI2pCustomRedirects]
|
||||
} else if (protocol == "tor") {
|
||||
libredditInstancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]
|
||||
tedditInstancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]
|
||||
}
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
libredditInstancesList = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]
|
||||
tedditInstancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]
|
||||
}
|
||||
|
||||
if (url.host === "i.redd.it") {
|
||||
if (redditFrontend == 'teddit') {
|
||||
if (tedditInstancesList.length === 0) return;
|
||||
let tedditRandomInstance = utils.getRandomInstance(tedditInstancesList);
|
||||
return `${tedditRandomInstance}/pics/w:null_${url.pathname.substring(1)}${url.search}`;
|
||||
}
|
||||
if (redditFrontend == 'libreddit') {
|
||||
if (libredditInstancesList.length === 0) return;
|
||||
let libredditRandomInstance = utils.getRandomInstance(libredditInstancesList);
|
||||
return `${libredditRandomInstance}/img${url.pathname}${url.search}`
|
||||
}
|
||||
}
|
||||
else if (url.host === "redd.it") {
|
||||
if (redditFrontend == 'libreddit' && !url.pathname.match(/^\/+[^\/]+\/+[^\/]/)) {
|
||||
if (libredditInstancesList.length === 0) return;
|
||||
let libredditRandomInstance = utils.getRandomInstance(libredditInstancesList);
|
||||
// https://redd.it/foo => https://libredd.it/comments/foo
|
||||
return `${libredditRandomInstance}/comments${url.pathname}${url.search}`;
|
||||
}
|
||||
if (redditFrontend == 'teddit' && !url.pathname.match(/^\/+[^\/]+\/+[^\/]/)) {
|
||||
if (tedditInstancesList.length === 0) return;
|
||||
let tedditRandomInstance = utils.getRandomInstance(tedditInstancesList);
|
||||
// https://redd.it/foo => https://teddit.net/comments/foo
|
||||
return `${tedditRandomInstance}/comments${url.pathname}${url.search}`
|
||||
}
|
||||
}
|
||||
else if (url.host === 'preview.redd.it') {
|
||||
if (redditFrontend == 'teddit') return;
|
||||
if (redditFrontend == 'libreddit') {
|
||||
if (libredditInstancesList.length === 0) return;
|
||||
const libredditRandomInstance = utils.getRandomInstance(libredditInstancesList);
|
||||
return `${libredditRandomInstance}/preview/pre${url.pathname}${url.search}`;
|
||||
}
|
||||
}
|
||||
if (url.host === "i.redd.it") {
|
||||
if (redditFrontend == "teddit") {
|
||||
if (tedditInstancesList.length === 0) return
|
||||
let tedditRandomInstance = utils.getRandomInstance(tedditInstancesList)
|
||||
return `${tedditRandomInstance}/pics/w:null_${url.pathname.substring(1)}${url.search}`
|
||||
}
|
||||
if (redditFrontend == "libreddit") {
|
||||
if (libredditInstancesList.length === 0) return
|
||||
let libredditRandomInstance = utils.getRandomInstance(libredditInstancesList)
|
||||
return `${libredditRandomInstance}/img${url.pathname}${url.search}`
|
||||
}
|
||||
} else if (url.host === "redd.it") {
|
||||
if (redditFrontend == "libreddit" && !url.pathname.match(/^\/+[^\/]+\/+[^\/]/)) {
|
||||
if (libredditInstancesList.length === 0) return
|
||||
let libredditRandomInstance = utils.getRandomInstance(libredditInstancesList)
|
||||
// https://redd.it/foo => https://libredd.it/comments/foo
|
||||
return `${libredditRandomInstance}/comments${url.pathname}${url.search}`
|
||||
}
|
||||
if (redditFrontend == "teddit" && !url.pathname.match(/^\/+[^\/]+\/+[^\/]/)) {
|
||||
if (tedditInstancesList.length === 0) return
|
||||
let tedditRandomInstance = utils.getRandomInstance(tedditInstancesList)
|
||||
// https://redd.it/foo => https://teddit.net/comments/foo
|
||||
return `${tedditRandomInstance}/comments${url.pathname}${url.search}`
|
||||
}
|
||||
} else if (url.host === "preview.redd.it") {
|
||||
if (redditFrontend == "teddit") return
|
||||
if (redditFrontend == "libreddit") {
|
||||
if (libredditInstancesList.length === 0) return
|
||||
const libredditRandomInstance = utils.getRandomInstance(libredditInstancesList)
|
||||
return `${libredditRandomInstance}/preview/pre${url.pathname}${url.search}`
|
||||
}
|
||||
}
|
||||
|
||||
let randomInstance;
|
||||
if (redditFrontend == 'libreddit') {
|
||||
if (libredditInstancesList.length === 0) return;
|
||||
randomInstance = utils.getRandomInstance(libredditInstancesList);
|
||||
}
|
||||
if (redditFrontend == 'teddit') {
|
||||
if (tedditInstancesList.length === 0) return;
|
||||
randomInstance = utils.getRandomInstance(tedditInstancesList);
|
||||
}
|
||||
return `${randomInstance}${url.pathname}${url.search}`;
|
||||
let randomInstance
|
||||
if (redditFrontend == "libreddit") {
|
||||
if (libredditInstancesList.length === 0) return
|
||||
randomInstance = utils.getRandomInstance(libredditInstancesList)
|
||||
}
|
||||
if (redditFrontend == "teddit") {
|
||||
if (tedditInstancesList.length === 0) return
|
||||
randomInstance = utils.getRandomInstance(tedditInstancesList)
|
||||
}
|
||||
return `${randomInstance}${url.pathname}${url.search}`
|
||||
}
|
||||
|
||||
function switchInstance(url, disableOverride) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableReddit && !disableOverride) { resolve(); return; }
|
||||
const protocolHost = utils.protocolHost(url);
|
||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
||||
let instancesList = [];
|
||||
if (redditFrontend == 'libreddit') {
|
||||
if (protocol == 'loki') instancesList = [...libredditLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...libredditI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects];
|
||||
}
|
||||
if ([
|
||||
...redditRedirects.teddit.normal,
|
||||
...redditRedirects.teddit.tor
|
||||
].includes(protocolHost)) url.pathname = url.pathname.replace("/pics/w:null_", "/img/");
|
||||
}
|
||||
else if (redditFrontend == 'teddit') {
|
||||
if (protocol == 'loki') instancesList = [...tedditLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...tedditI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects];
|
||||
}
|
||||
if ([
|
||||
...redditRedirects.libreddit.normal,
|
||||
...redditRedirects.libreddit.tor
|
||||
].includes(protocolHost)
|
||||
) url.pathname = url.pathname.replace("/img/", "/pics/w:null_");
|
||||
}
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableReddit && !disableOverride) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
const protocolHost = utils.protocolHost(url)
|
||||
if (!all().includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let instancesList = []
|
||||
if (redditFrontend == "libreddit") {
|
||||
if (protocol == "loki") instancesList = [...libredditLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...libredditI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]
|
||||
}
|
||||
if ([...redditRedirects.teddit.normal, ...redditRedirects.teddit.tor].includes(protocolHost)) url.pathname = url.pathname.replace("/pics/w:null_", "/img/")
|
||||
} else if (redditFrontend == "teddit") {
|
||||
if (protocol == "loki") instancesList = [...tedditLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...tedditI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]
|
||||
}
|
||||
if ([...redditRedirects.libreddit.normal, ...redditRedirects.libreddit.tor].includes(protocolHost)) url.pathname = url.pathname.replace("/img/", "/pics/w:null_")
|
||||
}
|
||||
|
||||
const i = instancesList.indexOf(protocolHost);
|
||||
if (i > -1) instancesList.splice(i, 1);
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
const i = instancesList.indexOf(protocolHost)
|
||||
if (i > -1) instancesList.splice(i, 1)
|
||||
if (instancesList.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
})
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get('cloudflareBlackList', async r => {
|
||||
libredditNormalRedirectsChecks = [...redirects.libreddit.normal];
|
||||
tedditNormalRedirectsChecks = [...redirects.teddit.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
let i;
|
||||
return new Promise(resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(async data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||
libredditNormalRedirectsChecks = [...redirects.libreddit.normal]
|
||||
tedditNormalRedirectsChecks = [...redirects.teddit.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
let i
|
||||
|
||||
i = libredditNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) libredditNormalRedirectsChecks.splice(i, 1);
|
||||
i = libredditNormalRedirectsChecks.indexOf(instance)
|
||||
if (i > -1) libredditNormalRedirectsChecks.splice(i, 1)
|
||||
|
||||
i = tedditNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) tedditNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
disableReddit: false,
|
||||
redditFrontend: 'libreddit',
|
||||
redditRedirects: redirects,
|
||||
i = tedditNormalRedirectsChecks.indexOf(instance)
|
||||
if (i > -1) tedditNormalRedirectsChecks.splice(i, 1)
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
disableReddit: false,
|
||||
redditFrontend: "libreddit",
|
||||
redditRedirects: redirects,
|
||||
|
||||
libredditNormalRedirectsChecks: libredditNormalRedirectsChecks,
|
||||
libredditNormalCustomRedirects: [],
|
||||
libredditNormalRedirectsChecks: libredditNormalRedirectsChecks,
|
||||
libredditNormalCustomRedirects: [],
|
||||
|
||||
libredditTorRedirectsChecks: [...redirects.libreddit.tor],
|
||||
libredditTorCustomRedirects: [],
|
||||
libredditTorRedirectsChecks: [...redirects.libreddit.tor],
|
||||
libredditTorCustomRedirects: [],
|
||||
|
||||
libredditI2pRedirectsChecks: [...redirects.libreddit.i2p],
|
||||
libredditI2pCustomRedirects: [],
|
||||
libredditI2pRedirectsChecks: [...redirects.libreddit.i2p],
|
||||
libredditI2pCustomRedirects: [],
|
||||
|
||||
libredditLokiRedirectsChecks: [...redirects.libreddit.loki],
|
||||
libredditLokiCustomRedirects: [],
|
||||
libredditLokiRedirectsChecks: [...redirects.libreddit.loki],
|
||||
libredditLokiCustomRedirects: [],
|
||||
|
||||
tedditNormalRedirectsChecks: tedditNormalRedirectsChecks,
|
||||
tedditNormalCustomRedirects: [],
|
||||
tedditNormalRedirectsChecks: tedditNormalRedirectsChecks,
|
||||
tedditNormalCustomRedirects: [],
|
||||
|
||||
tedditTorRedirectsChecks: [...redirects.teddit.tor],
|
||||
tedditTorCustomRedirects: [],
|
||||
tedditTorRedirectsChecks: [...redirects.teddit.tor],
|
||||
tedditTorCustomRedirects: [],
|
||||
|
||||
tedditI2pRedirectsChecks: [...redirects.teddit.i2p],
|
||||
tedditI2pCustomRedirects: [],
|
||||
tedditI2pRedirectsChecks: [...redirects.teddit.i2p],
|
||||
tedditI2pCustomRedirects: [],
|
||||
|
||||
tedditLokiRedirectsChecks: [...redirects.teddit.loki],
|
||||
tedditLokiCustomRedirects: []
|
||||
}, () => resolve());
|
||||
});
|
||||
});
|
||||
});
|
||||
tedditLokiRedirectsChecks: [...redirects.teddit.loki],
|
||||
tedditLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
initLibredditCookies,
|
||||
pasteLibredditCookies,
|
||||
initTedditCookies,
|
||||
pasteTedditCookies,
|
||||
setRedirects,
|
||||
initLibredditCookies,
|
||||
pasteLibredditCookies,
|
||||
initTedditCookies,
|
||||
pasteTedditCookies,
|
||||
|
||||
redirect,
|
||||
initDefaults,
|
||||
switchInstance,
|
||||
};
|
||||
redirect,
|
||||
initDefaults,
|
||||
switchInstance,
|
||||
}
|
||||
|
|
|
@ -1,152 +1,140 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
import utils from './utils.js'
|
||||
import utils from "./utils.js"
|
||||
|
||||
const targets = [
|
||||
/^https?:\/{2}(www\.|)reuters\.com.*/
|
||||
];
|
||||
const targets = [/^https?:\/{2}(www\.|)reuters\.com.*/]
|
||||
|
||||
let redirects = {
|
||||
"neuters": {
|
||||
"normal": [
|
||||
"https://neuters.de"
|
||||
],
|
||||
"tor": [],
|
||||
"i2p": [],
|
||||
"loki": []
|
||||
}
|
||||
const frontends = new Array("neuters")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
||||
let redirects = {}
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
// const frontends = new Array("neuters")
|
||||
// const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
||||
// for (let i = 0; i < frontends.length; i++) {
|
||||
// redirects[frontends[i]] = {}
|
||||
// for (let x = 0; x < protocols.length; x++) {
|
||||
// redirects[frontends[i]][protocols[x]] = []
|
||||
// }
|
||||
// }
|
||||
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get('cloudflareBlackList', r => {
|
||||
redirects.neuters = val;
|
||||
neutersNormalRedirectsChecks = [...redirects.neuters.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = neutersNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) neutersNormalRedirectsChecks.splice(a, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
neutersRedirects: redirects,
|
||||
neutersNormalRedirectsChecks
|
||||
})
|
||||
})
|
||||
browser.storage.local.get("cloudflareBlackList", r => {
|
||||
redirects.neuters = val
|
||||
neutersNormalRedirectsChecks = [...redirects.neuters.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = neutersNormalRedirectsChecks.indexOf(instance)
|
||||
if (a > -1) neutersNormalRedirectsChecks.splice(a, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
neutersRedirects: redirects,
|
||||
neutersNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
disableReuters,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
reutersRedirects,
|
||||
neutersNormalRedirectsChecks,
|
||||
neutersNormalCustomRedirects,
|
||||
neutersTorRedirectsChecks,
|
||||
neutersTorCustomRedirects,
|
||||
neutersI2pCustomRedirects,
|
||||
neutersLokiCustomRedirects;
|
||||
let disableReuters,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
reutersRedirects,
|
||||
neutersNormalRedirectsChecks,
|
||||
neutersNormalCustomRedirects,
|
||||
neutersTorRedirectsChecks,
|
||||
neutersTorCustomRedirects,
|
||||
neutersI2pCustomRedirects,
|
||||
neutersLokiCustomRedirects
|
||||
|
||||
function init() {
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableReuters",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"reutersRedirects",
|
||||
"neutersNormalRedirectsChecks",
|
||||
"neutersNormalCustomRedirects",
|
||||
"neutersTorRedirectsChecks",
|
||||
"neutersTorCustomRedirects",
|
||||
"neutersI2pCustomRedirects",
|
||||
"neutersLokiCustomRedirects"
|
||||
],
|
||||
r => {
|
||||
disableReuters = r.disableReuters;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
reutersRedirects = r.reutersRedirects;
|
||||
neutersNormalRedirectsChecks = r.neutersNormalRedirectsChecks;
|
||||
neutersNormalCustomRedirects = r.neutersNormalCustomRedirects;
|
||||
neutersTorRedirectsChecks = r.neutersTorRedirectsChecks;
|
||||
neutersTorCustomRedirects = r.neutersTorCustomRedirects;
|
||||
neutersI2pCustomRedirects = r.neutersI2pCustomRedirects;
|
||||
neutersLokiCustomRedirects = r.neutersLokiCustomRedirects;
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableReuters",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"reutersRedirects",
|
||||
"neutersNormalRedirectsChecks",
|
||||
"neutersNormalCustomRedirects",
|
||||
"neutersTorRedirectsChecks",
|
||||
"neutersTorCustomRedirects",
|
||||
"neutersI2pCustomRedirects",
|
||||
"neutersLokiCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disableReuters = r.disableReuters
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
reutersRedirects = r.reutersRedirects
|
||||
neutersNormalRedirectsChecks = r.neutersNormalRedirectsChecks
|
||||
neutersNormalCustomRedirects = r.neutersNormalCustomRedirects
|
||||
neutersTorRedirectsChecks = r.neutersTorRedirectsChecks
|
||||
neutersTorCustomRedirects = r.neutersTorCustomRedirects
|
||||
neutersI2pCustomRedirects = r.neutersI2pCustomRedirects
|
||||
neutersLokiCustomRedirects = r.neutersLokiCustomRedirects
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function redirect(url, type, initiator, disableOverride) {
|
||||
if (disableReuters && !disableOverride) return;
|
||||
if (type != "main_frame") return;
|
||||
const all = [
|
||||
...reutersRedirects.neuters.normal,
|
||||
...neutersNormalCustomRedirects
|
||||
];
|
||||
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return;
|
||||
if (!targets.some(rx => rx.test(url.href))) return;
|
||||
if (disableReuters && !disableOverride) return
|
||||
if (type != "main_frame") return
|
||||
const all = [...reutersRedirects.neuters.normal, ...neutersNormalCustomRedirects]
|
||||
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return
|
||||
if (!targets.some(rx => rx.test(url.href))) return
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...neutersLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...neutersI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...neutersTorRedirectsChecks, ...neutersTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...neutersNormalRedirectsChecks, ...neutersNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) return;
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...neutersLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...neutersI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...neutersTorRedirectsChecks, ...neutersTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...neutersNormalRedirectsChecks, ...neutersNormalCustomRedirects]
|
||||
}
|
||||
if (instancesList.length === 0) return
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
// stolen from https://addons.mozilla.org/en-US/firefox/addon/reuters-redirect/
|
||||
if (
|
||||
url.pathname.startsWith('/article/') ||
|
||||
url.pathname.startsWith('/pf/') ||
|
||||
url.pathname.startsWith('/arc/') ||
|
||||
url.pathname.startsWith('/resizer/')
|
||||
)
|
||||
return null;
|
||||
else if (url.pathname.endsWith('/'))
|
||||
return `${randomInstance}${url.pathname}`;
|
||||
else
|
||||
return `${randomInstance}${url.pathname}/`;
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
// stolen from https://addons.mozilla.org/en-US/firefox/addon/reuters-redirect/
|
||||
if (url.pathname.startsWith("/article/") || url.pathname.startsWith("/pf/") || url.pathname.startsWith("/arc/") || url.pathname.startsWith("/resizer/")) return null
|
||||
else if (url.pathname.endsWith("/")) return `${randomInstance}${url.pathname}`
|
||||
else return `${randomInstance}${url.pathname}/`
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.set({
|
||||
disableReuters: true,
|
||||
return new Promise(async resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(async data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
disableReuters: true,
|
||||
|
||||
reutersRedirects: redirects,
|
||||
reutersRedirects: redirects,
|
||||
|
||||
neutersNormalRedirectsChecks: [...redirects.neuters.normal],
|
||||
neutersNormalCustomRedirects: [],
|
||||
neutersNormalRedirectsChecks: [...redirects.neuters.normal],
|
||||
neutersNormalCustomRedirects: [],
|
||||
|
||||
neutersTorRedirectsChecks: [...redirects.neuters.tor],
|
||||
neutersTorCustomRedirects: [],
|
||||
neutersTorRedirectsChecks: [...redirects.neuters.tor],
|
||||
neutersTorCustomRedirects: [],
|
||||
|
||||
neutersI2pRedirectsChecks: [...redirects.neuters.i2p],
|
||||
neutersI2pCustomRedirects: [],
|
||||
neutersI2pRedirectsChecks: [...redirects.neuters.i2p],
|
||||
neutersI2pCustomRedirects: [],
|
||||
|
||||
neutersLokiRedirectsChecks: [...redirects.neuters.loki],
|
||||
neutersLokiCustomRedirects: []
|
||||
}, () => resolve());
|
||||
});
|
||||
neutersLokiRedirectsChecks: [...redirects.neuters.loki],
|
||||
neutersLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
redirect,
|
||||
initDefaults
|
||||
};
|
||||
setRedirects,
|
||||
redirect,
|
||||
initDefaults,
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,12 +1,8 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
import utils from './utils.js'
|
||||
import utils from "./utils.js"
|
||||
|
||||
const targets = [
|
||||
/^https?:\/{2}send\.libredirect\.invalid\/$/,
|
||||
/^ https ?: \/\/send\.firefox\.com\/$/,
|
||||
/^https?:\/{2}sendfiles\.online\/$/
|
||||
];
|
||||
const targets = [/^https?:\/{2}send\.libredirect\.invalid\/$/, /^ https ?: \/\/send\.firefox\.com\/$/, /^https?:\/{2}sendfiles\.online\/$/]
|
||||
|
||||
const frontends = new Array("send")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
@ -14,167 +10,183 @@ const protocols = new Array("normal", "tor", "i2p", "loki")
|
|||
let redirects = {}
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get('cloudflareBlackList', r => {
|
||||
redirects.send = val;
|
||||
sendNormalRedirectsChecks = [...redirects.send.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = sendNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) sendNormalRedirectsChecks.splice(a, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
sendTargetsRedirects: redirects,
|
||||
sendNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
browser.storage.local.get("cloudflareBlackList", r => {
|
||||
redirects.send = val
|
||||
sendNormalRedirectsChecks = [...redirects.send.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = sendNormalRedirectsChecks.indexOf(instance)
|
||||
if (a > -1) sendNormalRedirectsChecks.splice(a, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
sendTargetsRedirects: redirects,
|
||||
sendNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
disableSendTarget,
|
||||
sendTargetsRedirects,
|
||||
sendNormalRedirectsChecks,
|
||||
sendNormalCustomRedirects,
|
||||
sendTorRedirectsChecks,
|
||||
sendTorCustomRedirects,
|
||||
sendI2pCustomRedirects,
|
||||
sendLokiCustomRedirects,
|
||||
protocol,
|
||||
protocolFallback;
|
||||
let disableSendTarget,
|
||||
sendTargetsRedirects,
|
||||
sendNormalRedirectsChecks,
|
||||
sendNormalCustomRedirects,
|
||||
sendTorRedirectsChecks,
|
||||
sendTorCustomRedirects,
|
||||
sendI2pCustomRedirects,
|
||||
sendLokiCustomRedirects,
|
||||
protocol,
|
||||
protocolFallback
|
||||
|
||||
function init() {
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableSendTarget",
|
||||
"sendTargetsRedirects",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"sendNormalRedirectsChecks",
|
||||
"sendNormalCustomRedirects",
|
||||
"sendTorRedirectsChecks",
|
||||
"sendTorCustomRedirects",
|
||||
"sendI2pCustomRedirects",
|
||||
"sendLokiCustomRedirects"
|
||||
],
|
||||
r => {
|
||||
disableSendTarget = r.disableSendTarget;
|
||||
sendTargetsRedirects = r.sendTargetsRedirects;
|
||||
sendNormalRedirectsChecks = r.sendNormalRedirectsChecks;
|
||||
sendNormalCustomRedirects = r.sendNormalCustomRedirects;
|
||||
sendTorRedirectsChecks = r.sendTorRedirectsChecks;
|
||||
sendTorCustomRedirects = r.sendTorCustomRedirects;
|
||||
sendI2pCustomRedirects = r.sendI2pCustomRedirects;
|
||||
sendLokiCustomRedirects = r.sendLokiCustomRedirects;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableSendTarget",
|
||||
"sendTargetsRedirects",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"sendNormalRedirectsChecks",
|
||||
"sendNormalCustomRedirects",
|
||||
"sendTorRedirectsChecks",
|
||||
"sendTorCustomRedirects",
|
||||
"sendI2pCustomRedirects",
|
||||
"sendLokiCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disableSendTarget = r.disableSendTarget
|
||||
sendTargetsRedirects = r.sendTargetsRedirects
|
||||
sendNormalRedirectsChecks = r.sendNormalRedirectsChecks
|
||||
sendNormalCustomRedirects = r.sendNormalCustomRedirects
|
||||
sendTorRedirectsChecks = r.sendTorRedirectsChecks
|
||||
sendTorCustomRedirects = r.sendTorCustomRedirects
|
||||
sendI2pCustomRedirects = r.sendI2pCustomRedirects
|
||||
sendLokiCustomRedirects = r.sendLokiCustomRedirects
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function all() {
|
||||
return [
|
||||
...sendTargetsRedirects.send.normal,
|
||||
...sendTargetsRedirects.send.tor,
|
||||
...sendNormalCustomRedirects,
|
||||
...sendTorRedirectsChecks,
|
||||
...sendTorCustomRedirects,
|
||||
...sendI2pCustomRedirects,
|
||||
...sendLokiCustomRedirects
|
||||
];
|
||||
return [
|
||||
...sendTargetsRedirects.send.normal,
|
||||
...sendTargetsRedirects.send.tor,
|
||||
...sendNormalCustomRedirects,
|
||||
...sendTorRedirectsChecks,
|
||||
...sendTorCustomRedirects,
|
||||
...sendI2pCustomRedirects,
|
||||
...sendLokiCustomRedirects,
|
||||
]
|
||||
}
|
||||
|
||||
function switchInstance(url, disableOverride) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableSendTarget && !disableOverride) { resolve(); return; }
|
||||
const protocolHost = utils.protocolHost(url);
|
||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
||||
if (url.pathname != '/') { resolve(); return; }
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableSendTarget && !disableOverride) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
const protocolHost = utils.protocolHost(url)
|
||||
if (!all().includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
if (url.pathname != "/") {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...sendLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...sendI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects];
|
||||
}
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...sendLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...sendI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects]
|
||||
}
|
||||
|
||||
const i = instancesList.indexOf(protocolHost);
|
||||
if (i > -1) instancesList.splice(i, 1);
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
const i = instancesList.indexOf(protocolHost)
|
||||
if (i > -1) instancesList.splice(i, 1)
|
||||
if (instancesList.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
})
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function redirect(url, type, initiator, disableOverride) {
|
||||
if (disableSendTarget && !disableOverride) return;
|
||||
if (type != "main_frame") return;
|
||||
if (initiator && (all().includes(initiator.origin) || targets.includes(initiator.host))) return;
|
||||
if (!targets.some(rx => rx.test(url.href))) return;
|
||||
if (disableSendTarget && !disableOverride) return
|
||||
if (type != "main_frame") return
|
||||
if (initiator && (all().includes(initiator.origin) || targets.includes(initiator.host))) return
|
||||
if (!targets.some(rx => rx.test(url.href))) return
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...sendLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...sendI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) return;
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...sendLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...sendI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects]
|
||||
}
|
||||
if (instancesList.length === 0) return
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
return randomInstance;
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
return randomInstance
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get('cloudflareBlackList', async r => {
|
||||
sendNormalRedirectsChecks = [...redirects.send.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
let i = sendNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) sendNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
disableSendTarget: false,
|
||||
sendTargetsRedirects: redirects,
|
||||
return new Promise(resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(async data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||
sendNormalRedirectsChecks = [...redirects.send.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
let i = sendNormalRedirectsChecks.indexOf(instance)
|
||||
if (i > -1) sendNormalRedirectsChecks.splice(i, 1)
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
disableSendTarget: false,
|
||||
sendTargetsRedirects: redirects,
|
||||
|
||||
sendNormalRedirectsChecks: sendNormalRedirectsChecks,
|
||||
sendNormalCustomRedirects: [],
|
||||
sendNormalRedirectsChecks: sendNormalRedirectsChecks,
|
||||
sendNormalCustomRedirects: [],
|
||||
|
||||
sendTorRedirectsChecks: [...redirects.send.tor],
|
||||
sendTorCustomRedirects: [],
|
||||
sendTorRedirectsChecks: [...redirects.send.tor],
|
||||
sendTorCustomRedirects: [],
|
||||
|
||||
sendI2pRedirectsChecks: [...redirects.send.i2p],
|
||||
sendI2pCustomRedirects: [],
|
||||
sendI2pRedirectsChecks: [...redirects.send.i2p],
|
||||
sendI2pCustomRedirects: [],
|
||||
|
||||
sendLokiRedirectsChecks: [...redirects.send.loki],
|
||||
sendLokiCustomRedirects: []
|
||||
}, () => resolve())
|
||||
})
|
||||
})
|
||||
})
|
||||
sendLokiRedirectsChecks: [...redirects.send.loki],
|
||||
sendLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
redirect,
|
||||
switchInstance,
|
||||
initDefaults,
|
||||
};
|
||||
setRedirects,
|
||||
redirect,
|
||||
switchInstance,
|
||||
initDefaults,
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
import utils from './utils.js'
|
||||
import utils from "./utils.js"
|
||||
|
||||
const targets = [
|
||||
/^https?:\/{2}(www\.|)tiktok\.com.*/
|
||||
];
|
||||
const targets = [/^https?:\/{2}(www\.|)tiktok\.com.*/]
|
||||
|
||||
const frontends = new Array("proxiTok")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
@ -12,232 +10,251 @@ const protocols = new Array("normal", "tor", "i2p", "loki")
|
|||
let redirects = {}
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get('cloudflareBlackList', r => {
|
||||
redirects.proxiTok = val;
|
||||
proxiTokNormalRedirectsChecks = [...redirects.proxiTok.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = proxiTokNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) proxiTokNormalRedirectsChecks.splice(a, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
tiktokRedirects: redirects,
|
||||
proxiTokNormalRedirectsChecks
|
||||
})
|
||||
})
|
||||
browser.storage.local.get("cloudflareBlackList", r => {
|
||||
redirects.proxiTok = val
|
||||
proxiTokNormalRedirectsChecks = [...redirects.proxiTok.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = proxiTokNormalRedirectsChecks.indexOf(instance)
|
||||
if (a > -1) proxiTokNormalRedirectsChecks.splice(a, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
tiktokRedirects: redirects,
|
||||
proxiTokNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function initProxiTokCookies(test, from) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
let protocolHost = utils.protocolHost(from);
|
||||
if (![
|
||||
...proxiTokNormalRedirectsChecks,
|
||||
...proxiTokNormalCustomRedirects,
|
||||
...proxiTokTorRedirectsChecks,
|
||||
...proxiTokTorCustomRedirects,
|
||||
...proxiTokI2pCustomRedirects,
|
||||
...proxiTokLokiCustomRedirects,
|
||||
].includes(protocolHost)) resolve();
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
let protocolHost = utils.protocolHost(from)
|
||||
if (
|
||||
![
|
||||
...proxiTokNormalRedirectsChecks,
|
||||
...proxiTokNormalCustomRedirects,
|
||||
...proxiTokTorRedirectsChecks,
|
||||
...proxiTokTorCustomRedirects,
|
||||
...proxiTokI2pCustomRedirects,
|
||||
...proxiTokLokiCustomRedirects,
|
||||
].includes(protocolHost)
|
||||
)
|
||||
resolve()
|
||||
|
||||
if (!test) {
|
||||
let checkedInstances = [];
|
||||
if (protocol == 'loki') checkedInstances = [...proxiTokI2pCustomRedirects];
|
||||
else if (protocol == 'i2p') checkedInstances = [...proxiTokLokiCustomRedirects];
|
||||
else if (protocol == 'tor') checkedInstances = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects];
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
checkedInstances = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects];
|
||||
}
|
||||
await utils.copyCookie('proxitok', from, checkedInstances, 'theme');
|
||||
await utils.copyCookie('proxitok', from, checkedInstances, 'api-legacy');
|
||||
}
|
||||
resolve(true);
|
||||
})
|
||||
if (!test) {
|
||||
let checkedInstances = []
|
||||
if (protocol == "loki") checkedInstances = [...proxiTokI2pCustomRedirects]
|
||||
else if (protocol == "i2p") checkedInstances = [...proxiTokLokiCustomRedirects]
|
||||
else if (protocol == "tor") checkedInstances = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
checkedInstances = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]
|
||||
}
|
||||
await utils.copyCookie("proxitok", from, checkedInstances, "theme")
|
||||
await utils.copyCookie("proxitok", from, checkedInstances, "api-legacy")
|
||||
}
|
||||
resolve(true)
|
||||
})
|
||||
}
|
||||
|
||||
function pasteProxiTokCookies() {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableTiktok || protocol === undefined) { resolve(); return; }
|
||||
let checkedInstances = [];
|
||||
if (protocol == 'loki') checkedInstances = [...proxiTokI2pCustomRedirects];
|
||||
else if (protocol == 'i2p') checkedInstances = [...proxiTokLokiCustomRedirects];
|
||||
else if (protocol == 'tor') checkedInstances = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects];
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
checkedInstances = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects];
|
||||
}
|
||||
utils.getCookiesFromStorage('proxitok', checkedInstances, 'theme');
|
||||
utils.getCookiesFromStorage('proxitok', checkedInstances, 'api-legacy');
|
||||
resolve();
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableTiktok || protocol === undefined) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let checkedInstances = []
|
||||
if (protocol == "loki") checkedInstances = [...proxiTokI2pCustomRedirects]
|
||||
else if (protocol == "i2p") checkedInstances = [...proxiTokLokiCustomRedirects]
|
||||
else if (protocol == "tor") checkedInstances = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
checkedInstances = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]
|
||||
}
|
||||
utils.getCookiesFromStorage("proxitok", checkedInstances, "theme")
|
||||
utils.getCookiesFromStorage("proxitok", checkedInstances, "api-legacy")
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
disableTiktok,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
tiktokRedirects,
|
||||
proxiTokNormalRedirectsChecks,
|
||||
proxiTokNormalCustomRedirects,
|
||||
proxiTokTorRedirectsChecks,
|
||||
proxiTokTorCustomRedirects,
|
||||
proxiTokI2pCustomRedirects,
|
||||
proxiTokLokiCustomRedirects;
|
||||
let disableTiktok,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
tiktokRedirects,
|
||||
proxiTokNormalRedirectsChecks,
|
||||
proxiTokNormalCustomRedirects,
|
||||
proxiTokTorRedirectsChecks,
|
||||
proxiTokTorCustomRedirects,
|
||||
proxiTokI2pCustomRedirects,
|
||||
proxiTokLokiCustomRedirects
|
||||
|
||||
function init() {
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableTiktok",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"tiktokRedirects",
|
||||
"proxiTokNormalRedirectsChecks",
|
||||
"proxiTokNormalCustomRedirects",
|
||||
"proxiTokTorRedirectsChecks",
|
||||
"proxiTokTorCustomRedirects",
|
||||
"proxiTokI2pCustomRedirects",
|
||||
"proxiTokLokiCustomRedirects"
|
||||
],
|
||||
r => {
|
||||
disableTiktok = r.disableTiktok;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
tiktokRedirects = r.tiktokRedirects;
|
||||
proxiTokNormalRedirectsChecks = r.proxiTokNormalRedirectsChecks;
|
||||
proxiTokNormalCustomRedirects = r.proxiTokNormalCustomRedirects;
|
||||
proxiTokTorRedirectsChecks = r.proxiTokTorRedirectsChecks;
|
||||
proxiTokTorCustomRedirects = r.proxiTokTorCustomRedirects;
|
||||
proxiTokI2pCustomRedirects = r.proxiTokI2pCustomRedirects;
|
||||
proxiTokLokiCustomRedirects = r.proxiTokLokiCustomRedirects;
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableTiktok",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"tiktokRedirects",
|
||||
"proxiTokNormalRedirectsChecks",
|
||||
"proxiTokNormalCustomRedirects",
|
||||
"proxiTokTorRedirectsChecks",
|
||||
"proxiTokTorCustomRedirects",
|
||||
"proxiTokI2pCustomRedirects",
|
||||
"proxiTokLokiCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disableTiktok = r.disableTiktok
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
tiktokRedirects = r.tiktokRedirects
|
||||
proxiTokNormalRedirectsChecks = r.proxiTokNormalRedirectsChecks
|
||||
proxiTokNormalCustomRedirects = r.proxiTokNormalCustomRedirects
|
||||
proxiTokTorRedirectsChecks = r.proxiTokTorRedirectsChecks
|
||||
proxiTokTorCustomRedirects = r.proxiTokTorCustomRedirects
|
||||
proxiTokI2pCustomRedirects = r.proxiTokI2pCustomRedirects
|
||||
proxiTokLokiCustomRedirects = r.proxiTokLokiCustomRedirects
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
// https://www.tiktok.com/@keysikaspol/video/7061265241887345946
|
||||
// https://www.tiktok.com/@keysikaspol
|
||||
function redirect(url, type, initiator, disableOverride) {
|
||||
if (disableTiktok && !disableOverride) return;
|
||||
if (type != "main_frame") return;
|
||||
const all = [
|
||||
...tiktokRedirects.proxiTok.normal,
|
||||
...proxiTokNormalCustomRedirects
|
||||
];
|
||||
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return;
|
||||
if (!targets.some(rx => rx.test(url.href))) return;
|
||||
if (disableTiktok && !disableOverride) return
|
||||
if (type != "main_frame") return
|
||||
const all = [...tiktokRedirects.proxiTok.normal, ...proxiTokNormalCustomRedirects]
|
||||
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return
|
||||
if (!targets.some(rx => rx.test(url.href))) return
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...proxiTokI2pCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...proxiTokLokiCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) return;
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...proxiTokI2pCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...proxiTokLokiCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]
|
||||
}
|
||||
if (instancesList.length === 0) return
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
return `${randomInstance}${url.pathname}`;
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
return `${randomInstance}${url.pathname}`
|
||||
}
|
||||
|
||||
function reverse(url) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
let protocolHost = utils.protocolHost(url);
|
||||
const all = [
|
||||
...tiktokRedirects.proxiTok.normal,
|
||||
...tiktokRedirects.proxiTok.tor,
|
||||
...proxiTokNormalCustomRedirects,
|
||||
...proxiTokTorCustomRedirects,
|
||||
...proxiTokI2pCustomRedirects,
|
||||
...proxiTokLokiCustomRedirects
|
||||
];
|
||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
let protocolHost = utils.protocolHost(url)
|
||||
const all = [
|
||||
...tiktokRedirects.proxiTok.normal,
|
||||
...tiktokRedirects.proxiTok.tor,
|
||||
...proxiTokNormalCustomRedirects,
|
||||
...proxiTokTorCustomRedirects,
|
||||
...proxiTokI2pCustomRedirects,
|
||||
...proxiTokLokiCustomRedirects,
|
||||
]
|
||||
if (!all.includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
resolve(`https://tiktok.com${url.pathname}${url.search}`);
|
||||
})
|
||||
resolve(`https://tiktok.com${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function switchInstance(url, disableOverride) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableTiktok && !disableOverride) { resolve(); return; }
|
||||
let protocolHost = utils.protocolHost(url);
|
||||
const all = [
|
||||
...tiktokRedirects.proxiTok.tor,
|
||||
...tiktokRedirects.proxiTok.normal,
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableTiktok && !disableOverride) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let protocolHost = utils.protocolHost(url)
|
||||
const all = [
|
||||
...tiktokRedirects.proxiTok.tor,
|
||||
...tiktokRedirects.proxiTok.normal,
|
||||
|
||||
...proxiTokNormalCustomRedirects,
|
||||
...proxiTokTorCustomRedirects,
|
||||
...proxiTokI2pCustomRedirects,
|
||||
...proxiTokLokiCustomRedirects
|
||||
];
|
||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
||||
...proxiTokNormalCustomRedirects,
|
||||
...proxiTokTorCustomRedirects,
|
||||
...proxiTokI2pCustomRedirects,
|
||||
...proxiTokLokiCustomRedirects,
|
||||
]
|
||||
if (!all.includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...proxiTokI2pCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...proxiTokLokiCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects];
|
||||
}
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...proxiTokI2pCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...proxiTokLokiCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]
|
||||
}
|
||||
|
||||
const i = instancesList.indexOf(protocolHost);
|
||||
if (i > -1) instancesList.splice(i, 1);
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
const i = instancesList.indexOf(protocolHost)
|
||||
if (i > -1) instancesList.splice(i, 1)
|
||||
if (instancesList.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
})
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(async resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.set({
|
||||
disableTiktok: false,
|
||||
return new Promise(async resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(async data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
disableTiktok: false,
|
||||
|
||||
tiktokRedirects: redirects,
|
||||
tiktokRedirects: redirects,
|
||||
|
||||
proxiTokNormalRedirectsChecks: [...redirects.proxiTok.normal],
|
||||
proxiTokNormalCustomRedirects: [],
|
||||
proxiTokNormalRedirectsChecks: [...redirects.proxiTok.normal],
|
||||
proxiTokNormalCustomRedirects: [],
|
||||
|
||||
proxiTokTorRedirectsChecks: [...redirects.proxiTok.tor],
|
||||
proxiTokTorCustomRedirects: [],
|
||||
proxiTokTorRedirectsChecks: [...redirects.proxiTok.tor],
|
||||
proxiTokTorCustomRedirects: [],
|
||||
|
||||
proxiTokI2pRedirectsChecks: [...redirects.proxiTok.i2p],
|
||||
proxiTokI2pCustomRedirects: [],
|
||||
proxiTokI2pRedirectsChecks: [...redirects.proxiTok.i2p],
|
||||
proxiTokI2pCustomRedirects: [],
|
||||
|
||||
proxiTokLokiRedirectsChecks: [...redirects.proxiTok.loki],
|
||||
proxiTokLokiCustomRedirects: []
|
||||
}, () => resolve());
|
||||
});
|
||||
})
|
||||
proxiTokLokiRedirectsChecks: [...redirects.proxiTok.loki],
|
||||
proxiTokLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
setRedirects,
|
||||
|
||||
redirect,
|
||||
reverse,
|
||||
switchInstance,
|
||||
redirect,
|
||||
reverse,
|
||||
switchInstance,
|
||||
|
||||
initProxiTokCookies,
|
||||
pasteProxiTokCookies,
|
||||
initProxiTokCookies,
|
||||
pasteProxiTokCookies,
|
||||
|
||||
initDefaults
|
||||
};
|
||||
initDefaults,
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
browser.storage.local.set(
|
||||
{
|
||||
['lingva_chakra-ui-color-mode']: localStorage.getItem('chakra-ui-color-mode'),
|
||||
lingva_isauto: localStorage.getItem('isauto'),
|
||||
lingva_source: localStorage.getItem('source'),
|
||||
lingva_target: localStorage.getItem('target'),
|
||||
}
|
||||
)
|
||||
browser.storage.local.set({
|
||||
["lingva_chakra-ui-color-mode"]: localStorage.getItem("chakra-ui-color-mode"),
|
||||
lingva_isauto: localStorage.getItem("isauto"),
|
||||
lingva_source: localStorage.getItem("source"),
|
||||
lingva_target: localStorage.getItem("target"),
|
||||
})
|
||||
|
||||
console.log(localStorage.getItem('target'));
|
||||
console.log(localStorage.getItem("target"))
|
||||
|
|
|
@ -1,17 +1,9 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"lingva_chakra-ui-color-mode",
|
||||
"lingva_isauto",
|
||||
"lingva_source",
|
||||
"lingva_target",
|
||||
],
|
||||
r => {
|
||||
if (r['lingva_chakra-ui-color-mode'] !== undefined) localStorage.setItem('chakra-ui-color-mode', r['lingva_chakra-ui-color-mode']);
|
||||
if (r.lingva_isauto !== undefined) localStorage.setItem('isauto', r.lingva_isauto);
|
||||
if (r.lingva_source !== undefined) localStorage.setItem('source', r.lingva_source);
|
||||
if (r.lingva_target !== undefined) localStorage.setItem('target', r.lingva_target);
|
||||
window.close();
|
||||
}
|
||||
)
|
||||
browser.storage.local.get(["lingva_chakra-ui-color-mode", "lingva_isauto", "lingva_source", "lingva_target"], r => {
|
||||
if (r["lingva_chakra-ui-color-mode"] !== undefined) localStorage.setItem("chakra-ui-color-mode", r["lingva_chakra-ui-color-mode"])
|
||||
if (r.lingva_isauto !== undefined) localStorage.setItem("isauto", r.lingva_isauto)
|
||||
if (r.lingva_source !== undefined) localStorage.setItem("source", r.lingva_source)
|
||||
if (r.lingva_target !== undefined) localStorage.setItem("target", r.lingva_target)
|
||||
window.close()
|
||||
})
|
||||
|
|
|
@ -1,379 +1,413 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
import utils from '../utils.js'
|
||||
import utils from "../utils.js"
|
||||
|
||||
const targets = [
|
||||
/^https?:\/{2}translate\.google(\.[a-z]{2,3}){1,2}\//,
|
||||
];
|
||||
const targets = [/^https?:\/{2}translate\.google(\.[a-z]{2,3}){1,2}\//]
|
||||
|
||||
const frontends = new Array("simplyTranslate", "lingva")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
||||
let redirects = {};
|
||||
let redirects = {}
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
let
|
||||
translateDisable,
|
||||
translateFrontend,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
translateRedirects,
|
||||
simplyTranslateNormalRedirectsChecks,
|
||||
simplyTranslateNormalCustomRedirects,
|
||||
simplyTranslateTorRedirectsChecks,
|
||||
simplyTranslateTorCustomRedirects,
|
||||
simplyTranslateI2pRedirectsChecks,
|
||||
simplyTranslateI2pCustomRedirects,
|
||||
simplyTranslateLokiRedirectsChecks,
|
||||
simplyTranslateLokiCustomRedirects,
|
||||
lingvaNormalRedirectsChecks,
|
||||
lingvaNormalCustomRedirects,
|
||||
lingvaTorRedirectsChecks,
|
||||
lingvaTorCustomRedirects,
|
||||
lingvaI2pCustomRedirects,
|
||||
lingvaLokiCustomRedirects
|
||||
let translateDisable,
|
||||
translateFrontend,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
translateRedirects,
|
||||
simplyTranslateNormalRedirectsChecks,
|
||||
simplyTranslateNormalCustomRedirects,
|
||||
simplyTranslateTorRedirectsChecks,
|
||||
simplyTranslateTorCustomRedirects,
|
||||
simplyTranslateI2pRedirectsChecks,
|
||||
simplyTranslateI2pCustomRedirects,
|
||||
simplyTranslateLokiRedirectsChecks,
|
||||
simplyTranslateLokiCustomRedirects,
|
||||
lingvaNormalRedirectsChecks,
|
||||
lingvaNormalCustomRedirects,
|
||||
lingvaTorRedirectsChecks,
|
||||
lingvaTorCustomRedirects,
|
||||
lingvaI2pCustomRedirects,
|
||||
lingvaLokiCustomRedirects
|
||||
|
||||
function init() {
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"translateDisable",
|
||||
"translateFrontend",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"translateRedirects",
|
||||
"simplyTranslateNormalRedirectsChecks",
|
||||
"simplyTranslateNormalCustomRedirects",
|
||||
"simplyTranslateTorRedirectsChecks",
|
||||
"simplyTranslateTorCustomRedirects",
|
||||
"simplyTranslateI2pRedirectsChecks",
|
||||
"simplyTranslateI2pCustomRedirects",
|
||||
"simplyTranslateLokiRedirectsChecks",
|
||||
"simplyTranslateLokiCustomRedirects",
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"translateDisable",
|
||||
"translateFrontend",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"translateRedirects",
|
||||
"simplyTranslateNormalRedirectsChecks",
|
||||
"simplyTranslateNormalCustomRedirects",
|
||||
"simplyTranslateTorRedirectsChecks",
|
||||
"simplyTranslateTorCustomRedirects",
|
||||
"simplyTranslateI2pRedirectsChecks",
|
||||
"simplyTranslateI2pCustomRedirects",
|
||||
"simplyTranslateLokiRedirectsChecks",
|
||||
"simplyTranslateLokiCustomRedirects",
|
||||
|
||||
"lingvaNormalRedirectsChecks",
|
||||
"lingvaNormalCustomRedirects",
|
||||
"lingvaTorRedirectsChecks",
|
||||
"lingvaTorCustomRedirects",
|
||||
"lingvaI2pCustomRedirects",
|
||||
"lingvaLokiCustomRedirects"
|
||||
],
|
||||
r => {
|
||||
translateDisable = r.translateDisable;
|
||||
translateFrontend = r.translateFrontend;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback
|
||||
translateRedirects = r.translateRedirects;
|
||||
simplyTranslateNormalRedirectsChecks = r.simplyTranslateNormalRedirectsChecks;
|
||||
simplyTranslateNormalCustomRedirects = r.simplyTranslateNormalCustomRedirects;
|
||||
simplyTranslateTorRedirectsChecks = r.simplyTranslateTorRedirectsChecks;
|
||||
simplyTranslateTorCustomRedirects = r.simplyTranslateTorCustomRedirects;
|
||||
simplyTranslateI2pRedirectsChecks = r.simplyTranslateI2pRedirectsChecks;
|
||||
simplyTranslateI2pCustomRedirects = r.simplyTranslateI2pCustomRedirects;
|
||||
simplyTranslateLokiRedirectsChecks = r.simplyTranslateLokiRedirectsChecks;
|
||||
simplyTranslateLokiCustomRedirects = r.simplyTranslateLokiCustomRedirects;
|
||||
lingvaNormalRedirectsChecks = r.lingvaNormalRedirectsChecks;
|
||||
lingvaNormalCustomRedirects = r.lingvaNormalCustomRedirects;
|
||||
lingvaTorRedirectsChecks = r.lingvaTorRedirectsChecks;
|
||||
lingvaTorCustomRedirects = r.lingvaTorCustomRedirects;
|
||||
lingvaI2pCustomRedirects = r.lingvaI2pCustomRedirects;
|
||||
lingvaLokiCustomRedirects = r.lingvaLokiCustomRedirects;
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
"lingvaNormalRedirectsChecks",
|
||||
"lingvaNormalCustomRedirects",
|
||||
"lingvaTorRedirectsChecks",
|
||||
"lingvaTorCustomRedirects",
|
||||
"lingvaI2pCustomRedirects",
|
||||
"lingvaLokiCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
translateDisable = r.translateDisable
|
||||
translateFrontend = r.translateFrontend
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
translateRedirects = r.translateRedirects
|
||||
simplyTranslateNormalRedirectsChecks = r.simplyTranslateNormalRedirectsChecks
|
||||
simplyTranslateNormalCustomRedirects = r.simplyTranslateNormalCustomRedirects
|
||||
simplyTranslateTorRedirectsChecks = r.simplyTranslateTorRedirectsChecks
|
||||
simplyTranslateTorCustomRedirects = r.simplyTranslateTorCustomRedirects
|
||||
simplyTranslateI2pRedirectsChecks = r.simplyTranslateI2pRedirectsChecks
|
||||
simplyTranslateI2pCustomRedirects = r.simplyTranslateI2pCustomRedirects
|
||||
simplyTranslateLokiRedirectsChecks = r.simplyTranslateLokiRedirectsChecks
|
||||
simplyTranslateLokiCustomRedirects = r.simplyTranslateLokiCustomRedirects
|
||||
lingvaNormalRedirectsChecks = r.lingvaNormalRedirectsChecks
|
||||
lingvaNormalCustomRedirects = r.lingvaNormalCustomRedirects
|
||||
lingvaTorRedirectsChecks = r.lingvaTorRedirectsChecks
|
||||
lingvaTorCustomRedirects = r.lingvaTorCustomRedirects
|
||||
lingvaI2pCustomRedirects = r.lingvaI2pCustomRedirects
|
||||
lingvaLokiCustomRedirects = r.lingvaLokiCustomRedirects
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get('cloudflareBlackList', r => {
|
||||
redirects = val;
|
||||
lingvaNormalRedirectsChecks = [...redirects.lingva.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const i = lingvaNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) lingvaNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
translateRedirects: redirects,
|
||||
simplyTranslateNormalRedirectsChecks: redirects.simplyTranslate.normal,
|
||||
simplyTranslateTorRedirectsChecks: redirects.simplyTranslate.tor,
|
||||
simplyTranslateI2pRedirectsChecks: redirects.simplyTranslate.i2p,
|
||||
simplyTranslateLokiRedirectsChecks: redirects.simplyTranslate.loki,
|
||||
lingvaNormalRedirectsChecks,
|
||||
lingvaTorRedirectsChecks: redirects.lingva.tor,
|
||||
})
|
||||
})
|
||||
browser.storage.local.get("cloudflareBlackList", r => {
|
||||
redirects = val
|
||||
lingvaNormalRedirectsChecks = [...redirects.lingva.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const i = lingvaNormalRedirectsChecks.indexOf(instance)
|
||||
if (i > -1) lingvaNormalRedirectsChecks.splice(i, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
translateRedirects: redirects,
|
||||
simplyTranslateNormalRedirectsChecks: redirects.simplyTranslate.normal,
|
||||
simplyTranslateTorRedirectsChecks: redirects.simplyTranslate.tor,
|
||||
simplyTranslateI2pRedirectsChecks: redirects.simplyTranslate.i2p,
|
||||
simplyTranslateLokiRedirectsChecks: redirects.simplyTranslate.loki,
|
||||
lingvaNormalRedirectsChecks,
|
||||
lingvaTorRedirectsChecks: redirects.lingva.tor,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function copyPasteLingvaLocalStorage(test, url, tabId) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (translateDisable || translateFrontend != 'lingva') { resolve(); return; }
|
||||
const protocolHost = utils.protocolHost(url);
|
||||
if (![
|
||||
...lingvaNormalRedirectsChecks,
|
||||
...lingvaNormalCustomRedirects,
|
||||
...lingvaTorRedirectsChecks,
|
||||
...lingvaTorCustomRedirects,
|
||||
...lingvaI2pCustomRedirects,
|
||||
...lingvaLokiCustomRedirects
|
||||
].includes(protocolHost)) { resolve(); return; }
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (translateDisable || translateFrontend != "lingva") {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
const protocolHost = utils.protocolHost(url)
|
||||
if (
|
||||
![...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects, ...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects, ...lingvaI2pCustomRedirects, ...lingvaLokiCustomRedirects].includes(
|
||||
protocolHost
|
||||
)
|
||||
) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
if (!test) {
|
||||
browser.tabs.executeScript(
|
||||
tabId,
|
||||
{ file: "/assets/javascripts/translate/get_lingva_preferences.js", runAt: "document_start" }
|
||||
);
|
||||
if (!test) {
|
||||
browser.tabs.executeScript(tabId, {
|
||||
file: "/assets/javascripts/translate/get_lingva_preferences.js",
|
||||
runAt: "document_start",
|
||||
})
|
||||
|
||||
let checkedInstances = [];
|
||||
if (protocol == 'loki') checkedInstances = [...lingvaLokiCustomRedirects]; //...lingvaLokiRedirectsChecks,
|
||||
else if (protocol == 'i2p') checkedInstances = [...lingvaI2pCustomRedirects]; //...lingvaI2pRedirectsChecks,
|
||||
else if (protocol == 'tor') checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects];
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
checkedInstances = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects];
|
||||
}
|
||||
const i = checkedInstances.indexOf(protocolHost);
|
||||
if (i !== -1) checkedInstances.splice(i, 1);
|
||||
if (checkedInstances.length === 0) { resolve(); return; }
|
||||
for (const to of checkedInstances)
|
||||
browser.tabs.create(
|
||||
{ url: to },
|
||||
tab => browser.tabs.executeScript(tab.id, { file: "/assets/javascripts/translate/set_lingva_preferences.js", runAt: "document_start" })
|
||||
);
|
||||
}
|
||||
resolve(true);
|
||||
}
|
||||
)
|
||||
let checkedInstances = []
|
||||
if (protocol == "loki") checkedInstances = [...lingvaLokiCustomRedirects]
|
||||
//...lingvaLokiRedirectsChecks,
|
||||
else if (protocol == "i2p") checkedInstances = [...lingvaI2pCustomRedirects]
|
||||
//...lingvaI2pRedirectsChecks,
|
||||
else if (protocol == "tor") checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
checkedInstances = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]
|
||||
}
|
||||
const i = checkedInstances.indexOf(protocolHost)
|
||||
if (i !== -1) checkedInstances.splice(i, 1)
|
||||
if (checkedInstances.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
for (const to of checkedInstances)
|
||||
browser.tabs.create({ url: to }, tab =>
|
||||
browser.tabs.executeScript(tab.id, {
|
||||
file: "/assets/javascripts/translate/set_lingva_preferences.js",
|
||||
runAt: "document_start",
|
||||
})
|
||||
)
|
||||
}
|
||||
resolve(true)
|
||||
})
|
||||
}
|
||||
|
||||
function pasteLingvaLocalStorage() {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (translateDisable || translateFrontend != 'lingva') { resolve(); return; }
|
||||
let checkedInstances = [];
|
||||
if (protocol == 'loki') checkedInstances = [...lingvaLokiCustomRedirects]; //...lingvaLokiRedirectsChecks,
|
||||
else if (protocol == 'i2p') checkedInstances = [...lingvaI2pCustomRedirects]; //...lingvaI2pRedirectsChecks,
|
||||
else if (protocol == 'tor') checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects];
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
checkedInstances = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects];
|
||||
}
|
||||
for (const to of checkedInstances)
|
||||
browser.tabs.create({ url: to },
|
||||
tab => browser.tabs.executeScript(tab.id, { file: "/assets/javascripts/translate/set_lingva_preferences.js", runAt: "document_start" }))
|
||||
resolve();
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (translateDisable || translateFrontend != "lingva") {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let checkedInstances = []
|
||||
if (protocol == "loki") checkedInstances = [...lingvaLokiCustomRedirects]
|
||||
//...lingvaLokiRedirectsChecks,
|
||||
else if (protocol == "i2p") checkedInstances = [...lingvaI2pCustomRedirects]
|
||||
//...lingvaI2pRedirectsChecks,
|
||||
else if (protocol == "tor") checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
checkedInstances = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]
|
||||
}
|
||||
for (const to of checkedInstances)
|
||||
browser.tabs.create({ url: to }, tab =>
|
||||
browser.tabs.executeScript(tab.id, {
|
||||
file: "/assets/javascripts/translate/set_lingva_preferences.js",
|
||||
runAt: "document_start",
|
||||
})
|
||||
)
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
function copyPasteSimplyTranslateCookies(test, from) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
const protocolHost = utils.protocolHost(from);
|
||||
if (![
|
||||
...simplyTranslateNormalRedirectsChecks,
|
||||
...simplyTranslateNormalCustomRedirects,
|
||||
...simplyTranslateTorRedirectsChecks,
|
||||
...simplyTranslateTorCustomRedirects,
|
||||
...simplyTranslateI2pRedirectsChecks,
|
||||
...simplyTranslateI2pCustomRedirects,
|
||||
...simplyTranslateLokiRedirectsChecks,
|
||||
...simplyTranslateLokiCustomRedirects,
|
||||
].includes(protocolHost)) { resolve(); return; }
|
||||
if (!test) {
|
||||
let checkedInstances = [];
|
||||
if (protocol == 'loki') checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects]
|
||||
else if (protocol == 'i2p') checkedInstances = [...simplyTranslateI2pCustomRedirects, ...simplyTranslateI2pRedirectsChecks];
|
||||
else if (protocol == 'tor') checkedInstances = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects];
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
checkedInstances = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects];
|
||||
}
|
||||
await utils.copyCookie('simplyTranslate', from, checkedInstances, 'from_lang');
|
||||
await utils.copyCookie('simplyTranslate', from, checkedInstances, 'to_lang');
|
||||
await utils.copyCookie('simplyTranslate', from, checkedInstances, 'tts_enabled');
|
||||
await utils.copyCookie('simplyTranslate', from, checkedInstances, 'use_text_fields');
|
||||
}
|
||||
resolve(true);
|
||||
}
|
||||
)
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
const protocolHost = utils.protocolHost(from)
|
||||
if (
|
||||
![
|
||||
...simplyTranslateNormalRedirectsChecks,
|
||||
...simplyTranslateNormalCustomRedirects,
|
||||
...simplyTranslateTorRedirectsChecks,
|
||||
...simplyTranslateTorCustomRedirects,
|
||||
...simplyTranslateI2pRedirectsChecks,
|
||||
...simplyTranslateI2pCustomRedirects,
|
||||
...simplyTranslateLokiRedirectsChecks,
|
||||
...simplyTranslateLokiCustomRedirects,
|
||||
].includes(protocolHost)
|
||||
) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
if (!test) {
|
||||
let checkedInstances = []
|
||||
if (protocol == "loki") checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects]
|
||||
else if (protocol == "i2p") checkedInstances = [...simplyTranslateI2pCustomRedirects, ...simplyTranslateI2pRedirectsChecks]
|
||||
else if (protocol == "tor") checkedInstances = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
checkedInstances = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects]
|
||||
}
|
||||
await utils.copyCookie("simplyTranslate", from, checkedInstances, "from_lang")
|
||||
await utils.copyCookie("simplyTranslate", from, checkedInstances, "to_lang")
|
||||
await utils.copyCookie("simplyTranslate", from, checkedInstances, "tts_enabled")
|
||||
await utils.copyCookie("simplyTranslate", from, checkedInstances, "use_text_fields")
|
||||
}
|
||||
resolve(true)
|
||||
})
|
||||
}
|
||||
|
||||
function pasteSimplyTranslateCookies() {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (translateDisable || translateFrontend != 'simplyTranslate') { resolve(); return; }
|
||||
let checkedInstances = [];
|
||||
if (protocol == 'loki') checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects]
|
||||
else if (protocol == 'i2p') checkedInstances = [...simplyTranslateI2pCustomRedirects, ...simplyTranslateI2pRedirectsChecks];
|
||||
else if (protocol == 'tor') checkedInstances = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects];
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
checkedInstances = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects];
|
||||
}
|
||||
utils.getCookiesFromStorage('simplyTranslate', checkedInstances, 'from_lang');
|
||||
utils.getCookiesFromStorage('simplyTranslate', checkedInstances, 'to_lang');
|
||||
utils.getCookiesFromStorage('simplyTranslate', checkedInstances, 'tts_enabled');
|
||||
utils.getCookiesFromStorage('simplyTranslate', checkedInstances, 'use_text_fields');
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (translateDisable || translateFrontend != "simplyTranslate") {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let checkedInstances = []
|
||||
if (protocol == "loki") checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects]
|
||||
else if (protocol == "i2p") checkedInstances = [...simplyTranslateI2pCustomRedirects, ...simplyTranslateI2pRedirectsChecks]
|
||||
else if (protocol == "tor") checkedInstances = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
checkedInstances = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects]
|
||||
}
|
||||
utils.getCookiesFromStorage("simplyTranslate", checkedInstances, "from_lang")
|
||||
utils.getCookiesFromStorage("simplyTranslate", checkedInstances, "to_lang")
|
||||
utils.getCookiesFromStorage("simplyTranslate", checkedInstances, "tts_enabled")
|
||||
utils.getCookiesFromStorage("simplyTranslate", checkedInstances, "use_text_fields")
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
function redirect(url, disableOverride) {
|
||||
if (translateDisable && !disableOverride) return;
|
||||
if (!targets.some(rx => rx.test(url.href))) return;
|
||||
if (translateDisable && !disableOverride) return
|
||||
if (!targets.some(rx => rx.test(url.href))) return
|
||||
|
||||
if (translateFrontend == 'simplyTranslate') {
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...simplyTranslateI2pRedirectsChecks, ...simplyTranslateI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) return;
|
||||
if (translateFrontend == "simplyTranslate") {
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...simplyTranslateI2pRedirectsChecks, ...simplyTranslateI2pCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects]
|
||||
}
|
||||
if (instancesList.length === 0) return
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
return `${randomInstance}/${url.search}`;
|
||||
}
|
||||
else if (translateFrontend == 'lingva') {
|
||||
let params_arr = url.search.split('&');
|
||||
params_arr[0] = params_arr[0].substring(1);
|
||||
let params = {};
|
||||
for (let i = 0; i < params_arr.length; i++) {
|
||||
let pair = params_arr[i].split('=');
|
||||
params[pair[0]] = pair[1];
|
||||
}
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...lingvaLokiCustomRedirects]; //...lingvaLokiRedirectsChecks,
|
||||
else if (protocol == 'i2p') instancesList = [...lingvaI2pCustomRedirects]; //...lingvaI2pRedirectsChecks,
|
||||
if (protocol == 'tor') instancesList = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) return;
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
return `${randomInstance}/${url.search}`
|
||||
} else if (translateFrontend == "lingva") {
|
||||
let params_arr = url.search.split("&")
|
||||
params_arr[0] = params_arr[0].substring(1)
|
||||
let params = {}
|
||||
for (let i = 0; i < params_arr.length; i++) {
|
||||
let pair = params_arr[i].split("=")
|
||||
params[pair[0]] = pair[1]
|
||||
}
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...lingvaLokiCustomRedirects]
|
||||
//...lingvaLokiRedirectsChecks,
|
||||
else if (protocol == "i2p") instancesList = [...lingvaI2pCustomRedirects] //...lingvaI2pRedirectsChecks,
|
||||
if (protocol == "tor") instancesList = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]
|
||||
}
|
||||
if (instancesList.length === 0) return
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
if (params.sl && params.tl && params.text) {
|
||||
return `${randomInstance}/${params.sl}/${params.tl}/${params.text}`
|
||||
}
|
||||
return randomInstance;
|
||||
}
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
if (params.sl && params.tl && params.text) {
|
||||
return `${randomInstance}/${params.sl}/${params.tl}/${params.text}`
|
||||
}
|
||||
return randomInstance
|
||||
}
|
||||
}
|
||||
|
||||
function switchInstance(url, disableOverride) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (translateDisable && !disableOverride) { resolve(); return; }
|
||||
const protocolHost = utils.protocolHost(url);
|
||||
if (![
|
||||
...translateRedirects.simplyTranslate.normal,
|
||||
...translateRedirects.simplyTranslate.tor,
|
||||
...translateRedirects.simplyTranslate.i2p,
|
||||
...translateRedirects.simplyTranslate.loki,
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (translateDisable && !disableOverride) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
const protocolHost = utils.protocolHost(url)
|
||||
if (
|
||||
![
|
||||
...translateRedirects.simplyTranslate.normal,
|
||||
...translateRedirects.simplyTranslate.tor,
|
||||
...translateRedirects.simplyTranslate.i2p,
|
||||
...translateRedirects.simplyTranslate.loki,
|
||||
|
||||
...simplyTranslateNormalCustomRedirects,
|
||||
...simplyTranslateTorCustomRedirects,
|
||||
...simplyTranslateI2pCustomRedirects,
|
||||
...simplyTranslateLokiCustomRedirects,
|
||||
...simplyTranslateNormalCustomRedirects,
|
||||
...simplyTranslateTorCustomRedirects,
|
||||
...simplyTranslateI2pCustomRedirects,
|
||||
...simplyTranslateLokiCustomRedirects,
|
||||
|
||||
...translateRedirects.lingva.normal,
|
||||
...translateRedirects.lingva.tor,
|
||||
...translateRedirects.lingva.normal,
|
||||
...translateRedirects.lingva.tor,
|
||||
|
||||
...lingvaNormalCustomRedirects,
|
||||
...lingvaTorCustomRedirects,
|
||||
...lingvaI2pCustomRedirects,
|
||||
...lingvaLokiCustomRedirects
|
||||
].includes(protocolHost)) { resolve(); return; }
|
||||
...lingvaNormalCustomRedirects,
|
||||
...lingvaTorCustomRedirects,
|
||||
...lingvaI2pCustomRedirects,
|
||||
...lingvaLokiCustomRedirects,
|
||||
].includes(protocolHost)
|
||||
) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
let instancesList;
|
||||
let instancesList
|
||||
|
||||
if (protocol == 'loki') {
|
||||
if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects];
|
||||
else if (translateFrontend == 'lingva') instancesList = [...lingvaLokiCustomRedirects]; //...lingvaLokiRedirectsChecks,
|
||||
}
|
||||
else if (protocol == 'i2p') {
|
||||
if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateI2pRedirectsChecks, ...simplyTranslateI2pCustomRedirects];
|
||||
else if (translateFrontend == 'lingva') instancesList = [...lingvaI2pCustomRedirects]; //...lingvaI2pRedirectsChecks,
|
||||
}
|
||||
else if (protocol == 'tor') {
|
||||
if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects];
|
||||
else if (translateFrontend == 'lingva') instancesList = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects];
|
||||
}
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects];
|
||||
else if (translateFrontend == 'lingva') instancesList = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects];
|
||||
}
|
||||
if (protocol == "loki") {
|
||||
if (translateFrontend == "simplyTranslate") instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects]
|
||||
else if (translateFrontend == "lingva") instancesList = [...lingvaLokiCustomRedirects] //...lingvaLokiRedirectsChecks,
|
||||
} else if (protocol == "i2p") {
|
||||
if (translateFrontend == "simplyTranslate") instancesList = [...simplyTranslateI2pRedirectsChecks, ...simplyTranslateI2pCustomRedirects]
|
||||
else if (translateFrontend == "lingva") instancesList = [...lingvaI2pCustomRedirects] //...lingvaI2pRedirectsChecks,
|
||||
} else if (protocol == "tor") {
|
||||
if (translateFrontend == "simplyTranslate") instancesList = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]
|
||||
else if (translateFrontend == "lingva") instancesList = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]
|
||||
}
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
if (translateFrontend == "simplyTranslate") instancesList = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects]
|
||||
else if (translateFrontend == "lingva") instancesList = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]
|
||||
}
|
||||
|
||||
const i = instancesList.indexOf(protocolHost);
|
||||
if (i > -1) instancesList.splice(i, 1);
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
const i = instancesList.indexOf(protocolHost)
|
||||
if (i > -1) instancesList.splice(i, 1)
|
||||
if (instancesList.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
})
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(async resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get('cloudflareBlackList',
|
||||
async r => {
|
||||
lingvaNormalRedirectsChecks = [...redirects.lingva.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const i = lingvaNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) lingvaNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
translateDisable: false,
|
||||
translateFrontend: "simplyTranslate",
|
||||
translateRedirects: redirects,
|
||||
return new Promise(async resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||
lingvaNormalRedirectsChecks = [...redirects.lingva.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const i = lingvaNormalRedirectsChecks.indexOf(instance)
|
||||
if (i > -1) lingvaNormalRedirectsChecks.splice(i, 1)
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
translateDisable: false,
|
||||
translateFrontend: "simplyTranslate",
|
||||
translateRedirects: redirects,
|
||||
|
||||
simplyTranslateNormalRedirectsChecks: [...redirects.simplyTranslate.normal],
|
||||
simplyTranslateNormalCustomRedirects: [],
|
||||
|
||||
simplyTranslateTorRedirectsChecks: [...redirects.simplyTranslate.tor],
|
||||
simplyTranslateTorCustomRedirects: [],
|
||||
|
||||
simplyTranslateI2pRedirectsChecks: [...redirects.simplyTranslate.i2p],
|
||||
simplyTranslateI2pCustomRedirects: [],
|
||||
|
||||
simplyTranslateLokiRedirectsChecks: [...redirects.simplyTranslate.loki],
|
||||
simplyTranslateLokiCustomRedirects: [],
|
||||
simplyTranslateNormalRedirectsChecks: [...redirects.simplyTranslate.normal],
|
||||
simplyTranslateNormalCustomRedirects: [],
|
||||
|
||||
lingvaNormalRedirectsChecks: lingvaNormalRedirectsChecks,
|
||||
lingvaNormalCustomRedirects: [],
|
||||
simplyTranslateTorRedirectsChecks: [...redirects.simplyTranslate.tor],
|
||||
simplyTranslateTorCustomRedirects: [],
|
||||
|
||||
lingvaTorRedirectsChecks: [...redirects.lingva.tor],
|
||||
lingvaTorCustomRedirects: [],
|
||||
simplyTranslateI2pRedirectsChecks: [...redirects.simplyTranslate.i2p],
|
||||
simplyTranslateI2pCustomRedirects: [],
|
||||
|
||||
lingvaI2pRedirectsChecks: [...redirects.lingva.i2p],
|
||||
lingvaI2pCustomRedirects: [],
|
||||
simplyTranslateLokiRedirectsChecks: [...redirects.simplyTranslate.loki],
|
||||
simplyTranslateLokiCustomRedirects: [],
|
||||
|
||||
lingvaLokiRedirectsChecks: [...redirects.lingva.loki],
|
||||
lingvaLokiCustomRedirects: []
|
||||
}, () => resolve())
|
||||
})
|
||||
})
|
||||
})
|
||||
lingvaNormalRedirectsChecks: lingvaNormalRedirectsChecks,
|
||||
lingvaNormalCustomRedirects: [],
|
||||
|
||||
lingvaTorRedirectsChecks: [...redirects.lingva.tor],
|
||||
lingvaTorCustomRedirects: [],
|
||||
|
||||
lingvaI2pRedirectsChecks: [...redirects.lingva.i2p],
|
||||
lingvaI2pCustomRedirects: [],
|
||||
|
||||
lingvaLokiRedirectsChecks: [...redirects.lingva.loki],
|
||||
lingvaLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
copyPasteSimplyTranslateCookies,
|
||||
pasteSimplyTranslateCookies,
|
||||
copyPasteLingvaLocalStorage,
|
||||
pasteLingvaLocalStorage,
|
||||
setRedirects,
|
||||
redirect,
|
||||
initDefaults,
|
||||
switchInstance,
|
||||
};
|
||||
copyPasteSimplyTranslateCookies,
|
||||
pasteSimplyTranslateCookies,
|
||||
copyPasteLingvaLocalStorage,
|
||||
pasteLingvaLocalStorage,
|
||||
setRedirects,
|
||||
redirect,
|
||||
initDefaults,
|
||||
switchInstance,
|
||||
}
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
import utils from './utils.js'
|
||||
import utils from "./utils.js"
|
||||
|
||||
const targets = [
|
||||
/^https?:\/{2}(www\.|mobile\.|)twitter\.com/,
|
||||
/^https?:\/{2}(pbs\.|video\.|)twimg\.com/,
|
||||
/^https?:\/{2}platform\.twitter\.com\/embed/,
|
||||
/^https?:\/{2}t\.co/
|
||||
];
|
||||
const targets = [/^https?:\/{2}(www\.|mobile\.|)twitter\.com/, /^https?:\/{2}(pbs\.|video\.|)twimg\.com/, /^https?:\/{2}platform\.twitter\.com\/embed/, /^https?:\/{2}t\.co/]
|
||||
|
||||
const frontends = new Array("nitter")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
@ -15,287 +10,295 @@ const protocols = new Array("normal", "tor", "i2p", "loki")
|
|||
let redirects = {}
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get(['cloudflareBlackList', 'authenticateBlackList'], r => {
|
||||
redirects.nitter = val;
|
||||
nitterNormalRedirectsChecks = [...redirects.nitter.normal];
|
||||
for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList]) {
|
||||
let i = nitterNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) nitterNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
twitterRedirects: redirects,
|
||||
nitterNormalRedirectsChecks,
|
||||
nitterTorRedirectsChecks: [...redirects.nitter.tor]
|
||||
})
|
||||
})
|
||||
browser.storage.local.get(["cloudflareBlackList", "authenticateBlackList"], r => {
|
||||
redirects.nitter = val
|
||||
nitterNormalRedirectsChecks = [...redirects.nitter.normal]
|
||||
for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList]) {
|
||||
let i = nitterNormalRedirectsChecks.indexOf(instance)
|
||||
if (i > -1) nitterNormalRedirectsChecks.splice(i, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
twitterRedirects: redirects,
|
||||
nitterNormalRedirectsChecks,
|
||||
nitterTorRedirectsChecks: [...redirects.nitter.tor],
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
disableTwitter,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
twitterRedirects,
|
||||
twitterRedirectType,
|
||||
nitterNormalRedirectsChecks,
|
||||
nitterNormalCustomRedirects,
|
||||
nitterTorRedirectsChecks,
|
||||
nitterTorCustomRedirects,
|
||||
nitterI2pCustomRedirects,
|
||||
nitterLokiCustomRedirects;
|
||||
let disableTwitter,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
twitterRedirects,
|
||||
twitterRedirectType,
|
||||
nitterNormalRedirectsChecks,
|
||||
nitterNormalCustomRedirects,
|
||||
nitterTorRedirectsChecks,
|
||||
nitterTorCustomRedirects,
|
||||
nitterI2pCustomRedirects,
|
||||
nitterLokiCustomRedirects
|
||||
|
||||
function init() {
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableTwitter",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"twitterRedirects",
|
||||
"twitterRedirectType",
|
||||
"nitterNormalRedirectsChecks",
|
||||
"nitterNormalCustomRedirects",
|
||||
"nitterTorRedirectsChecks",
|
||||
"nitterTorCustomRedirects",
|
||||
"nitterI2pCustomRedirects",
|
||||
"nitterLokiCustomRedirects"
|
||||
],
|
||||
r => {
|
||||
disableTwitter = r.disableTwitter;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
twitterRedirects = r.twitterRedirects;
|
||||
twitterRedirectType = r.twitterRedirectType;
|
||||
nitterNormalRedirectsChecks = r.nitterNormalRedirectsChecks;
|
||||
nitterNormalCustomRedirects = r.nitterNormalCustomRedirects;
|
||||
nitterTorRedirectsChecks = r.nitterTorRedirectsChecks;
|
||||
nitterTorCustomRedirects = r.nitterTorCustomRedirects;
|
||||
nitterI2pCustomRedirects = r.nitterI2pCustomRedirects;
|
||||
nitterLokiCustomRedirects = r.nitterLokiCustomRedirects;
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableTwitter",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"twitterRedirects",
|
||||
"twitterRedirectType",
|
||||
"nitterNormalRedirectsChecks",
|
||||
"nitterNormalCustomRedirects",
|
||||
"nitterTorRedirectsChecks",
|
||||
"nitterTorCustomRedirects",
|
||||
"nitterI2pCustomRedirects",
|
||||
"nitterLokiCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disableTwitter = r.disableTwitter
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
twitterRedirects = r.twitterRedirects
|
||||
twitterRedirectType = r.twitterRedirectType
|
||||
nitterNormalRedirectsChecks = r.nitterNormalRedirectsChecks
|
||||
nitterNormalCustomRedirects = r.nitterNormalCustomRedirects
|
||||
nitterTorRedirectsChecks = r.nitterTorRedirectsChecks
|
||||
nitterTorCustomRedirects = r.nitterTorCustomRedirects
|
||||
nitterI2pCustomRedirects = r.nitterI2pCustomRedirects
|
||||
nitterLokiCustomRedirects = r.nitterLokiCustomRedirects
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function all() {
|
||||
return [
|
||||
...nitterNormalRedirectsChecks,
|
||||
...nitterTorRedirectsChecks,
|
||||
...nitterNormalCustomRedirects,
|
||||
...nitterTorCustomRedirects,
|
||||
...nitterI2pCustomRedirects,
|
||||
...nitterLokiCustomRedirects
|
||||
];
|
||||
return [...nitterNormalRedirectsChecks, ...nitterTorRedirectsChecks, ...nitterNormalCustomRedirects, ...nitterTorCustomRedirects, ...nitterI2pCustomRedirects, ...nitterLokiCustomRedirects]
|
||||
}
|
||||
|
||||
function redirect(url, type, initiator, disableOverride) {
|
||||
if (disableTwitter && !disableOverride) return;
|
||||
if (!targets.some(rx => rx.test(url.href))) return;
|
||||
if (url.pathname.split("/").includes("home")) return;
|
||||
if (initiator && all().includes(initiator.origin)) return 'BYPASSTAB';
|
||||
if (twitterRedirectType == 'sub_frame' && type == "main_frame") return;
|
||||
if (twitterRedirectType == 'main_frame' && type != "main_frame") return;
|
||||
if (disableTwitter && !disableOverride) return
|
||||
if (!targets.some(rx => rx.test(url.href))) return
|
||||
if (url.pathname.split("/").includes("home")) return
|
||||
if (initiator && all().includes(initiator.origin)) return "BYPASSTAB"
|
||||
if (twitterRedirectType == "sub_frame" && type == "main_frame") return
|
||||
if (twitterRedirectType == "main_frame" && type != "main_frame") return
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...nitterI2pCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...nitterLokiCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) return;
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...nitterI2pCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...nitterLokiCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]
|
||||
}
|
||||
if (instancesList.length === 0) return
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
// https://pbs.twimg.com/profile_images/648888480974508032/66_cUYfj_400x400.jpg
|
||||
if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video") {
|
||||
const [, id, format, extra] = url.search.match(/(.*)\?format=(.*)&(.*)/);
|
||||
const query = encodeURIComponent(`${id}.${format}?${extra}`);
|
||||
return `${randomInstance}/pic${url.pathname}${query}`;
|
||||
}
|
||||
else if (url.pathname.split("/").includes("tweets"))
|
||||
return `${randomInstance}${url.pathname.replace("/tweets", "")}${url.search}`;
|
||||
else if (url.host == 't.co')
|
||||
return `${randomInstance}/t.co${url.pathname}`;
|
||||
else
|
||||
return `${randomInstance}${url.pathname}${url.search}`;
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
// https://pbs.twimg.com/profile_images/648888480974508032/66_cUYfj_400x400.jpg
|
||||
if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video") {
|
||||
const [, id, format, extra] = url.search.match(/(.*)\?format=(.*)&(.*)/)
|
||||
const query = encodeURIComponent(`${id}.${format}?${extra}`)
|
||||
return `${randomInstance}/pic${url.pathname}${query}`
|
||||
} else if (url.pathname.split("/").includes("tweets")) return `${randomInstance}${url.pathname.replace("/tweets", "")}${url.search}`
|
||||
else if (url.host == "t.co") return `${randomInstance}/t.co${url.pathname}`
|
||||
else return `${randomInstance}${url.pathname}${url.search}`
|
||||
}
|
||||
|
||||
function reverse(url) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
const protocolHost = utils.protocolHost(url);
|
||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
||||
resolve(`https://twitter.com${url.pathname}${url.search}`);
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
const protocolHost = utils.protocolHost(url)
|
||||
if (!all().includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
resolve(`https://twitter.com${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function switchInstance(url, disableOverride) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableTwitter && !disableOverride) { resolve(); return; }
|
||||
const protocolHost = utils.protocolHost(url);
|
||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...nitterI2pCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...nitterLokiCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects];
|
||||
}
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableTwitter && !disableOverride) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
const protocolHost = utils.protocolHost(url)
|
||||
if (!all().includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...nitterI2pCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...nitterLokiCustomRedirects]
|
||||
else if (protocol == "tor") instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]
|
||||
}
|
||||
|
||||
let index = instancesList.indexOf(protocolHost);
|
||||
if (index > -1) instancesList.splice(index, 1);
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
let index = instancesList.indexOf(protocolHost)
|
||||
if (index > -1) instancesList.splice(index, 1)
|
||||
if (instancesList.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
})
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function removeXFrameOptions(e) {
|
||||
if (e.type != 'sub_frame') return;
|
||||
let url = new URL(e.url);
|
||||
let protocolHost = utils.protocolHost(url);
|
||||
if (!all().includes(protocolHost)) return;
|
||||
let isChanged = false;
|
||||
for (const i in e.responseHeaders) {
|
||||
if (e.responseHeaders[i].name == 'x-frame-options') {
|
||||
e.responseHeaders.splice(i, 1);
|
||||
isChanged = true;
|
||||
}
|
||||
else if (e.responseHeaders[i].name == 'content-security-policy') {
|
||||
e.responseHeaders.splice(i, 1);
|
||||
isChanged = true;
|
||||
}
|
||||
}
|
||||
if (isChanged) return { responseHeaders: e.responseHeaders };
|
||||
if (e.type != "sub_frame") return
|
||||
let url = new URL(e.url)
|
||||
let protocolHost = utils.protocolHost(url)
|
||||
if (!all().includes(protocolHost)) return
|
||||
let isChanged = false
|
||||
for (const i in e.responseHeaders) {
|
||||
if (e.responseHeaders[i].name == "x-frame-options") {
|
||||
e.responseHeaders.splice(i, 1)
|
||||
isChanged = true
|
||||
} else if (e.responseHeaders[i].name == "content-security-policy") {
|
||||
e.responseHeaders.splice(i, 1)
|
||||
isChanged = true
|
||||
}
|
||||
}
|
||||
if (isChanged) return { responseHeaders: e.responseHeaders }
|
||||
}
|
||||
|
||||
function initNitterCookies(test, from) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
const protocolHost = utils.protocolHost(from);
|
||||
if (!all().includes(protocolHost)
|
||||
) { resolve(); return; }
|
||||
if (!test) {
|
||||
let checkedInstances = [];
|
||||
if (protocol == 'loki') checkedInstances = [...nitterI2pCustomRedirects];
|
||||
else if (protocol == 'i2p') checkedInstances = [...nitterLokiCustomRedirects];
|
||||
else if (protocol == 'tor') checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects];
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects];
|
||||
}
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'theme');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'infiniteScroll');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'stickyProfile');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'bidiSupport');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'hideTweetStats');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'hideBanner');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'hidePins');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'hideReplies');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'squareAvatars');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'mp4Playback');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'hlsPlayback');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'proxyVideos');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'muteVideos');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'autoplayGifs');
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
const protocolHost = utils.protocolHost(from)
|
||||
if (!all().includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
if (!test) {
|
||||
let checkedInstances = []
|
||||
if (protocol == "loki") checkedInstances = [...nitterI2pCustomRedirects]
|
||||
else if (protocol == "i2p") checkedInstances = [...nitterLokiCustomRedirects]
|
||||
else if (protocol == "tor") checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]
|
||||
}
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "theme")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "infiniteScroll")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "stickyProfile")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "bidiSupport")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "hideTweetStats")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "hideBanner")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "hidePins")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "hideReplies")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "squareAvatars")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "mp4Playback")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "hlsPlayback")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "proxyVideos")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "muteVideos")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "autoplayGifs")
|
||||
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'replaceInstagram');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'replaceReddit');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'replaceTwitter');
|
||||
await utils.copyCookie('nitter', from, checkedInstances, 'replaceYouTube');
|
||||
}
|
||||
resolve(true);
|
||||
})
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "replaceInstagram")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "replaceReddit")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "replaceTwitter")
|
||||
await utils.copyCookie("nitter", from, checkedInstances, "replaceYouTube")
|
||||
}
|
||||
resolve(true)
|
||||
})
|
||||
}
|
||||
|
||||
function pasteNitterCookies() {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableTwitter || protocol === undefined) { resolve(); return; }
|
||||
let checkedInstances = [];
|
||||
if (protocol == 'loki') checkedInstances = [...nitterI2pCustomRedirects];
|
||||
else if (protocol == 'i2p') checkedInstances = [...nitterLokiCustomRedirects];
|
||||
else if (protocol == 'tor') checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects];
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects];
|
||||
}
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'theme');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'infiniteScroll');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'stickyProfile');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'bidiSupport');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'hideTweetStats');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'hideBanner');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'hidePins');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'hideReplies');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'squareAvatars');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'mp4Playback');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'hlsPlayback');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'proxyVideos');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'muteVideos');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'autoplayGifs');
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableTwitter || protocol === undefined) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let checkedInstances = []
|
||||
if (protocol == "loki") checkedInstances = [...nitterI2pCustomRedirects]
|
||||
else if (protocol == "i2p") checkedInstances = [...nitterLokiCustomRedirects]
|
||||
else if (protocol == "tor") checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]
|
||||
}
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "theme")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "infiniteScroll")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "stickyProfile")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "bidiSupport")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "hideTweetStats")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "hideBanner")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "hidePins")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "hideReplies")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "squareAvatars")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "mp4Playback")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "hlsPlayback")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "proxyVideos")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "muteVideos")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "autoplayGifs")
|
||||
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'replaceInstagram');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'replaceReddit');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'replaceTwitter');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'replaceYouTube');
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "replaceInstagram")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "replaceReddit")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "replaceTwitter")
|
||||
utils.getCookiesFromStorage("nitter", checkedInstances, "replaceYouTube")
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get(['cloudflareBlackList', 'authenticateBlackList'], async r => {
|
||||
nitterNormalRedirectsChecks = [...redirects.nitter.normal];
|
||||
for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList]) {
|
||||
let i = nitterNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) nitterNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
disableTwitter: false,
|
||||
twitterRedirects: redirects,
|
||||
twitterRedirectType: "both",
|
||||
return new Promise(resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get(["cloudflareBlackList", "authenticateBlackList"], async r => {
|
||||
nitterNormalRedirectsChecks = [...redirects.nitter.normal]
|
||||
for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList]) {
|
||||
let i = nitterNormalRedirectsChecks.indexOf(instance)
|
||||
if (i > -1) nitterNormalRedirectsChecks.splice(i, 1)
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
disableTwitter: false,
|
||||
twitterRedirects: redirects,
|
||||
twitterRedirectType: "both",
|
||||
|
||||
nitterNormalRedirectsChecks: nitterNormalRedirectsChecks,
|
||||
nitterNormalCustomRedirects: [],
|
||||
nitterNormalRedirectsChecks: nitterNormalRedirectsChecks,
|
||||
nitterNormalCustomRedirects: [],
|
||||
|
||||
nitterTorRedirectsChecks: [...redirects.nitter.tor],
|
||||
nitterTorCustomRedirects: [],
|
||||
nitterTorRedirectsChecks: [...redirects.nitter.tor],
|
||||
nitterTorCustomRedirects: [],
|
||||
|
||||
nitterI2pRedirectsChecks: [...redirects.nitter.i2p],
|
||||
nitterI2pCustomRedirects: [],
|
||||
nitterI2pRedirectsChecks: [...redirects.nitter.i2p],
|
||||
nitterI2pCustomRedirects: [],
|
||||
|
||||
nitterLokiRedirectsChecks: [...redirects.nitter.loki],
|
||||
nitterLokiCustomRedirects: []
|
||||
}, () => resolve());
|
||||
})
|
||||
})
|
||||
})
|
||||
nitterLokiRedirectsChecks: [...redirects.nitter.loki],
|
||||
nitterLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
redirect,
|
||||
switchInstance,
|
||||
reverse,
|
||||
removeXFrameOptions,
|
||||
initNitterCookies,
|
||||
pasteNitterCookies,
|
||||
initDefaults,
|
||||
};
|
||||
setRedirects,
|
||||
redirect,
|
||||
switchInstance,
|
||||
reverse,
|
||||
removeXFrameOptions,
|
||||
initNitterCookies,
|
||||
pasteNitterCookies,
|
||||
initDefaults,
|
||||
}
|
||||
|
|
|
@ -1,193 +1,207 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
import twitterHelper from "./twitter.js";
|
||||
import youtubeHelper from "./youtube/youtube.js";
|
||||
import instagramHelper from "./instagram.js";
|
||||
import mediumHelper from "./medium.js";
|
||||
import redditHelper from "./reddit.js";
|
||||
import searchHelper from "./search.js";
|
||||
import translateHelper from "./translate/translate.js";
|
||||
import wikipediaHelper from "./wikipedia.js";
|
||||
import peertubeHelper from "./peertube.js";
|
||||
import lbryHelper from "./lbry.js";
|
||||
import sendTargetsHelper from "./sendTargets.js";
|
||||
import tiktokHelper from "./tiktok.js";
|
||||
window.browser = window.browser || window.chrome
|
||||
import twitterHelper from "./twitter.js"
|
||||
import youtubeHelper from "./youtube/youtube.js"
|
||||
import instagramHelper from "./instagram.js"
|
||||
import mediumHelper from "./medium.js"
|
||||
import redditHelper from "./reddit.js"
|
||||
import searchHelper from "./search.js"
|
||||
import translateHelper from "./translate/translate.js"
|
||||
import wikipediaHelper from "./wikipedia.js"
|
||||
import peertubeHelper from "./peertube.js"
|
||||
import lbryHelper from "./lbry.js"
|
||||
import sendTargetsHelper from "./sendTargets.js"
|
||||
import tiktokHelper from "./tiktok.js"
|
||||
import quoraHelper from "./quora.js"
|
||||
import libremdbHelper from "./imdb.js";
|
||||
import imgurHelper from "./imgur.js";
|
||||
import reutersHelper from './reuters.js';
|
||||
import localise from './localise.js'
|
||||
import libremdbHelper from "./imdb.js"
|
||||
import imgurHelper from "./imgur.js"
|
||||
import reutersHelper from "./reuters.js"
|
||||
import youtubeMusicHelper from "./youtubeMusic.js"
|
||||
import mapsHelper from "./maps.js"
|
||||
import localise from "./localise.js"
|
||||
|
||||
function getRandomInstance(instances) {
|
||||
return instances[~~(instances.length * Math.random())];
|
||||
return instances[~~(instances.length * Math.random())]
|
||||
}
|
||||
|
||||
let cloudflareBlackList = [];
|
||||
let authenticateBlackList = [];
|
||||
let cloudflareBlackList = []
|
||||
let authenticateBlackList = []
|
||||
async function initcloudflareBlackList() {
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/blacklist.json').then(response => response.text()).then(data => {
|
||||
cloudflareBlackList = JSON.parse(data).cloudflare;
|
||||
authenticateBlackList = JSON.parse(data).authenticate;
|
||||
resolve();
|
||||
})
|
||||
});
|
||||
return new Promise(resolve => {
|
||||
fetch("/instances/blacklist.json")
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
cloudflareBlackList = JSON.parse(data).cloudflare
|
||||
authenticateBlackList = JSON.parse(data).authenticate
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function updateInstances() {
|
||||
return new Promise(async resolve => {
|
||||
let http = new XMLHttpRequest();
|
||||
http.open('GET', 'https://raw.githubusercontent.com/libredirect/libredirect/master/src/instances/data.json', false);
|
||||
http.send(null);
|
||||
if (http.status === 200) {
|
||||
await initcloudflareBlackList();
|
||||
const instances = JSON.parse(http.responseText);
|
||||
return new Promise(async resolve => {
|
||||
let http = new XMLHttpRequest()
|
||||
http.open("GET", "https://raw.githubusercontent.com/libredirect/libredirect/master/src/instances/data.json", false)
|
||||
http.send(null)
|
||||
if (http.status === 200) {
|
||||
await initcloudflareBlackList()
|
||||
const instances = JSON.parse(http.responseText)
|
||||
|
||||
youtubeHelper.setRedirects({ 'invidious': instances.invidious, 'piped': instances.piped, 'pipedMaterial': instances.pipedMaterial })
|
||||
twitterHelper.setRedirects(instances.nitter);
|
||||
instagramHelper.setRedirects(instances.bibliogram);
|
||||
redditHelper.setRedirects({ 'libreddit': instances.libreddit, 'teddit': instances.teddit });
|
||||
translateHelper.setRedirects({ "simplyTranslate": instances.simplyTranslate, "lingva": instances.lingva });
|
||||
searchHelper.setRedirects({ 'searx': instances.searx, 'searxng': instances.searxng, 'whoogle': instances.whoogle, 'librex': instances.librex });
|
||||
wikipediaHelper.setRedirects(instances.wikiless);
|
||||
mediumHelper.setRedirects(instances.scribe);
|
||||
quoraHelper.setRedirects(instances.quetre);
|
||||
libremdbHelper.setRedirects(instances.libremdb);
|
||||
sendTargetsHelper.setRedirects(instances.send);
|
||||
tiktokHelper.setRedirects(instances.proxiTok);
|
||||
lbryHelper.setRedirects(instances.librarian);
|
||||
reutersHelper.setRedirects(instances.neuters);
|
||||
youtubeHelper.setRedirects({
|
||||
invidious: instances.invidious,
|
||||
piped: instances.piped,
|
||||
pipedMaterial: instances.pipedMaterial,
|
||||
})
|
||||
twitterHelper.setRedirects(instances.nitter)
|
||||
instagramHelper.setRedirects(instances.bibliogram)
|
||||
redditHelper.setRedirects({
|
||||
libreddit: instances.libreddit,
|
||||
teddit: instances.teddit,
|
||||
})
|
||||
translateHelper.setRedirects({
|
||||
simplyTranslate: instances.simplyTranslate,
|
||||
lingva: instances.lingva,
|
||||
})
|
||||
searchHelper.setRedirects({
|
||||
searx: instances.searx,
|
||||
searxng: instances.searxng,
|
||||
whoogle: instances.whoogle,
|
||||
librex: instances.librex,
|
||||
})
|
||||
wikipediaHelper.setRedirects(instances.wikiless)
|
||||
mediumHelper.setRedirects(instances.scribe)
|
||||
quoraHelper.setRedirects(instances.quetre)
|
||||
libremdbHelper.setRedirects(instances.libremdb)
|
||||
sendTargetsHelper.setRedirects(instances.send)
|
||||
tiktokHelper.setRedirects(instances.proxiTok)
|
||||
lbryHelper.setRedirects(instances.librarian)
|
||||
reutersHelper.setRedirects(instances.neuters)
|
||||
youtubeMusicHelper.setRedirects({
|
||||
beatbump: instances.beatbump,
|
||||
hyperpipe: instances.hyperpipe,
|
||||
})
|
||||
mapsHelper.setRedirects(instances.facil)
|
||||
peertubeHelper.setRedirects(instances.simpleertube)
|
||||
|
||||
console.info("Successfully updated Instances");
|
||||
resolve(true); return;
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
console.info("Successfully updated Instances")
|
||||
resolve(true)
|
||||
return
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
function protocolHost(url) {
|
||||
if (url.username && url.password) return `${url.protocol}//${url.username}:${url.password}@${url.host}`;
|
||||
return `${url.protocol}//${url.host}`;
|
||||
if (url.username && url.password) return `${url.protocol}//${url.username}:${url.password}@${url.host}`
|
||||
return `${url.protocol}//${url.host}`
|
||||
}
|
||||
|
||||
async function processDefaultCustomInstances(target, name, protocol, document) {
|
||||
function camelCase(str) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1)
|
||||
}
|
||||
let latencyKey = `${name}Latency`
|
||||
let instancesLatency
|
||||
let nameProtocolElement = document.getElementById(name).getElementsByClassName(protocol)[0]
|
||||
|
||||
function camelCase(str) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}
|
||||
let latencyKey = `${name}Latency`;
|
||||
let instancesLatency;
|
||||
let nameProtocolElement = document.getElementById(name).getElementsByClassName(protocol)[0];
|
||||
let nameCustomInstances = []
|
||||
let nameCheckListElement = nameProtocolElement.getElementsByClassName("checklist")[0]
|
||||
|
||||
let nameCustomInstances = [];
|
||||
let nameCheckListElement = nameProtocolElement.getElementsByClassName('checklist')[0];
|
||||
await initcloudflareBlackList()
|
||||
|
||||
await initcloudflareBlackList();
|
||||
let nameDefaultRedirects
|
||||
|
||||
let nameDefaultRedirects;
|
||||
let redirectsChecks = `${name}${camelCase(protocol)}RedirectsChecks`
|
||||
let customRedirects = `${name}${camelCase(protocol)}CustomRedirects`
|
||||
let redirectsKey = `${target}Redirects`
|
||||
|
||||
let redirectsChecks = `${name}${camelCase(protocol)}RedirectsChecks`;
|
||||
let customRedirects = `${name}${camelCase(protocol)}CustomRedirects`;
|
||||
let redirectsKey = `${target}Redirects`;
|
||||
let redirects
|
||||
|
||||
let redirects;
|
||||
async function getFromStorage() {
|
||||
return new Promise(async resolve =>
|
||||
browser.storage.local.get([redirectsChecks, customRedirects, redirectsKey, latencyKey], r => {
|
||||
nameDefaultRedirects = r[redirectsChecks]
|
||||
nameCustomInstances = r[customRedirects]
|
||||
instancesLatency = r[latencyKey] ?? []
|
||||
redirects = r[redirectsKey]
|
||||
resolve()
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
async function getFromStorage() {
|
||||
return new Promise(async resolve =>
|
||||
browser.storage.local.get(
|
||||
[
|
||||
redirectsChecks,
|
||||
customRedirects,
|
||||
redirectsKey,
|
||||
latencyKey
|
||||
],
|
||||
r => {
|
||||
nameDefaultRedirects = r[redirectsChecks];
|
||||
nameCustomInstances = r[customRedirects];
|
||||
instancesLatency = r[latencyKey] ?? [];
|
||||
redirects = r[redirectsKey];
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
await getFromStorage();
|
||||
if (nameCustomInstances === undefined) console.log(customRedirects);
|
||||
await getFromStorage()
|
||||
if (nameCustomInstances === undefined) console.log(customRedirects)
|
||||
|
||||
function calcNameCheckBoxes() {
|
||||
let isTrue = true;
|
||||
for (const item of redirects[name][protocol]) {
|
||||
if (!nameDefaultRedirects.includes(item)) {
|
||||
isTrue = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (const element of nameCheckListElement.getElementsByTagName('input')) {
|
||||
element.checked = nameDefaultRedirects.includes(element.className)
|
||||
}
|
||||
if (nameDefaultRedirects.length == 0) isTrue = false;
|
||||
nameProtocolElement.getElementsByClassName('toggle-all')[0].checked = isTrue;
|
||||
}
|
||||
nameCheckListElement.innerHTML =
|
||||
[
|
||||
`<div>
|
||||
function calcNameCheckBoxes() {
|
||||
let isTrue = true
|
||||
for (const item of redirects[name][protocol]) {
|
||||
if (nameDefaultRedirects === undefined) console.log(name + protocol + " is undefined")
|
||||
if (!nameDefaultRedirects.includes(item)) {
|
||||
isTrue = false
|
||||
break
|
||||
}
|
||||
}
|
||||
for (const element of nameCheckListElement.getElementsByTagName("input")) {
|
||||
element.checked = nameDefaultRedirects.includes(element.className)
|
||||
}
|
||||
if (nameDefaultRedirects.length == 0) isTrue = false
|
||||
nameProtocolElement.getElementsByClassName("toggle-all")[0].checked = isTrue
|
||||
}
|
||||
nameCheckListElement.innerHTML = [
|
||||
`<div>
|
||||
<x data-localise="__MSG_toggleAll__">Toggle All</x>
|
||||
<input type="checkbox" class="toggle-all"/>
|
||||
</div>`,
|
||||
...redirects[name][protocol].map(
|
||||
x => {
|
||||
const cloudflare = cloudflareBlackList.includes(x) ? ' <span style="color:red;">cloudflare</span>' : '';
|
||||
const authenticate = authenticateBlackList.includes(x) ? ' <span style="color:orange;">authenticate</span>' : '';
|
||||
...redirects[name][protocol].map(x => {
|
||||
const cloudflare = cloudflareBlackList.includes(x) ? ' <span style="color:red;">cloudflare</span>' : ""
|
||||
const authenticate = authenticateBlackList.includes(x) ? ' <span style="color:orange;">authenticate</span>' : ""
|
||||
|
||||
let ms = instancesLatency[x];
|
||||
let latencyColor = (ms <= 1000 ? "green" : ms <= 2000 ? "orange" : "red");
|
||||
let latencyLimit;
|
||||
if (ms == 5000) latencyLimit = '5000ms+';
|
||||
else if (ms > 5000) latencyLimit = `ERROR: ${ms - 5000}`;
|
||||
else latencyLimit = ms + 'ms';
|
||||
let ms = instancesLatency[x]
|
||||
let latencyColor = ms <= 1000 ? "green" : ms <= 2000 ? "orange" : "red"
|
||||
let latencyLimit
|
||||
if (ms == 5000) latencyLimit = "5000ms+"
|
||||
else if (ms > 5000) latencyLimit = `ERROR: ${ms - 5000}`
|
||||
else latencyLimit = ms + "ms"
|
||||
|
||||
const latency = x in instancesLatency ? '<span style="color:' + latencyColor + ';">' + latencyLimit + '</span>' : '';
|
||||
const latency = x in instancesLatency ? '<span style="color:' + latencyColor + ';">' + latencyLimit + "</span>" : ""
|
||||
|
||||
let warnings = [cloudflare, authenticate, latency].join(' ');
|
||||
return `<div>
|
||||
let warnings = [cloudflare, authenticate, latency].join(" ")
|
||||
return `<div>
|
||||
<x><a href="${x}" target="_blank">${x}</a>${warnings}</x>
|
||||
<input type="checkbox" class="${x}"/>
|
||||
</div>`;
|
||||
}
|
||||
),
|
||||
].join('\n<hr>\n');
|
||||
</div>`
|
||||
}),
|
||||
].join("\n<hr>\n")
|
||||
|
||||
localise.localisePage();
|
||||
localise.localisePage()
|
||||
|
||||
calcNameCheckBoxes();
|
||||
nameProtocolElement.getElementsByClassName('toggle-all')[0].addEventListener("change", async event => {
|
||||
if (event.target.checked)
|
||||
nameDefaultRedirects = [...redirects[name][protocol]];
|
||||
else
|
||||
nameDefaultRedirects = [];
|
||||
calcNameCheckBoxes()
|
||||
nameProtocolElement.getElementsByClassName("toggle-all")[0].addEventListener("change", async event => {
|
||||
if (event.target.checked) nameDefaultRedirects = [...redirects[name][protocol]]
|
||||
else nameDefaultRedirects = []
|
||||
|
||||
browser.storage.local.set({ [redirectsChecks]: nameDefaultRedirects });
|
||||
calcNameCheckBoxes();
|
||||
});
|
||||
browser.storage.local.set({ [redirectsChecks]: nameDefaultRedirects })
|
||||
calcNameCheckBoxes()
|
||||
})
|
||||
|
||||
for (let element of nameCheckListElement.getElementsByTagName('input')) {
|
||||
if (element.className != 'toggle-all')
|
||||
nameProtocolElement.getElementsByClassName(element.className)[0].addEventListener("change", async event => {
|
||||
if (event.target.checked)
|
||||
nameDefaultRedirects.push(element.className)
|
||||
else {
|
||||
let index = nameDefaultRedirects.indexOf(element.className);
|
||||
if (index > -1) nameDefaultRedirects.splice(index, 1);
|
||||
}
|
||||
browser.storage.local.set({ [redirectsChecks]: nameDefaultRedirects });
|
||||
calcNameCheckBoxes();
|
||||
});
|
||||
}
|
||||
for (let element of nameCheckListElement.getElementsByTagName("input")) {
|
||||
if (element.className != "toggle-all")
|
||||
nameProtocolElement.getElementsByClassName(element.className)[0].addEventListener("change", async event => {
|
||||
if (event.target.checked) nameDefaultRedirects.push(element.className)
|
||||
else {
|
||||
let index = nameDefaultRedirects.indexOf(element.className)
|
||||
if (index > -1) nameDefaultRedirects.splice(index, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
[redirectsChecks]: nameDefaultRedirects,
|
||||
})
|
||||
calcNameCheckBoxes()
|
||||
})
|
||||
}
|
||||
|
||||
function calcNameCustomInstances() {
|
||||
nameProtocolElement.getElementsByClassName('custom-checklist')[0].innerHTML =
|
||||
nameCustomInstances.map(
|
||||
x => `<div>
|
||||
function calcNameCustomInstances() {
|
||||
nameProtocolElement.getElementsByClassName("custom-checklist")[0].innerHTML = nameCustomInstances
|
||||
.map(
|
||||
x => `<div>
|
||||
${x}
|
||||
<button class="add clear-${x}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor">
|
||||
|
@ -196,286 +210,294 @@ async function processDefaultCustomInstances(target, name, protocol, document) {
|
|||
</button>
|
||||
</div>
|
||||
<hr>`
|
||||
).join('\n');
|
||||
)
|
||||
.join("\n")
|
||||
|
||||
for (const item of nameCustomInstances) {
|
||||
nameProtocolElement.getElementsByClassName(`clear-${item}`)[0].addEventListener("click", async () => {
|
||||
let index = nameCustomInstances.indexOf(item);
|
||||
if (index > -1) nameCustomInstances.splice(index, 1);
|
||||
browser.storage.local.set({ [customRedirects]: nameCustomInstances });
|
||||
calcNameCustomInstances();
|
||||
});
|
||||
}
|
||||
}
|
||||
calcNameCustomInstances();
|
||||
nameProtocolElement.getElementsByClassName('custom-instance-form')[0].addEventListener("submit", async event => {
|
||||
event.preventDefault();
|
||||
let nameCustomInstanceInput = nameProtocolElement.getElementsByClassName('custom-instance')[0];
|
||||
let url = new URL(nameCustomInstanceInput.value);
|
||||
let protocolHostVar = protocolHost(url);
|
||||
if (nameCustomInstanceInput.validity.valid && !redirects[name][protocol].includes(protocolHostVar)) {
|
||||
if (!nameCustomInstances.includes(protocolHostVar)) {
|
||||
nameCustomInstances.push(protocolHostVar)
|
||||
browser.storage.local.set({ [customRedirects]: nameCustomInstances });
|
||||
nameCustomInstanceInput.value = '';
|
||||
}
|
||||
calcNameCustomInstances();
|
||||
}
|
||||
})
|
||||
for (const item of nameCustomInstances) {
|
||||
nameProtocolElement.getElementsByClassName(`clear-${item}`)[0].addEventListener("click", async () => {
|
||||
let index = nameCustomInstances.indexOf(item)
|
||||
if (index > -1) nameCustomInstances.splice(index, 1)
|
||||
browser.storage.local.set({ [customRedirects]: nameCustomInstances })
|
||||
calcNameCustomInstances()
|
||||
})
|
||||
}
|
||||
}
|
||||
calcNameCustomInstances()
|
||||
nameProtocolElement.getElementsByClassName("custom-instance-form")[0].addEventListener("submit", async event => {
|
||||
event.preventDefault()
|
||||
let nameCustomInstanceInput = nameProtocolElement.getElementsByClassName("custom-instance")[0]
|
||||
let url = new URL(nameCustomInstanceInput.value)
|
||||
let protocolHostVar = protocolHost(url)
|
||||
if (nameCustomInstanceInput.validity.valid && !redirects[name][protocol].includes(protocolHostVar)) {
|
||||
if (!nameCustomInstances.includes(protocolHostVar)) {
|
||||
nameCustomInstances.push(protocolHostVar)
|
||||
browser.storage.local.set({ [customRedirects]: nameCustomInstances })
|
||||
nameCustomInstanceInput.value = ""
|
||||
}
|
||||
calcNameCustomInstances()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function ping(href) {
|
||||
return new Promise(async resolve => {
|
||||
let http = new XMLHttpRequest();
|
||||
http.open("GET", `${href}?_=${new Date().getTime()}`, /*async*/true);
|
||||
http.timeout = 5000;
|
||||
let started = new Date().getTime();
|
||||
http.onreadystatechange = () => {
|
||||
if (http.readyState == 2) {
|
||||
if (http.status == 200) {
|
||||
let ended = new Date().getTime();
|
||||
http.abort();
|
||||
resolve(ended - started);
|
||||
}
|
||||
else
|
||||
resolve(5000 + http.status)
|
||||
}
|
||||
};
|
||||
http.ontimeout = () => resolve(5000)
|
||||
http.onerror = () => resolve()
|
||||
try {
|
||||
http.send(null);
|
||||
} catch (exception) {
|
||||
resolve()
|
||||
}
|
||||
});
|
||||
return new Promise(async resolve => {
|
||||
let http = new XMLHttpRequest()
|
||||
http.open("GET", `${href}?_=${new Date().getTime()}`, /*async*/ true)
|
||||
http.timeout = 5000
|
||||
let started = new Date().getTime()
|
||||
http.onreadystatechange = () => {
|
||||
if (http.readyState == 2) {
|
||||
if (http.status == 200) {
|
||||
let ended = new Date().getTime()
|
||||
http.abort()
|
||||
resolve(ended - started)
|
||||
} else resolve(5000 + http.status)
|
||||
}
|
||||
}
|
||||
http.ontimeout = () => resolve(5000)
|
||||
http.onerror = () => resolve()
|
||||
try {
|
||||
http.send(null)
|
||||
} catch (exception) {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function testLatency(element, instances) {
|
||||
return new Promise(async resolve => {
|
||||
let myList = {};
|
||||
for (const href of instances) await ping(href).then(time => {
|
||||
if (time) {
|
||||
myList[href] = time;
|
||||
let color;
|
||||
if (time <= 1000) color = "green"
|
||||
else if (time <= 2000) color = "orange"
|
||||
else color = "red";
|
||||
return new Promise(async resolve => {
|
||||
let myList = {}
|
||||
for (const href of instances)
|
||||
await ping(href).then(time => {
|
||||
if (time) {
|
||||
myList[href] = time
|
||||
let color
|
||||
if (time <= 1000) color = "green"
|
||||
else if (time <= 2000) color = "orange"
|
||||
else color = "red"
|
||||
|
||||
let text;
|
||||
if (time == 5000) text = '5000ms+'
|
||||
else if (time > 5000) text = `ERROR: ${time - 5000}`;
|
||||
else text = `${time}ms`;
|
||||
element.innerHTML = `${href}: <span style="color:${color};">${text}</span>`;
|
||||
}
|
||||
})
|
||||
resolve(myList);
|
||||
})
|
||||
let text
|
||||
if (time == 5000) text = "5000ms+"
|
||||
else if (time > 5000) text = `ERROR: ${time - 5000}`
|
||||
else text = `${time}ms`
|
||||
element.innerHTML = `${href}: <span style="color:${color};">${text}</span>`
|
||||
}
|
||||
})
|
||||
resolve(myList)
|
||||
})
|
||||
}
|
||||
|
||||
function copyCookie(frontend, targetUrl, urls, name) {
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get('firstPartyIsolate', r => {
|
||||
let query;
|
||||
if (!r.firstPartyIsolate) query = { url: protocolHost(targetUrl), name: name }
|
||||
else query = { url: protocolHost(targetUrl), name: name, firstPartyDomain: null }
|
||||
browser.cookies.getAll(
|
||||
query,
|
||||
async cookies => {
|
||||
for (const cookie of cookies)
|
||||
if (cookie.name == name) {
|
||||
for (const url of urls) {
|
||||
const setQuery =
|
||||
r.firstPartyIsolate ?
|
||||
{
|
||||
url: url, name: name, value: cookie.value, secure: true,
|
||||
firstPartyDomain: new URL(url).hostname,
|
||||
}
|
||||
:
|
||||
{
|
||||
url: url, name: name, value: cookie.value, secure: true,
|
||||
expirationDate: cookie.expirationDate,
|
||||
};
|
||||
browser.cookies.set(setQuery, () =>
|
||||
browser.storage.local.set({ [`${frontend}_${name}`]: cookie }, () => resolve())
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
})
|
||||
})
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.get("firstPartyIsolate", r => {
|
||||
let query
|
||||
if (!r.firstPartyIsolate) query = { url: protocolHost(targetUrl), name: name }
|
||||
else
|
||||
query = {
|
||||
url: protocolHost(targetUrl),
|
||||
name: name,
|
||||
firstPartyDomain: null,
|
||||
}
|
||||
browser.cookies.getAll(query, async cookies => {
|
||||
for (const cookie of cookies)
|
||||
if (cookie.name == name) {
|
||||
for (const url of urls) {
|
||||
const setQuery = r.firstPartyIsolate
|
||||
? {
|
||||
url: url,
|
||||
name: name,
|
||||
value: cookie.value,
|
||||
secure: true,
|
||||
firstPartyDomain: new URL(url).hostname,
|
||||
}
|
||||
: {
|
||||
url: url,
|
||||
name: name,
|
||||
value: cookie.value,
|
||||
secure: true,
|
||||
expirationDate: cookie.expirationDate,
|
||||
}
|
||||
browser.cookies.set(setQuery, () => browser.storage.local.set({ [`${frontend}_${name}`]: cookie }, () => resolve()))
|
||||
}
|
||||
break
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function getCookiesFromStorage(frontend, urls, name) {
|
||||
let key = `${frontend}_${name}`;
|
||||
browser.storage.local.get([key, 'firstPartyIsolate'], r => {
|
||||
const cookie = r[key];
|
||||
if (cookie === undefined) return;
|
||||
for (const url of urls) {
|
||||
let query =
|
||||
r.firstPartyIsolate ?
|
||||
{
|
||||
url: url, name: cookie.name, value: cookie.value, secure: true,
|
||||
expirationDate: null,
|
||||
firstPartyDomain: new URL(url).hostname,
|
||||
}
|
||||
:
|
||||
{
|
||||
url: url, name: cookie.name, value: cookie.value, secure: true,
|
||||
expirationDate: cookie.expirationDate,
|
||||
};
|
||||
browser.cookies.set(query)
|
||||
}
|
||||
})
|
||||
let key = `${frontend}_${name}`
|
||||
browser.storage.local.get([key, "firstPartyIsolate"], r => {
|
||||
const cookie = r[key]
|
||||
if (cookie === undefined) return
|
||||
for (const url of urls) {
|
||||
let query = r.firstPartyIsolate
|
||||
? {
|
||||
url: url,
|
||||
name: cookie.name,
|
||||
value: cookie.value,
|
||||
secure: true,
|
||||
expirationDate: null,
|
||||
firstPartyDomain: new URL(url).hostname,
|
||||
}
|
||||
: {
|
||||
url: url,
|
||||
name: cookie.name,
|
||||
value: cookie.value,
|
||||
secure: true,
|
||||
expirationDate: cookie.expirationDate,
|
||||
}
|
||||
browser.cookies.set(query)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function copyRaw(test, copyRawElement) {
|
||||
return new Promise(resolve => {
|
||||
browser.tabs.query(
|
||||
{ active: true, currentWindow: true }, async tabs => {
|
||||
let currTab = tabs[0];
|
||||
if (currTab) {
|
||||
let url;
|
||||
try { url = new URL(currTab.url); }
|
||||
catch { resolve(); return; }
|
||||
return new Promise(resolve => {
|
||||
browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
|
||||
let currTab = tabs[0]
|
||||
if (currTab) {
|
||||
let url
|
||||
try {
|
||||
url = new URL(currTab.url)
|
||||
} catch {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
let newUrl = await youtubeHelper.reverse(url);
|
||||
if (!newUrl) newUrl = await twitterHelper.reverse(url);
|
||||
if (!newUrl) newUrl = await instagramHelper.reverse(url);
|
||||
if (!newUrl) newUrl = await tiktokHelper.reverse(url);
|
||||
if (!newUrl) newUrl = await quoraHelper.reverse(url);
|
||||
if (!newUrl) newUrl = await libremdbHelper.reverse(url);
|
||||
if (!newUrl) newUrl = await imgurHelper.reverse(url);
|
||||
let newUrl = await youtubeHelper.reverse(url)
|
||||
if (!newUrl) newUrl = await twitterHelper.reverse(url)
|
||||
if (!newUrl) newUrl = await instagramHelper.reverse(url)
|
||||
if (!newUrl) newUrl = await tiktokHelper.reverse(url)
|
||||
if (!newUrl) newUrl = await quoraHelper.reverse(url)
|
||||
if (!newUrl) newUrl = await libremdbHelper.reverse(url)
|
||||
if (!newUrl) newUrl = await imgurHelper.reverse(url)
|
||||
|
||||
if (newUrl) {
|
||||
resolve(newUrl);
|
||||
if (test) return;
|
||||
navigator.clipboard.writeText(newUrl);
|
||||
if (copyRawElement) {
|
||||
const textElement = copyRawElement.getElementsByTagName('h4')[0]
|
||||
const oldHtml = textElement.innerHTML;
|
||||
textElement.innerHTML = browser.i18n.getMessage('copied');
|
||||
setTimeout(() => textElement.innerHTML = oldHtml, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
if (newUrl) {
|
||||
resolve(newUrl)
|
||||
if (test) return
|
||||
navigator.clipboard.writeText(newUrl)
|
||||
if (copyRawElement) {
|
||||
const textElement = copyRawElement.getElementsByTagName("h4")[0]
|
||||
const oldHtml = textElement.innerHTML
|
||||
textElement.innerHTML = browser.i18n.getMessage("copied")
|
||||
setTimeout(() => (textElement.innerHTML = oldHtml), 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function unify(test) {
|
||||
return new Promise(resolve => {
|
||||
browser.tabs.query(
|
||||
{ active: true, currentWindow: true },
|
||||
async tabs => {
|
||||
let currTab = tabs[0]
|
||||
if (currTab) {
|
||||
let url;
|
||||
try { url = new URL(currTab.url); }
|
||||
catch { resolve(); return; }
|
||||
if (currTab.incognito) { resolve(); return; }
|
||||
return new Promise(resolve => {
|
||||
browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
|
||||
let currTab = tabs[0]
|
||||
if (currTab) {
|
||||
let url
|
||||
try {
|
||||
url = new URL(currTab.url)
|
||||
} catch {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
if (currTab.incognito) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
let result = await youtubeHelper.copyPasteInvidiousCookies(test, url);
|
||||
if (!result) result = await youtubeHelper.copyPastePipedLocalStorage(test, url, currTab.id);
|
||||
if (!result) result = await youtubeHelper.copyPastePipedMaterialLocalStorage(test, url, currTab.id);
|
||||
let result = await youtubeHelper.copyPasteInvidiousCookies(test, url)
|
||||
if (!result) result = await youtubeHelper.copyPastePipedLocalStorage(test, url, currTab.id)
|
||||
if (!result) result = await youtubeHelper.copyPastePipedMaterialLocalStorage(test, url, currTab.id)
|
||||
|
||||
if (!result) result = await twitterHelper.initNitterCookies(test, url);
|
||||
if (!result) result = await twitterHelper.initNitterCookies(test, url)
|
||||
if (!result) result = await redditHelper.initLibredditCookies(test, url)
|
||||
if (!result) result = await redditHelper.initTedditCookies(test, url)
|
||||
if (!result) result = await searchHelper.initSearxCookies(test, url)
|
||||
if (!result) result = await searchHelper.initSearxngCookies(test, url)
|
||||
if (!result) result = await searchHelper.initLibrexCookies(test, url)
|
||||
if (!result) result = await tiktokHelper.initProxiTokCookies(test, url)
|
||||
if (!result) result = await wikipediaHelper.initWikilessCookies(test, url)
|
||||
if (!result) result = await translateHelper.copyPasteSimplyTranslateCookies(test, url)
|
||||
if (!result) result = await translateHelper.copyPasteLingvaLocalStorage(test, url)
|
||||
|
||||
if (!result) result = await redditHelper.initLibredditCookies(test, url);
|
||||
if (!result) result = await redditHelper.initTedditCookies(test, url);
|
||||
|
||||
if (!result) result = await searchHelper.initSearxCookies(test, url);
|
||||
if (!result) result = await searchHelper.initSearxngCookies(test, url);
|
||||
if (!result) result = await searchHelper.initLibrexCookies(test, url);
|
||||
|
||||
if (!result) result = await tiktokHelper.initProxiTokCookies(test, url);
|
||||
|
||||
if (!result) result = await wikipediaHelper.initWikilessCookies(test, url);
|
||||
|
||||
if (!result) result = await translateHelper.copyPasteSimplyTranslateCookies(test, url);
|
||||
if (!result) result = await translateHelper.copyPasteLingvaLocalStorage(test, url);
|
||||
|
||||
resolve(result);
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
resolve(result)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function switchInstance(test) {
|
||||
return new Promise(resolve => {
|
||||
browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
|
||||
let currTab = tabs[0];
|
||||
if (currTab) {
|
||||
let url;
|
||||
try { url = new URL(currTab.url); }
|
||||
catch { resolve(); return };
|
||||
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 sendTargetsHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await peertubeHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await lbryHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await imgurHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await wikipediaHelper.switchInstance(url);
|
||||
return new Promise(resolve => {
|
||||
browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
|
||||
let currTab = tabs[0]
|
||||
if (currTab) {
|
||||
let url
|
||||
try {
|
||||
url = new URL(currTab.url)
|
||||
} catch {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
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 sendTargetsHelper.switchInstance(url, true)
|
||||
if (!newUrl) newUrl = await peertubeHelper.switchInstance(url, true)
|
||||
if (!newUrl) newUrl = await lbryHelper.switchInstance(url, true)
|
||||
if (!newUrl) newUrl = await imgurHelper.switchInstance(url, true)
|
||||
if (!newUrl) newUrl = await wikipediaHelper.switchInstance(url, true)
|
||||
if (!newUrl) newUrl = await youtubeMusicHelper.switchInstance(url, true)
|
||||
|
||||
if (newUrl) {
|
||||
if (!test)
|
||||
browser.tabs.update({ url: newUrl });
|
||||
resolve(true)
|
||||
} else resolve()
|
||||
}
|
||||
})
|
||||
})
|
||||
if (newUrl) {
|
||||
if (!test) browser.tabs.update({ url: newUrl })
|
||||
resolve(true)
|
||||
} else resolve()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function latency(name, frontend, document, location) {
|
||||
let latencyElement = document.getElementById(`latency-${frontend}`);
|
||||
let latencyLabel = document.getElementById(`latency-${frontend}-label`);
|
||||
latencyElement.addEventListener("click",
|
||||
async () => {
|
||||
let reloadWindow = () => location.reload();
|
||||
latencyElement.addEventListener("click", reloadWindow);
|
||||
let key = `${name}Redirects`
|
||||
browser.storage.local.get(
|
||||
key,
|
||||
r => {
|
||||
let redirects = r[key];
|
||||
const oldHtml = latencyLabel.innerHTML;
|
||||
latencyLabel.innerHTML = '...';
|
||||
testLatency(latencyLabel, redirects[frontend].normal).then(r => {
|
||||
browser.storage.local.set({ [`${frontend}Latency`]: r });
|
||||
latencyLabel.innerHTML = oldHtml;
|
||||
processDefaultCustomInstances(name, frontend, 'normal', document);
|
||||
latencyElement.removeEventListener("click", reloadWindow)
|
||||
});
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
let latencyElement = document.getElementById(`latency-${frontend}`)
|
||||
let latencyLabel = document.getElementById(`latency-${frontend}-label`)
|
||||
latencyElement.addEventListener("click", async () => {
|
||||
let reloadWindow = () => location.reload()
|
||||
latencyElement.addEventListener("click", reloadWindow)
|
||||
let key = `${name}Redirects`
|
||||
browser.storage.local.get(key, r => {
|
||||
let redirects = r[key]
|
||||
const oldHtml = latencyLabel.innerHTML
|
||||
latencyLabel.innerHTML = "..."
|
||||
testLatency(latencyLabel, redirects[frontend].normal).then(r => {
|
||||
browser.storage.local.set({ [`${frontend}Latency`]: r })
|
||||
latencyLabel.innerHTML = oldHtml
|
||||
processDefaultCustomInstances(name, frontend, "normal", document)
|
||||
latencyElement.removeEventListener("click", reloadWindow)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
getRandomInstance,
|
||||
updateInstances,
|
||||
protocolHost,
|
||||
processDefaultCustomInstances,
|
||||
latency,
|
||||
copyCookie,
|
||||
getCookiesFromStorage,
|
||||
switchInstance,
|
||||
copyRaw,
|
||||
unify,
|
||||
getRandomInstance,
|
||||
updateInstances,
|
||||
protocolHost,
|
||||
processDefaultCustomInstances,
|
||||
latency,
|
||||
copyCookie,
|
||||
getCookiesFromStorage,
|
||||
switchInstance,
|
||||
copyRaw,
|
||||
unify,
|
||||
}
|
||||
|
|
|
@ -1,248 +1,262 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
import utils from './utils.js'
|
||||
import utils from "./utils.js"
|
||||
|
||||
const targets = /^https?:\/{2}(([a-z]{1,}\.){0,})wikipedia\.org/
|
||||
|
||||
const frontends = new Array("wikiless")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
||||
let redirects = {};
|
||||
let redirects = {}
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get('cloudflareBlackList', r => {
|
||||
redirects.wikiless = val;
|
||||
wikilessNormalRedirectsChecks = [...redirects.wikiless.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = wikilessNormalRedirectsChecks.indexOf(instance);
|
||||
if (a > -1) wikilessNormalRedirectsChecks.splice(a, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
wikipediaRedirects: redirects,
|
||||
wikilessNormalRedirectsChecks
|
||||
})
|
||||
})
|
||||
browser.storage.local.get("cloudflareBlackList", r => {
|
||||
redirects.wikiless = val
|
||||
wikilessNormalRedirectsChecks = [...redirects.wikiless.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = wikilessNormalRedirectsChecks.indexOf(instance)
|
||||
if (a > -1) wikilessNormalRedirectsChecks.splice(a, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
wikipediaRedirects: redirects,
|
||||
wikilessNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let
|
||||
disableWikipedia,
|
||||
wikipediaRedirects,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
wikilessNormalRedirectsChecks,
|
||||
wikilessTorRedirectsChecks,
|
||||
wikilessI2pRedirectsChecks,
|
||||
wikilessNormalCustomRedirects,
|
||||
wikilessTorCustomRedirects,
|
||||
wikilessI2pCustomRedirects,
|
||||
wikilessLokiCustomRedirects;
|
||||
let disableWikipedia,
|
||||
wikipediaRedirects,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
wikilessNormalRedirectsChecks,
|
||||
wikilessTorRedirectsChecks,
|
||||
wikilessI2pRedirectsChecks,
|
||||
wikilessNormalCustomRedirects,
|
||||
wikilessTorCustomRedirects,
|
||||
wikilessI2pCustomRedirects,
|
||||
wikilessLokiCustomRedirects
|
||||
|
||||
function init() {
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableWikipedia",
|
||||
"wikipediaRedirects",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"wikilessNormalRedirectsChecks",
|
||||
"wikilessTorRedirectsChecks",
|
||||
"wikilessI2pRedirectsChecks",
|
||||
"wikilessNormalCustomRedirects",
|
||||
"wikilessTorCustomRedirects",
|
||||
"wikilessI2pCustomRedirects",
|
||||
"wikilessLokiCustomRedirects"
|
||||
],
|
||||
r => {
|
||||
disableWikipedia = r.disableWikipedia;
|
||||
wikipediaRedirects = r.wikipediaRedirects;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
wikilessNormalRedirectsChecks = r.wikilessNormalRedirectsChecks;
|
||||
wikilessTorRedirectsChecks = r.wikilessTorRedirectsChecks;
|
||||
wikilessI2pRedirectsChecks = r.wikilessI2pRedirectsChecks;
|
||||
wikilessNormalCustomRedirects = r.wikilessNormalCustomRedirects;
|
||||
wikilessTorCustomRedirects = r.wikilessTorCustomRedirects;
|
||||
wikilessI2pCustomRedirects = r.wikilessI2pCustomRedirects;
|
||||
wikilessLokiCustomRedirects = r.wikilessLokiCustomRedirects;
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableWikipedia",
|
||||
"wikipediaRedirects",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"wikilessNormalRedirectsChecks",
|
||||
"wikilessTorRedirectsChecks",
|
||||
"wikilessI2pRedirectsChecks",
|
||||
"wikilessNormalCustomRedirects",
|
||||
"wikilessTorCustomRedirects",
|
||||
"wikilessI2pCustomRedirects",
|
||||
"wikilessLokiCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disableWikipedia = r.disableWikipedia
|
||||
wikipediaRedirects = r.wikipediaRedirects
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
wikilessNormalRedirectsChecks = r.wikilessNormalRedirectsChecks
|
||||
wikilessTorRedirectsChecks = r.wikilessTorRedirectsChecks
|
||||
wikilessI2pRedirectsChecks = r.wikilessI2pRedirectsChecks
|
||||
wikilessNormalCustomRedirects = r.wikilessNormalCustomRedirects
|
||||
wikilessTorCustomRedirects = r.wikilessTorCustomRedirects
|
||||
wikilessI2pCustomRedirects = r.wikilessI2pCustomRedirects
|
||||
wikilessLokiCustomRedirects = r.wikilessLokiCustomRedirects
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function initWikilessCookies(test, from) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
const protocolHost = utils.protocolHost(from);
|
||||
const all = [
|
||||
...wikilessNormalRedirectsChecks,
|
||||
...wikilessNormalCustomRedirects,
|
||||
...wikilessTorRedirectsChecks,
|
||||
...wikilessTorCustomRedirects,
|
||||
...wikilessI2pRedirectsChecks,
|
||||
...wikilessI2pCustomRedirects,
|
||||
...wikilessLokiCustomRedirects
|
||||
];
|
||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
const protocolHost = utils.protocolHost(from)
|
||||
const all = [
|
||||
...wikilessNormalRedirectsChecks,
|
||||
...wikilessNormalCustomRedirects,
|
||||
...wikilessTorRedirectsChecks,
|
||||
...wikilessTorCustomRedirects,
|
||||
...wikilessI2pRedirectsChecks,
|
||||
...wikilessI2pCustomRedirects,
|
||||
...wikilessLokiCustomRedirects,
|
||||
]
|
||||
if (!all.includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
if (!test) {
|
||||
let checkedInstances = [];
|
||||
if (protocol == 'loki') checkedInstances = [...wikilessLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks];
|
||||
else if (protocol == 'tor') checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects];
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects];
|
||||
}
|
||||
await utils.copyCookie('wikiless', from, checkedInstances, 'theme');
|
||||
await utils.copyCookie('wikiless', from, checkedInstances, 'default_lang');
|
||||
}
|
||||
resolve(true);
|
||||
})
|
||||
if (!test) {
|
||||
let checkedInstances = []
|
||||
if (protocol == "loki") checkedInstances = [...wikilessLokiCustomRedirects]
|
||||
else if (protocol == "i2p") checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]
|
||||
else if (protocol == "tor") checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]
|
||||
}
|
||||
await utils.copyCookie("wikiless", from, checkedInstances, "theme")
|
||||
await utils.copyCookie("wikiless", from, checkedInstances, "default_lang")
|
||||
}
|
||||
resolve(true)
|
||||
})
|
||||
}
|
||||
|
||||
function pasteWikilessCookies() {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableWikipedia || protocol === undefined) { resolve(); return; }
|
||||
let checkedInstances = [];
|
||||
if (protocol == 'loki') checkedInstances = [...wikilessLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks];
|
||||
else if (protocol == 'tor') checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects];
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects];
|
||||
}
|
||||
utils.getCookiesFromStorage('wikiless', checkedInstances, 'theme');
|
||||
utils.getCookiesFromStorage('wikiless', checkedInstances, 'default_lang');
|
||||
resolve();
|
||||
})
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableWikipedia || protocol === undefined) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
let checkedInstances = []
|
||||
if (protocol == "loki") checkedInstances = [...wikilessLokiCustomRedirects]
|
||||
else if (protocol == "i2p") checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]
|
||||
else if (protocol == "tor") checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]
|
||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]
|
||||
}
|
||||
utils.getCookiesFromStorage("wikiless", checkedInstances, "theme")
|
||||
utils.getCookiesFromStorage("wikiless", checkedInstances, "default_lang")
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
function redirect(url, disableOverride) {
|
||||
if (disableWikipedia && !disableOverride) return;
|
||||
if (!targets.test(url.href)) return;
|
||||
if (disableWikipedia && !disableOverride) return
|
||||
if (!targets.test(url.href)) return
|
||||
|
||||
let GETArguments = [];
|
||||
if (url.search.length > 0) {
|
||||
let search = url.search.substring(1); //get rid of '?'
|
||||
let argstrings = search.split("&");
|
||||
for (let i = 0; i < argstrings.length; i++) {
|
||||
let args = argstrings[i].split("=");
|
||||
GETArguments.push([args[0], args[1]]);
|
||||
}
|
||||
}
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...wikilessLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks];
|
||||
else if (protocol == 'tor') instancesList = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) return;
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
let GETArguments = []
|
||||
if (url.search.length > 0) {
|
||||
let search = url.search.substring(1) //get rid of '?'
|
||||
let argstrings = search.split("&")
|
||||
for (let i = 0; i < argstrings.length; i++) {
|
||||
let args = argstrings[i].split("=")
|
||||
GETArguments.push([args[0], args[1]])
|
||||
}
|
||||
}
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...wikilessLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]
|
||||
else if (protocol == "tor") instancesList = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]
|
||||
}
|
||||
if (instancesList.length === 0) return
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
|
||||
let link = `${randomInstance}${url.pathname}`;
|
||||
let urlSplit = url.host.split(".");
|
||||
if (urlSplit[0] != "wikipedia" && urlSplit[0] != "www") {
|
||||
if (urlSplit[0] == "m")
|
||||
GETArguments.push(["mobileaction", "toggle_view_mobile"]);
|
||||
else
|
||||
GETArguments.push(["lang", urlSplit[0]]);
|
||||
if (urlSplit[1] == "m")
|
||||
GETArguments.push(["mobileaction", "toggle_view_mobile"]);
|
||||
// wikiless doesn't have mobile view support yet
|
||||
}
|
||||
for (let i = 0; i < GETArguments.length; i++)
|
||||
link += (i == 0 ? "?" : "&") + GETArguments[i][0] + "=" + GETArguments[i][1];
|
||||
return link;
|
||||
let link = `${randomInstance}${url.pathname}`
|
||||
let urlSplit = url.host.split(".")
|
||||
if (urlSplit[0] != "wikipedia" && urlSplit[0] != "www") {
|
||||
if (urlSplit[0] == "m") GETArguments.push(["mobileaction", "toggle_view_mobile"])
|
||||
else GETArguments.push(["lang", urlSplit[0]])
|
||||
if (urlSplit[1] == "m") GETArguments.push(["mobileaction", "toggle_view_mobile"])
|
||||
// wikiless doesn't have mobile view support yet
|
||||
}
|
||||
for (let i = 0; i < GETArguments.length; i++) link += (i == 0 ? "?" : "&") + GETArguments[i][0] + "=" + GETArguments[i][1]
|
||||
return link
|
||||
}
|
||||
|
||||
function switchInstance(url, disableOverride) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableWikipedia && !disableOverride) { resolve(); return; }
|
||||
const protocolHost = utils.protocolHost(url);
|
||||
const wikipediaList = [
|
||||
...wikipediaRedirects.wikiless.normal,
|
||||
...wikipediaRedirects.wikiless.tor,
|
||||
...wikipediaRedirects.wikiless.i2p,
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableWikipedia && !disableOverride) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
const protocolHost = utils.protocolHost(url)
|
||||
const wikipediaList = [
|
||||
...wikipediaRedirects.wikiless.normal,
|
||||
...wikipediaRedirects.wikiless.tor,
|
||||
...wikipediaRedirects.wikiless.i2p,
|
||||
|
||||
...wikilessNormalCustomRedirects,
|
||||
...wikilessTorCustomRedirects,
|
||||
...wikilessI2pCustomRedirects,
|
||||
...wikilessLokiCustomRedirects
|
||||
];
|
||||
if (!wikipediaList.includes(protocolHost)) { resolve(); return; }
|
||||
...wikilessNormalCustomRedirects,
|
||||
...wikilessTorCustomRedirects,
|
||||
...wikilessI2pCustomRedirects,
|
||||
...wikilessLokiCustomRedirects,
|
||||
]
|
||||
if (!wikipediaList.includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...wikilessLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks];
|
||||
else if (protocol == 'tor') instancesList = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects];
|
||||
}
|
||||
let instancesList = []
|
||||
if (protocol == "loki") instancesList = [...wikilessLokiCustomRedirects]
|
||||
else if (protocol == "i2p") instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]
|
||||
else if (protocol == "tor") instancesList = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
instancesList = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]
|
||||
}
|
||||
|
||||
let index = instancesList.indexOf(protocolHost);
|
||||
if (index > -1) instancesList.splice(index, 1);
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
let index = instancesList.indexOf(protocolHost)
|
||||
if (index > -1) instancesList.splice(index, 1)
|
||||
if (instancesList.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
})
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||
})
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
||||
let dataJson = JSON.parse(data);
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get('cloudflareBlackList', async r => {
|
||||
wikilessNormalRedirectsChecks = [...redirects.wikiless.normal];
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
let i = wikilessNormalRedirectsChecks.indexOf(instance);
|
||||
if (i > -1) wikilessNormalRedirectsChecks.splice(i, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
disableWikipedia: true,
|
||||
wikipediaRedirects: redirects,
|
||||
|
||||
wikilessNormalRedirectsChecks: wikilessNormalRedirectsChecks,
|
||||
wikilessNormalCustomRedirects: [],
|
||||
|
||||
wikilessTorRedirectsChecks: [...redirects.wikiless.tor],
|
||||
wikilessTorCustomRedirects: [],
|
||||
|
||||
wikilessI2pRedirectsChecks: [...redirects.wikiless.i2p],
|
||||
wikilessI2pCustomRedirects: [],
|
||||
|
||||
wikilessLokiRedirectsChecks: [...redirects.wikiless.loki],
|
||||
wikilessLokiCustomRedirects: []
|
||||
|
||||
}, () => resolve());
|
||||
})
|
||||
})
|
||||
})
|
||||
return new Promise(resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(async data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||
wikilessNormalRedirectsChecks = [...redirects.wikiless.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
let i = wikilessNormalRedirectsChecks.indexOf(instance)
|
||||
if (i > -1) wikilessNormalRedirectsChecks.splice(i, 1)
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
disableWikipedia: true,
|
||||
wikipediaRedirects: redirects,
|
||||
|
||||
wikilessNormalRedirectsChecks: wikilessNormalRedirectsChecks,
|
||||
wikilessNormalCustomRedirects: [],
|
||||
|
||||
wikilessTorRedirectsChecks: [...redirects.wikiless.tor],
|
||||
wikilessTorCustomRedirects: [],
|
||||
|
||||
wikilessI2pRedirectsChecks: [...redirects.wikiless.i2p],
|
||||
wikilessI2pCustomRedirects: [],
|
||||
|
||||
wikilessLokiRedirectsChecks: [...redirects.wikiless.loki],
|
||||
wikilessLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
setRedirects,
|
||||
setRedirects,
|
||||
|
||||
initWikilessCookies,
|
||||
pasteWikilessCookies,
|
||||
initWikilessCookies,
|
||||
pasteWikilessCookies,
|
||||
|
||||
redirect,
|
||||
initDefaults,
|
||||
switchInstance,
|
||||
};
|
||||
redirect,
|
||||
initDefaults,
|
||||
switchInstance,
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
browser.storage.local.set(
|
||||
{
|
||||
'pipedMaterial_PREFERENCES': localStorage.getItem("PREFERENCES")
|
||||
}
|
||||
)
|
||||
browser.storage.local.set({
|
||||
pipedMaterial_PREFERENCES: localStorage.getItem("PREFERENCES"),
|
||||
})
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
browser.storage.local.set(
|
||||
{
|
||||
'piped_bufferGoal': localStorage.getItem("bufferGoal"),
|
||||
'piped_comments': localStorage.getItem("comments"),
|
||||
'piped_disableLBRY': localStorage.getItem("disableLBRY"),
|
||||
'piped_enabledCodecs': localStorage.getItem("enabledCodecs"),
|
||||
'piped_hl': localStorage.getItem("hl"),
|
||||
'piped_homepage': localStorage.getItem("homepage"),
|
||||
'piped_instance': localStorage.getItem("instance"),
|
||||
'piped_listen': localStorage.getItem("listen"),
|
||||
'piped_minimizeDescription': localStorage.getItem("minimizeDescription"),
|
||||
'piped_playerAutoPlay': localStorage.getItem("playerAutoPlay"),
|
||||
'piped_proxyLBRY': localStorage.getItem("proxyLBRY"),
|
||||
'piped_quality': localStorage.getItem("quality"),
|
||||
'piped_region': localStorage.getItem("region"),
|
||||
'piped_selectedSkip': localStorage.getItem("selectedSkip"),
|
||||
'piped_sponsorblock': localStorage.getItem("sponsorblock"),
|
||||
'piped_theme': localStorage.getItem("theme"),
|
||||
'piped_volume': localStorage.getItem("volume"),
|
||||
'piped_watchHistory': localStorage.getItem("watchHistory"),
|
||||
}
|
||||
)
|
||||
browser.storage.local.set({
|
||||
piped_bufferGoal: localStorage.getItem("bufferGoal"),
|
||||
piped_comments: localStorage.getItem("comments"),
|
||||
piped_disableLBRY: localStorage.getItem("disableLBRY"),
|
||||
piped_enabledCodecs: localStorage.getItem("enabledCodecs"),
|
||||
piped_hl: localStorage.getItem("hl"),
|
||||
piped_homepage: localStorage.getItem("homepage"),
|
||||
piped_instance: localStorage.getItem("instance"),
|
||||
piped_listen: localStorage.getItem("listen"),
|
||||
piped_minimizeDescription: localStorage.getItem("minimizeDescription"),
|
||||
piped_playerAutoPlay: localStorage.getItem("playerAutoPlay"),
|
||||
piped_proxyLBRY: localStorage.getItem("proxyLBRY"),
|
||||
piped_quality: localStorage.getItem("quality"),
|
||||
piped_region: localStorage.getItem("region"),
|
||||
piped_selectedSkip: localStorage.getItem("selectedSkip"),
|
||||
piped_sponsorblock: localStorage.getItem("sponsorblock"),
|
||||
piped_theme: localStorage.getItem("theme"),
|
||||
piped_volume: localStorage.getItem("volume"),
|
||||
piped_watchHistory: localStorage.getItem("watchHistory"),
|
||||
})
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
browser.storage.local.get(
|
||||
"pipedMaterial_PREFERENCES",
|
||||
r => {
|
||||
if (r.pipedMaterial_PREFERENCES !== undefined) localStorage.setItem("PREFERENCES", r.pipedMaterial_PREFERENCES)
|
||||
browser.storage.local.get("pipedMaterial_PREFERENCES", r => {
|
||||
if (r.pipedMaterial_PREFERENCES !== undefined) localStorage.setItem("PREFERENCES", r.pipedMaterial_PREFERENCES)
|
||||
|
||||
window.close();
|
||||
}
|
||||
)
|
||||
window.close()
|
||||
})
|
||||
|
|
|
@ -1,45 +1,45 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"piped_bufferGoal",
|
||||
"piped_comments",
|
||||
"piped_disableLBRY",
|
||||
"piped_enabledCodecs",
|
||||
"piped_homepage",
|
||||
"piped_instance",
|
||||
"piped_listen",
|
||||
"piped_minimizeDescription",
|
||||
"piped_playerAutoPlay",
|
||||
"piped_proxyLBRY",
|
||||
"piped_quality",
|
||||
"piped_region",
|
||||
"piped_selectedSkip",
|
||||
"piped_sponsorblock",
|
||||
"piped_theme",
|
||||
"piped_volume",
|
||||
"piped_watchHistory",
|
||||
],
|
||||
r => {
|
||||
if (r.piped_bufferGoal !== undefined) localStorage.setItem("bufferGoal", r.piped_bufferGoal);
|
||||
if (r.piped_comments !== undefined) localStorage.setItem("comments", r.piped_comments);
|
||||
if (r.piped_disableLBRY !== undefined) localStorage.setItem("disableLBRY", r.piped_disableLBRY);
|
||||
if (r.piped_hl !== undefined) localStorage.setItem("hl", r.piped_hl);
|
||||
if (r.piped_enabledCodecs !== undefined) localStorage.setItem("enabledCodecs", r.piped_enabledCodecs);
|
||||
if (r.piped_homepage !== undefined) localStorage.setItem("homepage", r.piped_homepage);
|
||||
if (r.piped_instance !== undefined) localStorage.setItem("instance", r.piped_instance);
|
||||
if (r.piped_listen !== undefined) localStorage.setItem("listen", r.piped_listen);
|
||||
if (r.piped_minimizeDescription !== undefined) localStorage.setItem("minimizeDescription", r.piped_minimizeDescription);
|
||||
if (r.piped_playerAutoPlay !== undefined) localStorage.setItem("playerAutoPlay", r.piped_playerAutoPlay);
|
||||
if (r.piped_proxyLBRY !== undefined) localStorage.setItem("proxyLBRY", r.piped_proxyLBRY);
|
||||
if (r.piped_quality !== undefined) localStorage.setItem("quality", r.piped_quality);
|
||||
if (r.piped_region !== undefined) localStorage.setItem("region", r.piped_region);
|
||||
if (r.piped_selectedSkip !== undefined) localStorage.setItem("selectedSkip", r.piped_selectedSkip);
|
||||
if (r.piped_sponsorblock !== undefined) localStorage.setItem("sponsorblock", r.piped_sponsorblock);
|
||||
if (r.piped_theme !== undefined) localStorage.setItem("theme", r.piped_theme);
|
||||
if (r.piped_volume !== undefined) localStorage.setItem("volume", r.piped_volume);
|
||||
if (r.piped_watchHistory !== undefined) localStorage.setItem("watchHistory", r.piped_watchHistory);
|
||||
[
|
||||
"piped_bufferGoal",
|
||||
"piped_comments",
|
||||
"piped_disableLBRY",
|
||||
"piped_enabledCodecs",
|
||||
"piped_homepage",
|
||||
"piped_instance",
|
||||
"piped_listen",
|
||||
"piped_minimizeDescription",
|
||||
"piped_playerAutoPlay",
|
||||
"piped_proxyLBRY",
|
||||
"piped_quality",
|
||||
"piped_region",
|
||||
"piped_selectedSkip",
|
||||
"piped_sponsorblock",
|
||||
"piped_theme",
|
||||
"piped_volume",
|
||||
"piped_watchHistory",
|
||||
],
|
||||
r => {
|
||||
if (r.piped_bufferGoal !== undefined) localStorage.setItem("bufferGoal", r.piped_bufferGoal)
|
||||
if (r.piped_comments !== undefined) localStorage.setItem("comments", r.piped_comments)
|
||||
if (r.piped_disableLBRY !== undefined) localStorage.setItem("disableLBRY", r.piped_disableLBRY)
|
||||
if (r.piped_hl !== undefined) localStorage.setItem("hl", r.piped_hl)
|
||||
if (r.piped_enabledCodecs !== undefined) localStorage.setItem("enabledCodecs", r.piped_enabledCodecs)
|
||||
if (r.piped_homepage !== undefined) localStorage.setItem("homepage", r.piped_homepage)
|
||||
if (r.piped_instance !== undefined) localStorage.setItem("instance", r.piped_instance)
|
||||
if (r.piped_listen !== undefined) localStorage.setItem("listen", r.piped_listen)
|
||||
if (r.piped_minimizeDescription !== undefined) localStorage.setItem("minimizeDescription", r.piped_minimizeDescription)
|
||||
if (r.piped_playerAutoPlay !== undefined) localStorage.setItem("playerAutoPlay", r.piped_playerAutoPlay)
|
||||
if (r.piped_proxyLBRY !== undefined) localStorage.setItem("proxyLBRY", r.piped_proxyLBRY)
|
||||
if (r.piped_quality !== undefined) localStorage.setItem("quality", r.piped_quality)
|
||||
if (r.piped_region !== undefined) localStorage.setItem("region", r.piped_region)
|
||||
if (r.piped_selectedSkip !== undefined) localStorage.setItem("selectedSkip", r.piped_selectedSkip)
|
||||
if (r.piped_sponsorblock !== undefined) localStorage.setItem("sponsorblock", r.piped_sponsorblock)
|
||||
if (r.piped_theme !== undefined) localStorage.setItem("theme", r.piped_theme)
|
||||
if (r.piped_volume !== undefined) localStorage.setItem("volume", r.piped_volume)
|
||||
if (r.piped_watchHistory !== undefined) localStorage.setItem("watchHistory", r.piped_watchHistory)
|
||||
|
||||
window.close();
|
||||
}
|
||||
)
|
||||
window.close()
|
||||
}
|
||||
)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,61 +1,192 @@
|
|||
"use strict";
|
||||
"use strict"
|
||||
|
||||
import utils from './utils.js'
|
||||
import utils from "./utils.js"
|
||||
|
||||
window.browser = window.browser || window.chrome;
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
const targets = [
|
||||
/^https?:\/{2}music\.youtube\.com(\/.*|$)/,
|
||||
];
|
||||
let redirects = {
|
||||
"beatbump": {
|
||||
"normal": [
|
||||
"https://beatbump.ml"
|
||||
],
|
||||
"tor": [],
|
||||
"i2p": [],
|
||||
"loki": []
|
||||
},
|
||||
};
|
||||
const targets = [/^https?:\/{2}music\.youtube\.com(\/.*|$)/]
|
||||
|
||||
let
|
||||
disableYoutubeMusic,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
beatbumpNormalRedirectsChecks,
|
||||
beatbumpNormalCustomRedirects,
|
||||
beatbumpTorCustomRedirects,
|
||||
beatbumpI2pCustomRedirects,
|
||||
beatbumpLokiCustomRedirects;
|
||||
const frontends = new Array("beatbump", "hyperpipe")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
||||
function init() {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableYoutubeMusic",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"beatbumpNormalRedirectsChecks",
|
||||
"beatbumpNormalCustomRedirects",
|
||||
"beatbumpTorCustomRedirects",
|
||||
"beatbumpI2pCustomRedirects",
|
||||
"beatbumpLokiCustomRedirects"
|
||||
],
|
||||
r => {
|
||||
disableYoutubeMusic = r.disableYoutubeMusic;
|
||||
protocol = r.protocol;
|
||||
protocolFallback = r.protocolFallback;
|
||||
beatbumpNormalRedirectsChecks = r.beatbumpNormalRedirectsChecks;
|
||||
beatbumpNormalCustomRedirects = r.beatbumpNormalCustomRedirects;
|
||||
beatbumpTorCustomRedirects = r.beatbumpTorCustomRedirects;
|
||||
beatbumpI2pCustomRedirects = r.beatbumpI2pCustomRedirects;
|
||||
beatbumpLokiCustomRedirects = r.beatbumpLokiCustomRedirects;
|
||||
}
|
||||
)
|
||||
let redirects = {}
|
||||
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = {}
|
||||
for (let x = 0; x < protocols.length; x++) {
|
||||
redirects[frontends[i]][protocols[x]] = []
|
||||
}
|
||||
}
|
||||
|
||||
init();
|
||||
function setRedirects(val) {
|
||||
browser.storage.local.get("cloudflareBlackList", r => {
|
||||
redirects = val
|
||||
beatbumpNormalRedirectsChecks = [...redirects.beatbump.normal]
|
||||
hyperpipeNormalRedirectsChecks = [...redirects.hyperpipe.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
const a = beatbumpNormalRedirectsChecks.indexOf(instance)
|
||||
if (a > -1) beatbumpNormalRedirectsChecks.splice(a, 1)
|
||||
|
||||
const b = hyperpipeNormalRedirectsChecks.indexOf(instance)
|
||||
if (b > -1) hyperpipeNormalRedirectsChecks.splice(b, 1)
|
||||
}
|
||||
browser.storage.local.set({
|
||||
youtubeMusicRedirects: redirects,
|
||||
beatbumpNormalRedirectsChecks,
|
||||
hyperpipeNormalRedirectsChecks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let disableYoutubeMusic,
|
||||
youtubeMusicFrontend,
|
||||
youtubeMusicRedirects,
|
||||
protocol,
|
||||
protocolFallback,
|
||||
beatbumpNormalRedirectsChecks,
|
||||
beatbumpNormalCustomRedirects,
|
||||
beatbumpTorRedirectsChecks,
|
||||
beatbumpTorCustomRedirects,
|
||||
beatbumpI2pRedirectsChecks,
|
||||
beatbumpI2pCustomRedirects,
|
||||
beatbumpLokiRedirectsChecks,
|
||||
beatbumpLokiCustomRedirects,
|
||||
hyperpipeNormalRedirectsChecks,
|
||||
hyperpipeNormalCustomRedirects,
|
||||
hyperpipeTorRedirectsChecks,
|
||||
hyperpipeTorCustomRedirects,
|
||||
hyperpipeI2pRedirectsChecks,
|
||||
hyperpipeI2pCustomRedirects,
|
||||
hyperpipeLokiRedirectsChecks,
|
||||
hyperpipeLokiCustomRedirects
|
||||
|
||||
function init() {
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableYoutubeMusic",
|
||||
"youtubeMusicFrontend",
|
||||
"youtubeMusicRedirects",
|
||||
"protocol",
|
||||
"protocolFallback",
|
||||
"beatbumpNormalRedirectsChecks",
|
||||
"beatbumpNormalCustomRedirects",
|
||||
"beatbumpTorRedirectsChecks",
|
||||
"beatbumpTorCustomRedirects",
|
||||
"beatbumpI2pRedirectsChecks",
|
||||
"beatbumpI2pCustomRedirects",
|
||||
"beatbumpLokiRedirectsChecks",
|
||||
"beatbumpLokiCustomRedirects",
|
||||
"hyperpipeNormalRedirectsChecks",
|
||||
"hyperpipeNormalCustomRedirects",
|
||||
"hyperpipeTorRedirectsChecks",
|
||||
"hyperpipeTorCustomRedirects",
|
||||
"hyperpipeI2pRedirectsChecks",
|
||||
"hyperpipeI2pCustomRedirects",
|
||||
"hyperpipeLokiRedirectsChecks",
|
||||
"hyperpipeLokiCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disableYoutubeMusic = r.disableYoutubeMusic
|
||||
youtubeMusicFrontend = r.youtubeMusicFrontend
|
||||
youtubeMusicRedirects = r.youtubeMusicRedirects
|
||||
protocol = r.protocol
|
||||
protocolFallback = r.protocolFallback
|
||||
beatbumpNormalRedirectsChecks = r.beatbumpNormalRedirectsChecks
|
||||
beatbumpNormalCustomRedirects = r.beatbumpNormalCustomRedirects
|
||||
beatbumpTorRedirectsChecks = r.beatbumpTorRedirectsChecks
|
||||
beatbumpTorCustomRedirects = r.beatbumpTorCustomRedirects
|
||||
beatbumpI2pRedirectsChecks = r.beatbumpI2pRedirectsChecks
|
||||
beatbumpI2pCustomRedirects = r.beatbumpI2pCustomRedirects
|
||||
beatbumpLokiRedirectsChecks = r.beatbumpLokiRedirectsChecks
|
||||
beatbumpLokiCustomRedirects = r.beatbumpLokiCustomRedirects
|
||||
hyperpipeNormalRedirectsChecks = r.hyperpipeNormalRedirectsChecks
|
||||
hyperpipeNormalCustomRedirects = r.hyperpipeNormalCustomRedirects
|
||||
hyperpipeTorRedirectsChecks = r.hyperpipeTorRedirectsChecks
|
||||
hyperpipeTorCustomRedirects = r.hyperpipeTorCustomRedirects
|
||||
hyperpipeI2pRedirectsChecks = r.hyperpipeI2pRedirectsChecks
|
||||
hyperpipeI2pCustomRedirects = r.hyperpipeI2pCustomRedirects
|
||||
hyperpipeLokiRedirectsChecks = r.hyperpipeLokiRedirectsChecks
|
||||
hyperpipeLokiCustomRedirects = r.hyperpipeLokiCustomRedirects
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init()
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function all() {
|
||||
return [
|
||||
...beatbumpNormalRedirectsChecks,
|
||||
...beatbumpNormalCustomRedirects,
|
||||
...beatbumpTorRedirectsChecks,
|
||||
...beatbumpTorCustomRedirects,
|
||||
...beatbumpI2pRedirectsChecks,
|
||||
...beatbumpI2pCustomRedirects,
|
||||
...beatbumpLokiRedirectsChecks,
|
||||
...beatbumpLokiCustomRedirects,
|
||||
...hyperpipeNormalRedirectsChecks,
|
||||
...hyperpipeNormalCustomRedirects,
|
||||
...hyperpipeTorRedirectsChecks,
|
||||
...hyperpipeTorCustomRedirects,
|
||||
...hyperpipeI2pRedirectsChecks,
|
||||
...hyperpipeI2pCustomRedirects,
|
||||
...hyperpipeLokiRedirectsChecks,
|
||||
...hyperpipeLokiCustomRedirects,
|
||||
]
|
||||
}
|
||||
|
||||
function getInstanceList() {
|
||||
let tmpList = []
|
||||
switch (youtubeMusicFrontend) {
|
||||
case "beatbump":
|
||||
switch (protocol) {
|
||||
case "loki":
|
||||
tmpList = [...beatbumpLokiRedirectsChecks, ...beatbumpLokiCustomRedirects]
|
||||
break
|
||||
case "i2p":
|
||||
tmpList = [...beatbumpI2pRedirectsChecks, ...beatbumpI2pCustomRedirects]
|
||||
break
|
||||
case "tor":
|
||||
tmpList = [...beatbumpTorRedirectsChecks, ...beatbumpTorCustomRedirects]
|
||||
}
|
||||
if ((tmpList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
tmpList = [...beatbumpNormalRedirectsChecks, ...beatbumpNormalCustomRedirects]
|
||||
}
|
||||
break
|
||||
case "hyperpipe":
|
||||
switch (protocol) {
|
||||
case "loki":
|
||||
tmpList = [...hyperpipeLokiRedirectsChecks, ...hyperpipeLokiCustomRedirects]
|
||||
break
|
||||
case "i2p":
|
||||
tmpList = [...hyperpipeI2pRedirectsChecks, ...hyperpipeI2pCustomRedirects]
|
||||
break
|
||||
case "tor":
|
||||
tmpList = [...hyperpipeTorRedirectsChecks, ...hyperpipeTorCustomRedirects]
|
||||
}
|
||||
if ((tmpList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||
tmpList = [...hyperpipeNormalRedirectsChecks, ...hyperpipeNormalCustomRedirects]
|
||||
}
|
||||
}
|
||||
return tmpList
|
||||
}
|
||||
|
||||
function getUrl(randomInstance, url) {
|
||||
switch (youtubeMusicFrontend) {
|
||||
case "beatbump":
|
||||
return `${randomInstance}${url.pathname}${url.search}`
|
||||
.replace("/watch?v=", "/listen?id=")
|
||||
.replace("/channel/", "/artist/")
|
||||
.replace("/playlist?list=", "/playlist/VL")
|
||||
.replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/") + "?filter=EgWKAQIIAWoKEAMQBBAKEAkQBQ%3D%3D")
|
||||
case "hyperpipe":
|
||||
return `${randomInstance}${url.pathname}${url.search}`.replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/"))
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Video
|
||||
https://music.youtube.com/watch?v=_PkGiKBW-DA&list=RDAMVM_PkGiKBW-DA
|
||||
|
@ -88,48 +219,105 @@ https://music.youtube.com/search?q=test
|
|||
https://beatbump.ml/search/test?filter=EgWKAQIIAWoKEAMQBBAKEAkQBQ%3D%3D
|
||||
|
||||
*/
|
||||
function redirect(url, disableOverride) {
|
||||
if (disableYoutubeMusic && !disableOverride) return;
|
||||
if (!targets.some(rx => rx.test(url.href))) return;
|
||||
function redirect(url, type, initiator, disableOverride) {
|
||||
if (disableYoutubeMusic && !disableOverride) return
|
||||
if (!targets.some(rx => rx.test(url.href))) return
|
||||
|
||||
let instancesList = [];
|
||||
if (protocol == 'loki') instancesList = [...beatbumpLokiCustomRedirects];
|
||||
else if (protocol == 'i2p') instancesList = [...beatbumpI2pCustomRedirects];
|
||||
else if (protocol == 'tor') instancesList = [...beatbumpTorCustomRedirects];
|
||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
||||
instancesList = [...beatbumpNormalRedirectsChecks, ...beatbumpNormalCustomRedirects];
|
||||
}
|
||||
if (instancesList.length === 0) return;
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
return `${randomInstance}${url.pathname}${url.search}`
|
||||
.replace("/watch?v=", "/listen?id=")
|
||||
.replace("/channel/", "/artist/")
|
||||
.replace("/playlist?list=", "/playlist/VL")
|
||||
.replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/") + "?filter=EgWKAQIIAWoKEAMQBBAKEAkQBQ%3D%3D");
|
||||
let instancesList = getInstanceList()
|
||||
|
||||
if (instancesList.length === 0) return
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
return getUrl(randomInstance, url)
|
||||
}
|
||||
|
||||
async function initDefaults() {
|
||||
return new Promise(resolve =>
|
||||
browser.storage.local.set({
|
||||
disableYoutubeMusic: true,
|
||||
youtubeMusicRedirects: redirects,
|
||||
function switchInstance(url, disableOverride) {
|
||||
return new Promise(async resolve => {
|
||||
await init()
|
||||
if (disableYoutubeMusic && !disableOverride) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
const protocolHost = utils.protocolHost(url)
|
||||
if (!all().includes(protocolHost)) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
beatbumpNormalRedirectsChecks: [...redirects.beatbump.normal],
|
||||
beatbumpNormalCustomRedirects: [],
|
||||
let instancesList = getInstanceList()
|
||||
|
||||
beatbumpTorRedirectsChecks: [...redirects.beatbump.tor],
|
||||
beatbumpTorCustomRedirects: [],
|
||||
const i = instancesList.indexOf(protocolHost)
|
||||
if (i > -1) instancesList.splice(i, 1)
|
||||
if (instancesList.length === 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
beatbumpI2pRedirectsChecks: [...redirects.beatbump.i2p],
|
||||
beatbumpI2pCustomRedirects: [],
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
return getUrl(randomInstance, url)
|
||||
})
|
||||
}
|
||||
|
||||
beatbumpLokiRedirectsChecks: [...redirects.beatbump.loki],
|
||||
beatbumpLokiCustomRedirects: []
|
||||
}, () => resolve())
|
||||
)
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
fetch("/instances/data.json")
|
||||
.then(response => response.text())
|
||||
.then(async data => {
|
||||
let dataJson = JSON.parse(data)
|
||||
for (let i = 0; i < frontends.length; i++) {
|
||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||
}
|
||||
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||
beatbumpNormalRedirectsChecks = [...redirects.beatbump.normal]
|
||||
hyperpipeNormalRedirectsChecks = [...redirects.hyperpipe.normal]
|
||||
for (const instance of r.cloudflareBlackList) {
|
||||
let i
|
||||
|
||||
i = beatbumpNormalRedirectsChecks.indexOf(instance)
|
||||
if (i > -1) beatbumpNormalRedirectsChecks.splice(i, 1)
|
||||
|
||||
i = hyperpipeNormalRedirectsChecks.indexOf(instance)
|
||||
if (i > -1) hyperpipeNormalRedirectsChecks.splice(i, 1)
|
||||
}
|
||||
browser.storage.local.set(
|
||||
{
|
||||
disableYoutubeMusic: false,
|
||||
youtubeMusicFrontend: "hyperpipe",
|
||||
youtubeMusicRedirects: redirects,
|
||||
|
||||
beatbumpNormalRedirectsChecks: beatbumpNormalRedirectsChecks,
|
||||
beatbumpNormalCustomRedirects: [],
|
||||
|
||||
beatbumpTorRedirectsChecks: [...redirects.beatbump.tor],
|
||||
beatbumpTorCustomRedirects: [],
|
||||
|
||||
beatbumpI2pRedirectsChecks: [...redirects.beatbump.i2p],
|
||||
beatbumpI2pCustomRedirects: [],
|
||||
|
||||
beatbumpLokiRedirectsChecks: [...redirects.beatbump.loki],
|
||||
beatbumpLokiCustomRedirects: [],
|
||||
|
||||
hyperpipeNormalRedirectsChecks: hyperpipeNormalRedirectsChecks,
|
||||
hyperpipeNormalCustomRedirects: [],
|
||||
|
||||
hyperpipeTorRedirectsChecks: [...redirects.hyperpipe.tor],
|
||||
hyperpipeTorCustomRedirects: [],
|
||||
|
||||
hyperpipeI2pRedirectsChecks: [...redirects.hyperpipe.i2p],
|
||||
hyperpipeI2pCustomRedirects: [],
|
||||
|
||||
hyperpipeLokiRedirectsChecks: [...redirects.hyperpipe.loki],
|
||||
hyperpipeLokiCustomRedirects: [],
|
||||
},
|
||||
() => resolve()
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
redirect,
|
||||
initDefaults,
|
||||
};
|
||||
setRedirects,
|
||||
switchInstance,
|
||||
redirect,
|
||||
initDefaults,
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"normal": ["https://beatbump.ml"],
|
||||
"tor": [],
|
||||
"i2p": [],
|
||||
"loki": []
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"normal": ["https://tube.cadence.moe", "https://yt.beparanoid.de"],
|
||||
"tor": ["http://yt.prnoid54e44a4bduq5due64jkk7wcnkxcp5kv3juncm7veptjcqudgyd.onion"],
|
||||
"i2p": [],
|
||||
"loki": []
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"normal": ["https://facilmap.org"],
|
||||
"tor": [],
|
||||
"i2p": [],
|
||||
"loki": []
|
||||
}
|
|
@ -12,6 +12,12 @@ import subprocess
|
|||
|
||||
mightyList = {}
|
||||
|
||||
startRegex = "https?:\/{2}(?:[^\s\/]+\.)+"
|
||||
endRegex = "(?:\/[^\s\/]+)*\/?"
|
||||
torRegex = startRegex + "onion" + endRegex
|
||||
i2pRegex = startRegex + "i2p" + endRegex
|
||||
lokiRegex = startRegex + "loki" + endRegex
|
||||
authRegex = "https?:\/{2}\S+:\S+@(?:[^\s\/]+\.)+[a-zA-Z0-9]+" + endRegex
|
||||
|
||||
def filterLastSlash(urlList):
|
||||
tmp = {}
|
||||
|
@ -65,16 +71,19 @@ def is_cloudflare(url):
|
|||
instance_bin_masked = instance_bin[:mask]
|
||||
|
||||
if cloudflare_bin_masked == instance_bin_masked:
|
||||
print(url + ' is ' + Fore.RED + 'cloudflare' + Style.RESET_ALL)
|
||||
print(url + ' is behind ' + Fore.RED + 'cloudflare' + Style.RESET_ALL)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def is_authenticate(url):
|
||||
try:
|
||||
if re.match(authRegex, url):
|
||||
print(url + ' requires ' + Fore.RED + 'authentication' + Style.RESET_ALL)
|
||||
return True
|
||||
r = requests.get(url, timeout=5)
|
||||
if 'www-authenticate' in r.headers:
|
||||
print(url + ' is ' + Fore.RED + 'authenticate' + Style.RESET_ALL)
|
||||
print(url + ' requires ' + Fore.RED + 'authentication' + Style.RESET_ALL)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
@ -99,9 +108,26 @@ def invidious():
|
|||
|
||||
|
||||
def piped():
|
||||
json_object = json.dumps(mightyList, ensure_ascii=False, indent=2)
|
||||
with open('./src/instances/piped.json') as file:
|
||||
mightyList['piped'] = json.load(file)
|
||||
r = requests.get(
|
||||
'https://raw.githubusercontent.com/wiki/TeamPiped/Piped/Instances.md')
|
||||
|
||||
tmp = re.findall(
|
||||
'(?:[^\s\/]+\.)+[a-zA-Z]+ (?:\(Official\) )?\| (https:\/{2}(?:[^\s\/]+\.)+[a-zA-Z]+) \| ', r.text)
|
||||
_list = {}
|
||||
_list['normal'] = []
|
||||
_list['tor'] = []
|
||||
_list['i2p'] = []
|
||||
_list['loki'] = []
|
||||
for item in tmp:
|
||||
try:
|
||||
url = requests.get(item, timeout=5).url
|
||||
if url.strip("/") == item:
|
||||
continue
|
||||
else:
|
||||
_list['normal'].append(url)
|
||||
except:
|
||||
continue
|
||||
mightyList['piped'] = _list
|
||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Piped')
|
||||
|
||||
|
||||
|
@ -110,7 +136,7 @@ def pipedMaterial():
|
|||
'https://raw.githubusercontent.com/mmjee/Piped-Material/master/README.md')
|
||||
|
||||
tmp = re.findall(
|
||||
r"\| (https?:\/{2}(?:.+\.)+[a-zA-Z0-9]*) +\|", r.text)
|
||||
r"\| (https?:\/{2}(?:\S+\.)+[a-zA-Z0-9]*) +\|", r.text)
|
||||
pipedMaterialList = {}
|
||||
pipedMaterialList['normal'] = []
|
||||
pipedMaterialList['tor'] = []
|
||||
|
@ -122,6 +148,13 @@ def pipedMaterial():
|
|||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'pipedMaterial')
|
||||
|
||||
|
||||
def cloudtube():
|
||||
json_object = json.dumps(mightyList, ensure_ascii=False, indent=2)
|
||||
with open('./src/instances/cloudtube.json') as file:
|
||||
mightyList['cloudtube'] = json.load(file)
|
||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'CloudTube')
|
||||
|
||||
|
||||
def proxitok():
|
||||
r = requests.get(
|
||||
'https://raw.githubusercontent.com/wiki/pablouser1/ProxiTok/Public-instances.md')
|
||||
|
@ -156,30 +189,29 @@ def send():
|
|||
|
||||
|
||||
def nitter():
|
||||
r = requests.get('https://github.com/zedeus/nitter/wiki/Instances')
|
||||
soup = BeautifulSoup(r.text, 'html.parser')
|
||||
markdownBody = soup.find(class_='markdown-body')
|
||||
tables = markdownBody.find_all('table')
|
||||
tables.pop(3)
|
||||
tables.pop(3)
|
||||
r = requests.get('https://raw.githubusercontent.com/wiki/zedeus/nitter/Instances.md')
|
||||
tmp = re.findall(
|
||||
r"(?:(?:\| \[(?:\S+\.)+[a-zA-Z]+\]\((https?:\/{2}(?:\S+\.)+[a-zA-Z]+)\/?\) (?:\((?:\S+ ?\S*)\) )? *\| (?:✅|🇩🇪) +\|(?:(?:\n)|(?: (?:❌)|(?: ✅)|(?: ❓)|(?: \[))))|(?:- \[(?:\S+\.)+(?:(?:i2p)|(?:loki))\]\((https?:\/{2}(?:\S+\.)(?:(?:i2p)|(?:loki)))\/?\)))", r.text)
|
||||
|
||||
nitterList = {}
|
||||
nitterList['normal'] = []
|
||||
nitterList['tor'] = []
|
||||
nitterList['i2p'] = []
|
||||
nitterList['loki'] = []
|
||||
for table in tables:
|
||||
tbody = table.find('tbody')
|
||||
trs = tbody.find_all('tr')
|
||||
for tr in trs:
|
||||
td = tr.find('td')
|
||||
a = td.find('a')
|
||||
url = a.contents[0]
|
||||
if url.endswith('.onion'):
|
||||
url = 'http://' + url
|
||||
nitterList['tor'].append(url)
|
||||
for item in tmp:
|
||||
for i in item:
|
||||
if i == '':
|
||||
continue
|
||||
else:
|
||||
url = 'https://' + url
|
||||
nitterList['normal'].append(url)
|
||||
item = i
|
||||
if re.search(torRegex, item):
|
||||
nitterList['tor'].append(item)
|
||||
elif re.search(i2pRegex, item):
|
||||
nitterList['i2p'].append(item)
|
||||
elif re.search(lokiRegex, item):
|
||||
nitterList['loki'].append(item)
|
||||
else:
|
||||
nitterList['normal'].append(item)
|
||||
mightyList['nitter'] = nitterList
|
||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Nitter')
|
||||
|
||||
|
@ -211,7 +243,7 @@ def libreddit():
|
|||
r"\| \[.*\]\(([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)\)*\|*[A-Z]{0,}.*\|.*\|", r.text)
|
||||
|
||||
for item in tmp:
|
||||
if re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+onion(?:\/[a-zA-Z0-9]+)*\/?", item):
|
||||
if re.search(torRegex, item):
|
||||
libredditList['tor'].append(item)
|
||||
else:
|
||||
libredditList['normal'].append(item)
|
||||
|
@ -292,7 +324,7 @@ def quetre():
|
|||
|
||||
|
||||
for item in tmp:
|
||||
if re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+onion(?:\/[a-zA-Z0-9]+)*\/?", item):
|
||||
if re.search(torRegex, item):
|
||||
_list['tor'].append(item)
|
||||
else:
|
||||
_list['normal'].append(item)
|
||||
|
@ -316,7 +348,7 @@ def libremdb():
|
|||
for item in tmp:
|
||||
if item.strip() == "":
|
||||
continue
|
||||
if re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+onion(?:\/[a-zA-Z0-9]+)*\/?", item):
|
||||
if re.search(torRegex, item):
|
||||
_list['tor'].append(item)
|
||||
else:
|
||||
_list['normal'].append(item)
|
||||
|
@ -324,6 +356,19 @@ def libremdb():
|
|||
mightyList['libremdb'] = _list
|
||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Libremdb')
|
||||
|
||||
def simpleertube():
|
||||
r = requests.get('https://simple-web.org/instances/simpleertube')
|
||||
_list = {}
|
||||
_list['normal'] = []
|
||||
_list['tor'] = []
|
||||
_list['i2p'] = []
|
||||
_list['loki'] = []
|
||||
for item in r.text.strip().split('\n'):
|
||||
_list['normal'].append('https://' + item)
|
||||
|
||||
mightyList['simpleertube'] = _list
|
||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'SimpleerTube')
|
||||
|
||||
|
||||
def simplytranslate():
|
||||
r = requests.get('https://simple-web.org/instances/simplytranslate')
|
||||
|
@ -381,12 +426,12 @@ def searx_searxng():
|
|||
searxngList['i2p'] = []
|
||||
searxngList['loki'] = []
|
||||
for item in rJson['instances']:
|
||||
if re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+onion(?:\/[a-zA-Z0-9]+)*\/?", item[:-1]):
|
||||
if re.search(torRegex, item[:-1]):
|
||||
if (rJson['instances'][item].get('generator') == 'searxng'):
|
||||
searxngList['tor'].append(item[:-1])
|
||||
else:
|
||||
searxList['tor'].append(item[:-1])
|
||||
elif re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+i2p(?:\/[a-zA-Z0-9]+)*\/?", item[:-1]):
|
||||
elif re.search(torRegex, item[:-1]):
|
||||
if (rJson['instances'][item].get('generator') == 'searxng'):
|
||||
searxngList['i2p'].append(item[:-1])
|
||||
else:
|
||||
|
@ -412,9 +457,9 @@ def whoogle():
|
|||
whoogleList['i2p'] = []
|
||||
whoogleList['loki'] = []
|
||||
for item in tmpList:
|
||||
if re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+onion(?:\/[a-zA-Z0-9]+)*\/?", item):
|
||||
if re.search(torRegex, item):
|
||||
whoogleList['tor'].append(item)
|
||||
elif re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+i2p(?:\/[a-zA-Z0-9]+)*\/?", item):
|
||||
elif re.search(torRegex, item):
|
||||
whoogleList['i2p'].append(item)
|
||||
else:
|
||||
whoogleList['normal'].append(item)
|
||||
|
@ -437,9 +482,9 @@ def librex():
|
|||
for item in tmp:
|
||||
if item.strip() == "":
|
||||
continue
|
||||
elif re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+onion(?:\/[a-zA-Z0-9]+)*\/?", item):
|
||||
elif re.search(torRegex, item):
|
||||
_list['tor'].append(item)
|
||||
elif re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+i2p(?:\/[a-zA-Z0-9]+)*\/?", item):
|
||||
elif re.search(i2pRegex, item):
|
||||
_list['i2p'].append(item)
|
||||
else:
|
||||
_list['normal'].append(item)
|
||||
|
@ -481,16 +526,64 @@ def librarian():
|
|||
url = item['url']
|
||||
if url.strip() == "":
|
||||
continue
|
||||
elif re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+onion(?:\/[a-zA-Z0-9]+)*\/?", url):
|
||||
elif re.search(torRegex, url):
|
||||
librarianList['tor'].append(url)
|
||||
elif re.search("https?:\/{2}(?:[a-zA-Z0-9]+\.)+i2p(?:\/[a-zA-Z0-9]+)*\/?", url):
|
||||
elif re.search(i2pRegex, url):
|
||||
librarianList['i2p'].append(url)
|
||||
elif re.search(lokiRegex, url):
|
||||
librarianList['loki'].append(url)
|
||||
else:
|
||||
librarianList['normal'].append(url)
|
||||
mightyList['librarian'] = librarianList
|
||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Librarian')
|
||||
|
||||
|
||||
def neuters():
|
||||
json_object = json.dumps(mightyList, ensure_ascii=False, indent=2)
|
||||
with open('./src/instances/neuters.json') as file:
|
||||
mightyList['neuters'] = json.load(file)
|
||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Neuters')
|
||||
|
||||
|
||||
def beatbump():
|
||||
json_object = json.dumps(mightyList, ensure_ascii=False, indent=2)
|
||||
with open('./src/instances/beatbump.json') as file:
|
||||
mightyList['beatbump'] = json.load(file)
|
||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Beatbump')
|
||||
|
||||
|
||||
def hyperpipe():
|
||||
r = requests.get(
|
||||
'https://codeberg.org/Hyperpipe/pages/raw/branch/main/api/frontend.json')
|
||||
rJson = json.loads(r.text)
|
||||
hyperpipeList = {}
|
||||
hyperpipeList['normal'] = []
|
||||
hyperpipeList['tor'] = []
|
||||
hyperpipeList['i2p'] = []
|
||||
hyperpipeList['loki'] = []
|
||||
for item in rJson:
|
||||
url = item['url']
|
||||
if url.strip() == "":
|
||||
continue
|
||||
elif re.search(torRegex, url):
|
||||
hyperpipeList['tor'].append(url)
|
||||
elif re.search(i2pRegex, url):
|
||||
hyperpipeList['i2p'].append(url)
|
||||
elif re.search(lokiRegex, url):
|
||||
hyperpipeList['loki'].append(url)
|
||||
else:
|
||||
hyperpipeList['normal'].append(url)
|
||||
mightyList['hyperpipe'] = hyperpipeList
|
||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Hyperpipe')
|
||||
|
||||
|
||||
def facil():
|
||||
json_object = json.dumps(mightyList, ensure_ascii=False, indent=2)
|
||||
with open('./src/instances/facil.json') as file:
|
||||
mightyList['facil'] = json.load(file)
|
||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'FacilMap')
|
||||
|
||||
|
||||
def peertube():
|
||||
r = requests.get(
|
||||
'https://instances.joinpeertube.org/api/v1/instances?start=0&count=1045&sort=-createdAt')
|
||||
|
@ -515,6 +608,7 @@ def isValid(url): # This code is contributed by avanitrachhadiya2155
|
|||
invidious()
|
||||
piped()
|
||||
pipedMaterial()
|
||||
cloudtube()
|
||||
proxitok()
|
||||
send()
|
||||
nitter()
|
||||
|
@ -532,6 +626,11 @@ whoogle()
|
|||
librex()
|
||||
rimgo()
|
||||
librarian()
|
||||
neuters()
|
||||
beatbump()
|
||||
hyperpipe()
|
||||
facil()
|
||||
simpleertube()
|
||||
mightyList = filterLastSlash(mightyList)
|
||||
|
||||
cloudflare = []
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"normal": ["https://neuters.de"],
|
||||
"tor": [],
|
||||
"i2p": [],
|
||||
"loki": []
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"normal": [
|
||||
"https://piped.kavin.rocks",
|
||||
"https://piped.tokhmi.xyz",
|
||||
"https://piped.moomoo.me",
|
||||
"https://il.ax",
|
||||
"https://piped.syncpundit.com",
|
||||
"https://piped.mha.fi",
|
||||
"https://piped.shimul.me",
|
||||
"https://pipedus.palash.dev/",
|
||||
"https://yt.jae.fi",
|
||||
"https://piped.mint.lgbt",
|
||||
"https://piped.privacy.com.de",
|
||||
"https://piped.esmailelbob.xyz"
|
||||
],
|
||||
"tor": [
|
||||
"http://piped2bbch4xslbl2ckr6k62q56kon56ffowxaqzy42ai22a4sash3ad.onion"
|
||||
],
|
||||
"i2p": [],
|
||||
"loki": []
|
||||
}
|
|
@ -1,81 +1,72 @@
|
|||
{
|
||||
"name": "__MSG_extensionName__",
|
||||
"description": "__MSG_extensionDescription__",
|
||||
"version": "2.2.1",
|
||||
"manifest_version": 2,
|
||||
"browser_specific_settings": {
|
||||
"gecko": {
|
||||
"id": "7esoorv3@alefvanoon.anonaddy.me",
|
||||
"strict_min_version": "67.0"
|
||||
}
|
||||
},
|
||||
"background": {
|
||||
"page": "pages/background/background.html",
|
||||
"persistent": true
|
||||
},
|
||||
"icons": {
|
||||
"16": "assets/images/libredirect-16.png",
|
||||
"32": "assets/images/libredirect-32.png",
|
||||
"48": "assets/images/libredirect-48.png",
|
||||
"128": "assets/images/libredirect-128.png"
|
||||
},
|
||||
"permissions": [
|
||||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
"storage",
|
||||
"unlimitedStorage",
|
||||
"cookies",
|
||||
"clipboardWrite",
|
||||
"contextMenus",
|
||||
"<all_urls>"
|
||||
],
|
||||
"browser_action": {
|
||||
"default_title": "__MSG_extensionName__",
|
||||
"browser_style": false,
|
||||
"default_popup": "pages/popup/popup.html",
|
||||
"default_icon": {
|
||||
"16": "assets/images/libredirect-16.png",
|
||||
"32": "assets/images/libredirect-32.png",
|
||||
"48": "assets/images/libredirect-48.png",
|
||||
"128": "assets/images/libredirect-128.png"
|
||||
}
|
||||
},
|
||||
"options_ui": {
|
||||
"page": "pages/options/index.html",
|
||||
"browser_style": false,
|
||||
"open_in_tab": true
|
||||
},
|
||||
"chrome_settings_overrides": {
|
||||
"search_provider": {
|
||||
"name": "__MSG_extensionName__",
|
||||
"keyword": "libredirect",
|
||||
"favicon_url": "https://raw.githubusercontent.com/libredirect/libredirect/master/src/assets/images/libredirect-16.png",
|
||||
"search_url": "https://search.libredirect.invalid/?q={searchTerms}",
|
||||
"encoding": "UTF-8",
|
||||
"is_default": false
|
||||
}
|
||||
},
|
||||
"commands": {
|
||||
"switchInstance": {
|
||||
"suggested_key": {
|
||||
"default": "Alt+Shift+L"
|
||||
},
|
||||
"description": "__MSG_switchInstance__"
|
||||
},
|
||||
"copyRaw": {
|
||||
"suggested_key": {
|
||||
"default": "Alt+Shift+C"
|
||||
},
|
||||
"description": "Copies the original link. Ex: Copies the original twitter link while in the nitter website"
|
||||
},
|
||||
"unify": {
|
||||
"suggested_key": {
|
||||
"default": "Alt+Shift+U"
|
||||
},
|
||||
"description": "Copies the preferences (cookies, localStorage) from the current opened instance and copy them to all the other selected instances"
|
||||
}
|
||||
},
|
||||
"default_locale": "en",
|
||||
"update_url": "https://raw.githubusercontent.com/libredirect/libredirect/master/src/updates/updates.xml",
|
||||
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAroWDSoSRZ1scj+eJRrvnhJbrqXTKnhQuxs6+AJg16sqr0bsMdFV+MSY4i4xnK+K5WOYkBliWXgUyk/wzicoAjOnSJddrL/Md4FuWHI2NVIkrlsLOrYkygi5OLqGPajRH/w8Cdmg7KzEpXe/OnYV0/qS8li8huEdTzdeLdhfbiVl1j3DOr4OJALQ7mPeeNFHFo/oVQ+OkSezWLezA5jUGfhtzPYV6u1TXzX7lCi8E/BbDbwkvvXOMcjXCv08kjdLOY2djCA2a6zr0xAb3q8DlexAMZ8vMof7AQRFtBKhLc9n9VFoipMMdBOVQQj/eIcRILBrmkcZNnJxFKiHNJ+NcZQIDAQAB"
|
||||
}
|
||||
"name": "__MSG_extensionName__",
|
||||
"description": "__MSG_extensionDescription__",
|
||||
"version": "2.2.1",
|
||||
"manifest_version": 2,
|
||||
"browser_specific_settings": {
|
||||
"gecko": {
|
||||
"id": "7esoorv3@alefvanoon.anonaddy.me",
|
||||
"strict_min_version": "67.0"
|
||||
}
|
||||
},
|
||||
"background": {
|
||||
"page": "pages/background/background.html",
|
||||
"persistent": true
|
||||
},
|
||||
"icons": {
|
||||
"16": "assets/images/libredirect-16.png",
|
||||
"32": "assets/images/libredirect-32.png",
|
||||
"48": "assets/images/libredirect-48.png",
|
||||
"128": "assets/images/libredirect-128.png"
|
||||
},
|
||||
"permissions": ["webRequest", "webRequestBlocking", "storage", "unlimitedStorage", "cookies", "clipboardWrite", "contextMenus", "<all_urls>"],
|
||||
"browser_action": {
|
||||
"default_title": "__MSG_extensionName__",
|
||||
"browser_style": false,
|
||||
"default_popup": "pages/popup/popup.html",
|
||||
"default_icon": {
|
||||
"16": "assets/images/libredirect-16.png",
|
||||
"32": "assets/images/libredirect-32.png",
|
||||
"48": "assets/images/libredirect-48.png",
|
||||
"128": "assets/images/libredirect-128.png"
|
||||
}
|
||||
},
|
||||
"options_ui": {
|
||||
"page": "pages/options/index.html",
|
||||
"browser_style": false,
|
||||
"open_in_tab": true
|
||||
},
|
||||
"chrome_settings_overrides": {
|
||||
"search_provider": {
|
||||
"name": "__MSG_extensionName__",
|
||||
"keyword": "libredirect",
|
||||
"favicon_url": "https://raw.githubusercontent.com/libredirect/libredirect/master/src/assets/images/libredirect-16.png",
|
||||
"search_url": "https://search.libredirect.invalid/?q={searchTerms}",
|
||||
"encoding": "UTF-8",
|
||||
"is_default": false
|
||||
}
|
||||
},
|
||||
"commands": {
|
||||
"switchInstance": {
|
||||
"suggested_key": {
|
||||
"default": "Alt+Shift+L"
|
||||
},
|
||||
"description": "__MSG_switchInstance__"
|
||||
},
|
||||
"copyRaw": {
|
||||
"suggested_key": {
|
||||
"default": "Alt+Shift+C"
|
||||
},
|
||||
"description": "Copies the original link. Ex: Copies the original twitter link while in the nitter website"
|
||||
},
|
||||
"unify": {
|
||||
"suggested_key": {
|
||||
"default": "Alt+Shift+U"
|
||||
},
|
||||
"description": "Copies the preferences (cookies, localStorage) from the current opened instance and copy them to all the other selected instances"
|
||||
}
|
||||
},
|
||||
"default_locale": "en",
|
||||
"update_url": "https://raw.githubusercontent.com/libredirect/libredirect/master/src/updates/updates.xml",
|
||||
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAroWDSoSRZ1scj+eJRrvnhJbrqXTKnhQuxs6+AJg16sqr0bsMdFV+MSY4i4xnK+K5WOYkBliWXgUyk/wzicoAjOnSJddrL/Md4FuWHI2NVIkrlsLOrYkygi5OLqGPajRH/w8Cdmg7KzEpXe/OnYV0/qS8li8huEdTzdeLdhfbiVl1j3DOr4OJALQ7mPeeNFHFo/oVQ+OkSezWLezA5jUGfhtzPYV6u1TXzX7lCi8E/BbDbwkvvXOMcjXCv08kjdLOY2djCA2a6zr0xAb3q8DlexAMZ8vMof7AQRFtBKhLc9n9VFoipMMdBOVQQj/eIcRILBrmkcZNnJxFKiHNJ+NcZQIDAQAB"
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<script type="module" src="background.js"></script>
|
||||
</head>
|
||||
|
||||
</html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<script type="module" src="background.js"></script>
|
||||
</head>
|
||||
</html>
|
||||
|
|
|
@ -1,263 +1,252 @@
|
|||
"use strict";
|
||||
"use strict"
|
||||
|
||||
import generalHelper from "../../assets/javascripts/general.js";
|
||||
import utils from "../../assets/javascripts/utils.js";
|
||||
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";
|
||||
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
|
||||
|
||||
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()
|
||||
|
||||
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();
|
||||
// }
|
||||
})
|
||||
|
||||
// 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"]
|
||||
)
|
||||
|
||||
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"]
|
||||
);
|
||||
|
||||
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);
|
||||
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++;
|
||||
}
|
||||
}
|
||||
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"]
|
||||
});
|
||||
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.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 })
|
||||
|
|
|
@ -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>
|
||||
<body>
|
||||
<div>
|
||||
<p>Initializing Cookies...</p>
|
||||
</div>
|
||||
<script type="module" src="incognito.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
<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 {
|
||||
width: 80%;
|
||||
}
|
||||
div.logo {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
div.logo {
|
||||
display: flex;
|
||||
}
|
||||
img {
|
||||
width: 90px;
|
||||
height: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
img {
|
||||
width: 90px;
|
||||
height: auto;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<div>
|
||||
<div class="logo">
|
||||
<img src="/assets/images/libredirect.svg" alt="LibRedirect icon" />
|
||||
<h1>LibRedirect</h1>
|
||||
</div>
|
||||
|
||||
</head>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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>
|
||||
<script src="instance_offline.js" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -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) }
|
||||
);
|
||||
|
||||
let number = document.getElementById("number");
|
||||
setTimeout(() => number.innerHTML = '1', 1000);
|
||||
setTimeout(
|
||||
() => {
|
||||
number.innerHTML = '0'
|
||||
if (!isCanceled) window.location = params.url;
|
||||
},
|
||||
2000
|
||||
);
|
||||
|
||||
let isCanceled = false;
|
||||
document.getElementById("cancel").addEventListener("click", () => {
|
||||
isCanceled = true;
|
||||
document.getElementById("message").innerHTML = browser.i18n.getMessage('redirectionCanceled');
|
||||
const params = new Proxy(new URLSearchParams(window.location.search), {
|
||||
get: (searchParams, prop) => searchParams.get(prop),
|
||||
})
|
||||
|
||||
localise.localisePage();
|
||||
let number = document.getElementById("number")
|
||||
setTimeout(() => (number.innerHTML = "1"), 1000)
|
||||
setTimeout(() => {
|
||||
number.innerHTML = "0"
|
||||
if (!isCanceled) window.location = params.url
|
||||
}, 2000)
|
||||
|
||||
let isCanceled = false
|
||||
document.getElementById("cancel").addEventListener("click", () => {
|
||||
isCanceled = true
|
||||
document.getElementById("message").innerHTML = browser.i18n.getMessage("redirectionCanceled")
|
||||
})
|
||||
|
||||
localise.localisePage()
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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');
|
||||
if (r) loadPage(r[1])
|
||||
else loadPage("general")
|
||||
|
|
|
@ -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)
|
||||
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", changeTheme)
|
||||
|
|
|
@ -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();
|
||||
exportSettings()
|
||||
|
||||
document.getElementById('general_page').addEventListener('click', exportSettings)
|
||||
document.getElementById("general_page").addEventListener("click", 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();
|
||||
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 translateHelper.pasteSimplyTranslateCookies();
|
||||
await translateHelper.pasteLingvaLocalStorage();
|
||||
await translateHelper.pasteSimplyTranslateCookies()
|
||||
await translateHelper.pasteLingvaLocalStorage()
|
||||
|
||||
await twitterHelper.pasteNitterCookies();
|
||||
await twitterHelper.pasteNitterCookies()
|
||||
|
||||
await wikipediaHelper.pasteWikilessCookies();
|
||||
await wikipediaHelper.pasteWikilessCookies()
|
||||
|
||||
await searchHelper.pasteSearxCookies();
|
||||
await searchHelper.pasteSearxngCookies();
|
||||
await searchHelper.pasteLibrexCookies();
|
||||
await searchHelper.pasteSearxCookies()
|
||||
await searchHelper.pasteSearxngCookies()
|
||||
await searchHelper.pasteLibrexCookies()
|
||||
|
||||
await redditHelper.pasteLibredditCookies();
|
||||
await redditHelper.pasteTedditCookies();
|
||||
await redditHelper.pasteLibredditCookies()
|
||||
await redditHelper.pasteTedditCookies()
|
||||
|
||||
await tiktokHelper.pasteProxiTokCookies();
|
||||
await tiktokHelper.pasteProxiTokCookies()
|
||||
|
||||
location.reload();
|
||||
})
|
||||
|
||||
});
|
||||
} 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 })
|
||||
});
|
||||
|
||||
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();
|
||||
browser.storage.local.set({ autoRedirect: event.target.checked })
|
||||
})
|
||||
|
||||
let protocolElement = document.getElementById("protocol");
|
||||
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()
|
||||
})
|
||||
|
||||
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;
|
||||
[
|
||||
"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';
|
||||
}
|
||||
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)
|
||||
})
|
||||
}
|
||||
)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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("librarian")
|
||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||
|
||||
const enable = document.getElementById("lbry-enable");
|
||||
const lbry = document.getElementById('lbry_page');
|
||||
const enable = document.getElementById("lbry-enable")
|
||||
const lbry = document.getElementById("lbry_page")
|
||||
//const frontend = document.getElementById("lbry-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(
|
||||
[
|
||||
"disableLbryTargets",
|
||||
"protocol"
|
||||
],
|
||||
r => {
|
||||
enable.checked = !r.disableLbryTargets;
|
||||
protocol = r.protocol;
|
||||
changeProtocolSettings();
|
||||
}
|
||||
)
|
||||
browser.storage.local.get(["disableLbryTargets", "protocol"], r => {
|
||||
enable.checked = !r.disableLbryTargets
|
||||
protocol = r.protocol
|
||||
changeProtocolSettings()
|
||||
})
|
||||
|
||||
lbry.addEventListener("change", () => {
|
||||
browser.storage.local.set({ disableLbryTargets: !enable.checked });
|
||||
browser.storage.local.set({ disableLbryTargets: !enable.checked })
|
||||
})
|
||||
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
browser.storage.local.get(["disableSearch", "searchFrontend", "protocol"], r => {
|
||||
enable.checked = !r.disableSearch
|
||||
frontend.value = r.searchFrontend
|
||||
protocol = r.protocol
|
||||
|
||||
changeFrontendsSettings();
|
||||
changeProtocolSettings();
|
||||
}
|
||||
);
|
||||
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()
|
||||
})
|
||||
|
||||
/*
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -1,103 +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;
|
||||
youtubeEmbedFrontend.value = r.youtubeEmbedFrontend;
|
||||
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,
|
||||
youtubeFrontend: frontend.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)
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -1,337 +1,445 @@
|
|||
"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 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 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')
|
||||
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;
|
||||
[
|
||||
"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")
|
||||
}
|
||||
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;
|
||||
}
|
||||
let url
|
||||
try {
|
||||
url = new URL(tabs[0].url)
|
||||
} catch {
|
||||
currentSiteIsFrontend.classList.add("hide")
|
||||
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");
|
||||
} else {
|
||||
currentSiteIsFrontend.classList.add("hide")
|
||||
}
|
||||
})
|
||||
}
|
||||
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 })
|
||||
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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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 })
|
||||
})
|
||||
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()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
height: 10px;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
width: auto;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
module.exports = {
|
||||
ignoreFiles: [
|
||||
"instances/get_instances.py"
|
||||
],
|
||||
};
|
||||
ignoreFiles: ["instances/get_instances.py"],
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue