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:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [master]
|
||||||
pull_request:
|
pull_request:
|
||||||
# The branches below must be a subset of the branches above
|
# The branches below must be a subset of the branches above
|
||||||
branches: [ master ]
|
branches: [master]
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '43 18 * * 3'
|
- cron: "43 18 * * 3"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
analyze:
|
analyze:
|
||||||
|
@ -32,39 +32,39 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
language: [ 'javascript' ]
|
language: ["javascript"]
|
||||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||||
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v1
|
uses: github/codeql-action/init@v1
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
# 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.
|
# 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.
|
# 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
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# 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)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v1
|
uses: github/codeql-action/autobuild@v1
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
# ✏️ 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
|
# and modify them (or add more) to build your code if your project
|
||||||
# uses a compiled language
|
# uses a compiled language
|
||||||
|
|
||||||
#- run: |
|
#- run: |
|
||||||
# make bootstrap
|
# make bootstrap
|
||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v1
|
uses: github/codeql-action/analyze@v1
|
||||||
|
|
|
@ -2,21 +2,21 @@ name: instances-updater
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '10 22 */3 * *'
|
- cron: "10 22 */3 * *"
|
||||||
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: get repo content
|
- name: get repo content
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: setup python
|
- name: setup python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: '3.8' # install the python version needed
|
python-version: "3.8" # install the python version needed
|
||||||
|
|
||||||
- name: install python packages
|
- name: install python packages
|
||||||
run: |
|
run: |
|
||||||
|
@ -24,7 +24,7 @@ jobs:
|
||||||
pip install requests bs4 colorama
|
pip install requests bs4 colorama
|
||||||
- name: run script
|
- name: run script
|
||||||
run: python src/instances/get_instances.py
|
run: python src/instances/get_instances.py
|
||||||
|
|
||||||
- name: commit files
|
- name: commit files
|
||||||
run: |
|
run: |
|
||||||
git config --local user.email "action@github.com"
|
git config --local user.email "action@github.com"
|
||||||
|
|
|
@ -9,6 +9,6 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: '16'
|
node-version: "16"
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm test
|
- 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
|
## Data collected
|
||||||
* LibRedirect does not collect any Personal Information of any kind.
|
|
||||||
* LibRedirect doesn't embed any kind of analytics in its code.
|
- LibRedirect does not collect any Personal Information of any kind.
|
||||||
* All aspects of the extension work locally in your browser, with the exception of
|
- LibRedirect doesn't embed any kind of analytics in its code.
|
||||||
OpenStreetMap (OSM) reverse geocoding, done via the [OSM Nomantim API](https://nominatim.org/release-docs/develop/api/Overview/),
|
- All aspects of the extension work locally in your browser, with the exception of
|
||||||
used as part of OSM redirects, which can be disabled by toggling the OSM redirects.
|
OpenStreetMap (OSM) reverse geocoding, done via the [OSM Nomantim API](https://nominatim.org/release-docs/develop/api/Overview/),
|
||||||
* 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.
|
used as part of OSM redirects, which can be disabled by toggling the OSM redirects.
|
||||||
* 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.
|
- 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
|
## Future Changes
|
||||||
|
|
||||||
If we decide to change our privacy policy, we will post those changes on this page.
|
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/)
|
[![Firefox Add-on](./img/badge-amo.png)](https://addons.mozilla.org/firefox/addon/libredirect/)
|
||||||
<a href="https://microsoftedge.microsoft.com/addons/detail/libredirect/aodffkeankebfonljgbcfbbaljopcpdb">
|
<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>
|
||||||
<a href="./chromium.md">
|
<a href="./chromium.md">
|
||||||
<img src ="./img/badge-chromium.png" height=60 >
|
<img src ="./img/badge-chromium.png" height=60 >
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<img src ="./img/1.png" width=350>
|
<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)
|
[FAQ](https://libredirect.github.io/faq.html)
|
||||||
|
|
||||||
## Donate
|
## Donate
|
||||||
|
|
||||||
[![Liberapay](./img/liberapay.svg)](https://liberapay.com/LibRedirect)
|
[![Liberapay](./img/liberapay.svg)](https://liberapay.com/LibRedirect)
|
||||||
[![Patreon](./img/patreon.svg)](https://patreon.com/LibRedirect)
|
[![Patreon](./img/patreon.svg)](https://patreon.com/LibRedirect)
|
||||||
[![Buy me a coffee](./img/bmc.svg)](https://www.buymeacoffee.com/libredirect)
|
[![Buy me a coffee](./img/bmc.svg)](https://www.buymeacoffee.com/libredirect)
|
||||||
|
@ -52,47 +53,59 @@ ETH: 0x896E5796Da76E49A400A9186E1c459CD2C64b4E8\
|
||||||
XMR: 4AM5CVfaGsnEXQQjZSzJvaWufe7pT86ubcZPr83fCjb2Hn3iwcForTWFy2Z3ugXcufUwHaGcucfPMFgPXBFSYGFvNrmV5XR
|
XMR: 4AM5CVfaGsnEXQQjZSzJvaWufe7pT86ubcZPr83fCjb2Hn3iwcForTWFy2Z3ugXcufUwHaGcucfPMFgPXBFSYGFvNrmV5XR
|
||||||
|
|
||||||
## Mirror Repos
|
## Mirror Repos
|
||||||
|
|
||||||
[![GitHub](https://raw.githubusercontent.com/ManeraKai/manerakai/main/icons/github.svg)](https://github.com/libredirect/libredirect/)
|
[![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)
|
[![Codeberg](https://raw.githubusercontent.com/ManeraKai/manerakai/main/icons/codeberg.svg)](https://codeberg.org/LibRedirect/libredirect)
|
||||||
|
|
||||||
## Translate
|
## Translate
|
||||||
|
|
||||||
[![Weblate](./img/weblate.svg)](https://hosted.weblate.org/projects/libredirect/extension)
|
[![Weblate](./img/weblate.svg)](https://hosted.weblate.org/projects/libredirect/extension)
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
### Install Dependencies
|
### Install Dependencies
|
||||||
|
|
||||||
[Node.js](https://nodejs.org/) latest LTS is recommended
|
[Node.js](https://nodejs.org/) latest LTS is recommended
|
||||||
|
|
||||||
```
|
```
|
||||||
npm update
|
npm update
|
||||||
npm install
|
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):
|
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
|
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
|
### Build
|
||||||
|
|
||||||
```
|
```
|
||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
### Test
|
### Test
|
||||||
|
|
||||||
```
|
```
|
||||||
npm run test
|
npm run test
|
||||||
```
|
```
|
||||||
|
|
||||||
### Test in Firefox
|
### Test in Firefox
|
||||||
|
|
||||||
```
|
```
|
||||||
npm run start
|
npm run start
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install temporarily
|
### Install temporarily
|
||||||
|
|
||||||
open `about:addons`\
|
open `about:addons`\
|
||||||
click on the settings button below the addon search bar and select `debug add-on`\
|
click on the settings button below the addon search bar and select `debug add-on`\
|
||||||
press `load temporarily addon`
|
press `load temporarily addon`
|
||||||
|
|
||||||
### Install in Firefox ESR, Developer Edition, Nightly
|
### Install in Firefox ESR, Developer Edition, Nightly
|
||||||
|
|
||||||
open `about:config`\
|
open `about:config`\
|
||||||
set `xpinstall.signatures.required` to `false`\
|
set `xpinstall.signatures.required` to `false`\
|
||||||
open `about:addons`\
|
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
|
select `libredirect-VERSION.zip` from `web-ext-artifacts` folder
|
||||||
|
|
||||||
### Install in Chromium browsers
|
### Install in Chromium browsers
|
||||||
|
|
||||||
open `chrome://extensions`\
|
open `chrome://extensions`\
|
||||||
enable `dev mode`\
|
enable `dev mode`\
|
||||||
select `load unpacked extension`\
|
select `load unpacked extension`\
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
## Linux
|
## 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)
|
- 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`
|
- Open `chrome://extensions`
|
||||||
- Enable `dev mode`
|
- Enable `dev mode`
|
||||||
|
@ -8,6 +9,7 @@
|
||||||
Updates are automatic
|
Updates are automatic
|
||||||
|
|
||||||
## Windows, MacOS
|
## 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)
|
- 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`
|
- Unzip it with `Auto detect subfolder`
|
||||||
- Open `chrome://extensions`
|
- Open `chrome://extensions`
|
||||||
|
|
58
package.json
58
package.json
|
@ -1,29 +1,33 @@
|
||||||
{
|
{
|
||||||
"name": "libredirect",
|
"name": "libredirect",
|
||||||
"description": "Redirects YouTube, Twitter, Instagram and more to privacy friendly frontends.",
|
"description": "Redirects YouTube, Twitter, Instagram and more to privacy friendly frontends.",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16.13.1",
|
"node": ">=16.13.1",
|
||||||
"npm": ">=8.1.2"
|
"npm": ">=8.1.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "web-ext run --browser-console --source-dir ./src/",
|
"start": "web-ext run --browser-console --source-dir ./src/",
|
||||||
"build": "web-ext build --overwrite-dest --source-dir ./src/",
|
"build": "web-ext build --overwrite-dest --source-dir ./src/",
|
||||||
"test": "web-ext lint --source-dir ./src/ || true"
|
"test": "web-ext lint --source-dir ./src/ || true",
|
||||||
},
|
"pug": "pug ./src/pages/options/*.pug ./src/pages/popup/ -P -w",
|
||||||
"repository": {
|
"prettier": "npx prettier --write .",
|
||||||
"type": "git",
|
"instances": "python3 src/instances/get_instances.py; git update-index --assume-unchanged src/instances/blacklist.json src/instances/data.json"
|
||||||
"url": "git+https://github.com/LibRedirect/LibRedirect.git"
|
},
|
||||||
},
|
"repository": {
|
||||||
"author": "LibRedirect",
|
"type": "git",
|
||||||
"license": "GPL-3.0-only",
|
"url": "git+https://github.com/LibRedirect/LibRedirect.git"
|
||||||
"bugs": {
|
},
|
||||||
"url": "https://github.com/LibRedirect/LibRedirect/issues"
|
"author": "LibRedirect",
|
||||||
},
|
"license": "GPL-3.0-only",
|
||||||
"homepage": "https://github.com/LibRedirect/LibRedirect",
|
"bugs": {
|
||||||
"devDependencies": {
|
"url": "https://github.com/LibRedirect/LibRedirect/issues"
|
||||||
"web-ext": "^6.7.0"
|
},
|
||||||
},
|
"homepage": "https://github.com/LibRedirect/LibRedirect",
|
||||||
"dependencies": {
|
"devDependencies": {
|
||||||
"buffer": "^6.0.3"
|
"prettier": "2.7.1",
|
||||||
}
|
"web-ext": "^6.7.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"buffer": "^6.0.3"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,78 +1,66 @@
|
||||||
"use strict";
|
"use strict"
|
||||||
window.browser = window.browser || window.chrome;
|
window.browser = window.browser || window.chrome
|
||||||
|
|
||||||
function isException(url) {
|
function isException(url) {
|
||||||
for (const item of exceptions.url)
|
for (const item of exceptions.url) if (item == `${url.protocol}//${url.host}`) return true
|
||||||
if (item == `${url.protocol}//${url.host}`) return true;
|
for (const item of exceptions.regex) if (new RegExp(item).test(url.href)) return true
|
||||||
for (const item of exceptions.regex)
|
return false
|
||||||
if (new RegExp(item).test(url.href)) return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let exceptions;
|
let exceptions
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get("exceptions", r => {
|
||||||
'exceptions',
|
exceptions = r.exceptions
|
||||||
r => {
|
})
|
||||||
exceptions = r.exceptions;
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
async function initDefaults() {
|
async function initDefaults() {
|
||||||
return new Promise(resolve =>
|
return new Promise(resolve =>
|
||||||
browser.storage.local.set({
|
browser.storage.local.set(
|
||||||
exceptions: {
|
{
|
||||||
"url": [],
|
exceptions: {
|
||||||
"regex": [],
|
url: [],
|
||||||
},
|
regex: [],
|
||||||
theme: "DEFAULT",
|
},
|
||||||
popupFrontends: [
|
theme: "DEFAULT",
|
||||||
"youtube",
|
popupFrontends: ["youtube", "twitter", "instagram", "tiktok", "imgur", "reddit", "quora", "translate", "maps"],
|
||||||
"twitter",
|
autoRedirect: false,
|
||||||
"instagram",
|
firstPartyIsolate: false,
|
||||||
"tiktok",
|
protocol: "normal",
|
||||||
"imgur",
|
protocolFallback: true,
|
||||||
"reddit",
|
},
|
||||||
"quora",
|
() => resolve()
|
||||||
"translate",
|
)
|
||||||
"maps",
|
)
|
||||||
],
|
|
||||||
autoRedirect: false,
|
|
||||||
firstPartyIsolate: false,
|
|
||||||
protocol: "normal",
|
|
||||||
protocolFallback: true
|
|
||||||
}, () => resolve())
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const allPopupFrontends = [
|
const allPopupFrontends = [
|
||||||
"youtube",
|
"youtube",
|
||||||
"youtubeMusic",
|
"youtubeMusic",
|
||||||
"twitter",
|
"twitter",
|
||||||
"instagram",
|
"instagram",
|
||||||
"tiktok",
|
"tiktok",
|
||||||
"imgur",
|
"imgur",
|
||||||
"reddit",
|
"reddit",
|
||||||
"search",
|
"search",
|
||||||
"translate",
|
"translate",
|
||||||
"maps",
|
"maps",
|
||||||
"wikipedia",
|
"wikipedia",
|
||||||
"medium",
|
"medium",
|
||||||
"quora",
|
"quora",
|
||||||
"imdb",
|
"imdb",
|
||||||
"reuters",
|
"reuters",
|
||||||
"peertube",
|
"peertube",
|
||||||
"lbry",
|
"lbry",
|
||||||
"sendTargets"
|
"sendTargets",
|
||||||
];
|
]
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
isException,
|
isException,
|
||||||
initDefaults,
|
initDefaults,
|
||||||
allPopupFrontends,
|
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 = [
|
const targets = [/^https?:\/{2}(?:www\.|)imdb\.com.*/]
|
||||||
/^https?:\/{2}(?:www\.|)imdb\.com.*/
|
|
||||||
];
|
|
||||||
|
|
||||||
const frontends = new Array("libremdb")
|
const frontends = new Array("libremdb")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
@ -12,182 +10,197 @@ const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
let redirects = {}
|
let redirects = {}
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
redirects[frontends[i]] = {}
|
redirects[frontends[i]] = {}
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
redirects[frontends[i]][protocols[x]] = []
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRedirects(val) {
|
function setRedirects(val) {
|
||||||
browser.storage.local.get('cloudflareBlackList', r => {
|
browser.storage.local.get("cloudflareBlackList", r => {
|
||||||
redirects.libremdb = val;
|
redirects.libremdb = val
|
||||||
libremdbNormalRedirectsChecks = [...redirects.libremdb.normal];
|
libremdbNormalRedirectsChecks = [...redirects.libremdb.normal]
|
||||||
for (const instance of r.cloudflareBlackList) {
|
for (const instance of r.cloudflareBlackList) {
|
||||||
const a = libremdbNormalRedirectsChecks.indexOf(instance);
|
const a = libremdbNormalRedirectsChecks.indexOf(instance)
|
||||||
if (a > -1) libremdbNormalRedirectsChecks.splice(a, 1);
|
if (a > -1) libremdbNormalRedirectsChecks.splice(a, 1)
|
||||||
}
|
}
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
imdbRedirects: redirects,
|
imdbRedirects: redirects,
|
||||||
libremdbNormalRedirectsChecks
|
libremdbNormalRedirectsChecks,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let disableImdb,
|
||||||
disableImdb,
|
protocol,
|
||||||
protocol,
|
protocolFallback,
|
||||||
protocolFallback,
|
imdbRedirects,
|
||||||
imdbRedirects,
|
libremdbNormalRedirectsChecks,
|
||||||
libremdbNormalRedirectsChecks,
|
libremdbNormalCustomRedirects,
|
||||||
libremdbNormalCustomRedirects,
|
libremdbTorRedirectsChecks,
|
||||||
libremdbTorRedirectsChecks,
|
libremdbTorCustomRedirects,
|
||||||
libremdbTorCustomRedirects,
|
libremdbI2pCustomRedirects,
|
||||||
libremdbI2pCustomRedirects,
|
libremdbLokiCustomRedirects
|
||||||
libremdbLokiCustomRedirects;
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disableImdb",
|
"disableImdb",
|
||||||
"protocol",
|
"protocol",
|
||||||
"protocolFallback",
|
"protocolFallback",
|
||||||
"imdbRedirects",
|
"imdbRedirects",
|
||||||
"libremdbNormalRedirectsChecks",
|
"libremdbNormalRedirectsChecks",
|
||||||
"libremdbNormalCustomRedirects",
|
"libremdbNormalCustomRedirects",
|
||||||
"libremdbTorRedirectsChecks",
|
"libremdbTorRedirectsChecks",
|
||||||
"libremdbTorCustomRedirects",
|
"libremdbTorCustomRedirects",
|
||||||
"libremdbI2pCustomRedirects",
|
"libremdbI2pCustomRedirects",
|
||||||
"libremdbLokiCustomRedirects"
|
"libremdbLokiCustomRedirects",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
disableImdb = r.disableImdb;
|
disableImdb = r.disableImdb
|
||||||
protocol = r.protocol;
|
protocol = r.protocol
|
||||||
protocolFallback = r.protocolFallback;
|
protocolFallback = r.protocolFallback
|
||||||
imdbRedirects = r.imdbRedirects;
|
imdbRedirects = r.imdbRedirects
|
||||||
libremdbNormalRedirectsChecks = r.libremdbNormalRedirectsChecks;
|
libremdbNormalRedirectsChecks = r.libremdbNormalRedirectsChecks
|
||||||
libremdbNormalCustomRedirects = r.libremdbNormalCustomRedirects;
|
libremdbNormalCustomRedirects = r.libremdbNormalCustomRedirects
|
||||||
libremdbTorRedirectsChecks = r.libremdbTorRedirectsChecks;
|
libremdbTorRedirectsChecks = r.libremdbTorRedirectsChecks
|
||||||
libremdbTorCustomRedirects = r.libremdbTorCustomRedirects;
|
libremdbTorCustomRedirects = r.libremdbTorCustomRedirects
|
||||||
libremdbI2pCustomRedirects = r.libremdbI2pCustomRedirects;
|
libremdbI2pCustomRedirects = r.libremdbI2pCustomRedirects
|
||||||
libremdbLokiCustomRedirects = r.libremdbLokiCustomRedirects;
|
libremdbLokiCustomRedirects = r.libremdbLokiCustomRedirects
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
function redirect(url, type, initiator, disableOverride) {
|
function redirect(url, type, initiator, disableOverride) {
|
||||||
if (disableImdb && !disableOverride) return;
|
if (disableImdb && !disableOverride) return
|
||||||
if (url.pathname == "/") return;
|
if (url.pathname == "/") return
|
||||||
if (type != "main_frame") return;
|
if (type != "main_frame") return
|
||||||
const all = [
|
const all = [...imdbRedirects.libremdb.normal, ...libremdbNormalCustomRedirects]
|
||||||
...imdbRedirects.libremdb.normal,
|
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return
|
||||||
...libremdbNormalCustomRedirects
|
if (!targets.some(rx => rx.test(url.href))) return
|
||||||
];
|
|
||||||
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return;
|
|
||||||
if (!targets.some(rx => rx.test(url.href))) return;
|
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...libremdbLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...libremdbLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...libremdbI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...libremdbI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...libremdbNormalRedirectsChecks, ...libremdbNormalCustomRedirects];
|
instancesList = [...libremdbNormalRedirectsChecks, ...libremdbNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) { return; }
|
if (instancesList.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
return `${randomInstance}${url.pathname}`;
|
return `${randomInstance}${url.pathname}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function reverse(url) {
|
function reverse(url) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
let protocolHost = utils.protocolHost(url);
|
let protocolHost = utils.protocolHost(url)
|
||||||
const all = [
|
const all = [
|
||||||
...imdbRedirects.libremdb.normal,
|
...imdbRedirects.libremdb.normal,
|
||||||
...imdbRedirects.libremdb.tor,
|
...imdbRedirects.libremdb.tor,
|
||||||
...libremdbNormalCustomRedirects,
|
...libremdbNormalCustomRedirects,
|
||||||
...libremdbTorCustomRedirects,
|
...libremdbTorCustomRedirects,
|
||||||
...libremdbI2pCustomRedirects,
|
...libremdbI2pCustomRedirects,
|
||||||
...libremdbLokiCustomRedirects
|
...libremdbLokiCustomRedirects,
|
||||||
];
|
]
|
||||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
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) {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableImdb && !disableOverride) { resolve(); return; }
|
if (disableImdb && !disableOverride) {
|
||||||
let protocolHost = utils.protocolHost(url);
|
resolve()
|
||||||
const all = [
|
return
|
||||||
...imdbRedirects.libremdb.tor,
|
}
|
||||||
...imdbRedirects.libremdb.normal,
|
let protocolHost = utils.protocolHost(url)
|
||||||
|
const all = [
|
||||||
|
...imdbRedirects.libremdb.tor,
|
||||||
|
...imdbRedirects.libremdb.normal,
|
||||||
|
|
||||||
...libremdbNormalCustomRedirects,
|
...libremdbNormalCustomRedirects,
|
||||||
...libremdbTorCustomRedirects,
|
...libremdbTorCustomRedirects,
|
||||||
...libremdbI2pCustomRedirects,
|
...libremdbI2pCustomRedirects,
|
||||||
...libremdbLokiCustomRedirects
|
...libremdbLokiCustomRedirects,
|
||||||
];
|
]
|
||||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
if (!all.includes(protocolHost)) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...libremdbLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...libremdbLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...libremdbI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...libremdbI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...libremdbTorRedirectsChecks, ...libremdbTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...libremdbNormalRedirectsChecks, ...libremdbNormalCustomRedirects];
|
instancesList = [...libremdbNormalRedirectsChecks, ...libremdbNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
|
|
||||||
const i = instancesList.indexOf(protocolHost);
|
const i = instancesList.indexOf(protocolHost)
|
||||||
if (i > -1) instancesList.splice(i, 1);
|
if (i > -1) instancesList.splice(i, 1)
|
||||||
if (instancesList.length === 0) { resolve(); return; }
|
if (instancesList.length === 0) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaults() {
|
function initDefaults() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
fetch("/instances/data.json")
|
||||||
let dataJson = JSON.parse(data);
|
.then(response => response.text())
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
.then(async data => {
|
||||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
let dataJson = JSON.parse(data)
|
||||||
}
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
browser.storage.local.set({
|
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||||
disableImdb: true,
|
}
|
||||||
imdbRedirects: redirects,
|
browser.storage.local.set(
|
||||||
|
{
|
||||||
|
disableImdb: true,
|
||||||
|
imdbRedirects: redirects,
|
||||||
|
|
||||||
libremdbNormalRedirectsChecks: [...redirects.libremdb.normal],
|
libremdbNormalRedirectsChecks: [...redirects.libremdb.normal],
|
||||||
libremdbNormalCustomRedirects: [],
|
libremdbNormalCustomRedirects: [],
|
||||||
|
|
||||||
libremdbTorRedirectsChecks: [...redirects.libremdb.tor],
|
libremdbTorRedirectsChecks: [...redirects.libremdb.tor],
|
||||||
libremdbTorCustomRedirects: [],
|
libremdbTorCustomRedirects: [],
|
||||||
|
|
||||||
libremdbI2pRedirectsChecks: [],
|
libremdbI2pRedirectsChecks: [],
|
||||||
libremdbI2pCustomRedirects: [],
|
libremdbI2pCustomRedirects: [],
|
||||||
|
|
||||||
libremdbLokiRedirectsChecks: [],
|
libremdbLokiRedirectsChecks: [],
|
||||||
libremdbLokiCustomRedirects: []
|
libremdbLokiCustomRedirects: [],
|
||||||
}, () => resolve());
|
},
|
||||||
});
|
() => resolve()
|
||||||
})
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setRedirects,
|
setRedirects,
|
||||||
|
|
||||||
redirect,
|
redirect,
|
||||||
reverse,
|
reverse,
|
||||||
switchInstance,
|
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)(\/|$)/
|
const targets = /^https?:\/{2}([im]\.)?imgur\.(com|io)(\/|$)/
|
||||||
|
|
||||||
|
@ -10,91 +10,95 @@ const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
let redirects = {}
|
let redirects = {}
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
redirects[frontends[i]] = {}
|
redirects[frontends[i]] = {}
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
redirects[frontends[i]][protocols[x]] = []
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRedirects() {
|
function setRedirects() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
fetch("/instances/data.json")
|
||||||
let dataJson = JSON.parse(data);
|
.then(response => response.text())
|
||||||
redirects.rimgo = dataJson.rimgo;
|
.then(async data => {
|
||||||
|
let dataJson = JSON.parse(data)
|
||||||
|
redirects.rimgo = dataJson.rimgo
|
||||||
|
|
||||||
rimgoNormalRedirectsChecks = [...redirects.rimgo.normal];
|
rimgoNormalRedirectsChecks = [...redirects.rimgo.normal]
|
||||||
rimgoTorRedirectsChecks = [...redirects.rimgo.tor];
|
rimgoTorRedirectsChecks = [...redirects.rimgo.tor]
|
||||||
rimgoI2pRedirectsChecks = [...redirects.rimgo.i2p];
|
rimgoI2pRedirectsChecks = [...redirects.rimgo.i2p]
|
||||||
|
|
||||||
for (const instance of r.cloudflareBlackList) {
|
for (const instance of r.cloudflareBlackList) {
|
||||||
const a = rimgoNormalRedirectsChecks.indexOf(instance);
|
const a = rimgoNormalRedirectsChecks.indexOf(instance)
|
||||||
if (a > -1) rimgoNormalRedirectsChecks.splice(a, 1);
|
if (a > -1) rimgoNormalRedirectsChecks.splice(a, 1)
|
||||||
|
|
||||||
const b = rimgoTorRedirectsChecks.indexOf(instance);
|
const b = rimgoTorRedirectsChecks.indexOf(instance)
|
||||||
if (b > -1) rimgoTorRedirectsChecks.splice(b, 1);
|
if (b > -1) rimgoTorRedirectsChecks.splice(b, 1)
|
||||||
|
|
||||||
const c = rimgoI2pRedirectsChecks.indexOf(instance);
|
const c = rimgoI2pRedirectsChecks.indexOf(instance)
|
||||||
if (c > -1) rimgoI2pRedirectsChecks.splice(c, 1);
|
if (c > -1) rimgoI2pRedirectsChecks.splice(c, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.set({
|
browser.storage.local.set(
|
||||||
imgurRedirects: redirects,
|
{
|
||||||
rimgoNormalRedirectsChecks,
|
imgurRedirects: redirects,
|
||||||
rimgoTorRedirectsChecks,
|
rimgoNormalRedirectsChecks,
|
||||||
rimgoI2pRedirectsChecks,
|
rimgoTorRedirectsChecks,
|
||||||
}, () => resolve());
|
rimgoI2pRedirectsChecks,
|
||||||
})
|
},
|
||||||
})
|
() => resolve()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let disableImgur,
|
||||||
disableImgur,
|
imgurRedirects,
|
||||||
imgurRedirects,
|
protocol,
|
||||||
protocol,
|
protocolFallback,
|
||||||
protocolFallback,
|
rimgoNormalRedirectsChecks,
|
||||||
rimgoNormalRedirectsChecks,
|
rimgoNormalCustomRedirects,
|
||||||
rimgoNormalCustomRedirects,
|
rimgoTorRedirectsChecks,
|
||||||
rimgoTorRedirectsChecks,
|
rimgoTorCustomRedirects,
|
||||||
rimgoTorCustomRedirects,
|
rimgoI2pRedirectsChecks,
|
||||||
rimgoI2pRedirectsChecks,
|
rimgoI2pCustomRedirects,
|
||||||
rimgoI2pCustomRedirects,
|
rimgoLokiCustomRedirects
|
||||||
rimgoLokiCustomRedirects;
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disableImgur",
|
"disableImgur",
|
||||||
"imgurRedirects",
|
"imgurRedirects",
|
||||||
"protocol",
|
"protocol",
|
||||||
"protocolFallback",
|
"protocolFallback",
|
||||||
"rimgoNormalRedirectsChecks",
|
"rimgoNormalRedirectsChecks",
|
||||||
"rimgoNormalCustomRedirects",
|
"rimgoNormalCustomRedirects",
|
||||||
"rimgoTorRedirectsChecks",
|
"rimgoTorRedirectsChecks",
|
||||||
"rimgoTorCustomRedirects",
|
"rimgoTorCustomRedirects",
|
||||||
"rimgoI2pRedirectsChecks",
|
"rimgoI2pRedirectsChecks",
|
||||||
"rimgoI2pCustomRedirects",
|
"rimgoI2pCustomRedirects",
|
||||||
"rimgoLokiCustomRedirects"
|
"rimgoLokiCustomRedirects",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
disableImgur = r.disableImgur;
|
disableImgur = r.disableImgur
|
||||||
imgurRedirects = r.imgurRedirects;
|
imgurRedirects = r.imgurRedirects
|
||||||
protocol = r.protocol;
|
protocol = r.protocol
|
||||||
protocolFallback = r.protocolFallback;
|
protocolFallback = r.protocolFallback
|
||||||
rimgoNormalRedirectsChecks = r.rimgoNormalRedirectsChecks;
|
rimgoNormalRedirectsChecks = r.rimgoNormalRedirectsChecks
|
||||||
rimgoNormalCustomRedirects = r.rimgoNormalCustomRedirects;
|
rimgoNormalCustomRedirects = r.rimgoNormalCustomRedirects
|
||||||
rimgoTorRedirectsChecks = r.rimgoTorRedirectsChecks;
|
rimgoTorRedirectsChecks = r.rimgoTorRedirectsChecks
|
||||||
rimgoTorCustomRedirects = r.rimgoTorCustomRedirects;
|
rimgoTorCustomRedirects = r.rimgoTorCustomRedirects
|
||||||
rimgoI2pRedirectsChecks = r.rimgoI2pRedirectsChecks;
|
rimgoI2pRedirectsChecks = r.rimgoI2pRedirectsChecks
|
||||||
rimgoI2pCustomRedirects = r.rimgoI2pCustomRedirects;
|
rimgoI2pCustomRedirects = r.rimgoI2pCustomRedirects
|
||||||
rimgoLokiCustomRedirects = r.rimgoLokiCustomRedirects;
|
rimgoLokiCustomRedirects = r.rimgoLokiCustomRedirects
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
// https://imgur.com/gallery/s4WXQmn
|
// https://imgur.com/gallery/s4WXQmn
|
||||||
|
@ -104,108 +108,127 @@ browser.storage.onChanged.addListener(init)
|
||||||
// https://i.imgur.com/CFSQArP.jpeg
|
// https://i.imgur.com/CFSQArP.jpeg
|
||||||
|
|
||||||
function all() {
|
function all() {
|
||||||
return [
|
return [
|
||||||
...imgurRedirects.rimgo.normal,
|
...imgurRedirects.rimgo.normal,
|
||||||
...imgurRedirects.rimgo.tor,
|
...imgurRedirects.rimgo.tor,
|
||||||
...imgurRedirects.rimgo.i2p,
|
...imgurRedirects.rimgo.i2p,
|
||||||
...rimgoNormalCustomRedirects,
|
...rimgoNormalCustomRedirects,
|
||||||
...rimgoTorCustomRedirects,
|
...rimgoTorCustomRedirects,
|
||||||
...rimgoI2pCustomRedirects,
|
...rimgoI2pCustomRedirects,
|
||||||
...rimgoLokiCustomRedirects
|
...rimgoLokiCustomRedirects,
|
||||||
];
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirect(url, type, initiator, disableOverride) {
|
function redirect(url, type, initiator, disableOverride) {
|
||||||
if (disableImgur && !disableOverride) return;
|
if (disableImgur && !disableOverride) return
|
||||||
if (url.pathname == "/" && !disableOverride) return;
|
if (url.pathname == "/" && !disableOverride) return
|
||||||
if (!["main_frame", "sub_frame", "xmlhttprequest", "other", "image", "media",].includes(type)) 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 (initiator && (all().includes(initiator.origin) || targets.test(initiator.host))) return
|
||||||
if (!targets.test(url.href)) return;
|
if (!targets.test(url.href)) return
|
||||||
if (url.pathname.includes("delete/")) return;
|
if (url.pathname.includes("delete/")) return
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...rimgoLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...rimgoLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks];
|
else if (protocol == "i2p") instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks]
|
||||||
else if (protocol == 'tor') instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects];
|
instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) { return; }
|
if (instancesList.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
return `${randomInstance}${url.pathname}${url.search}`;
|
return `${randomInstance}${url.pathname}${url.search}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function reverse(url) {
|
function reverse(url) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
const protocolHost = utils.protocolHost(url);
|
const protocolHost = utils.protocolHost(url)
|
||||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
if (!all().includes(protocolHost)) {
|
||||||
resolve(`https://imgur.com${url.pathname}${url.search}`);
|
resolve()
|
||||||
})
|
return
|
||||||
|
}
|
||||||
|
resolve(`https://imgur.com${url.pathname}${url.search}`)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchInstance(url, disableOverride) {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableImgur && !disableOverride) { resolve(); return; }
|
if (disableImgur && !disableOverride) {
|
||||||
let protocolHost = utils.protocolHost(url);
|
resolve()
|
||||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
return
|
||||||
let instancesList = [];
|
}
|
||||||
if (protocol == 'loki') instancesList = [...rimgoLokiCustomRedirects];
|
let protocolHost = utils.protocolHost(url)
|
||||||
else if (protocol == 'i2p') instancesList = [...rimgoI2pCustomRedirects, ...rimgoI2pRedirectsChecks];
|
if (!all().includes(protocolHost)) {
|
||||||
else if (protocol == 'tor') instancesList = [...rimgoTorRedirectsChecks, ...rimgoTorCustomRedirects];
|
resolve()
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
return
|
||||||
instancesList = [...rimgoNormalRedirectsChecks, ...rimgoNormalCustomRedirects];
|
}
|
||||||
}
|
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);
|
const i = instancesList.indexOf(protocolHost)
|
||||||
if (i > -1) instancesList.splice(i, 1);
|
if (i > -1) instancesList.splice(i, 1)
|
||||||
if (instancesList.length === 0) { resolve(); return; }
|
if (instancesList.length === 0) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaults() {
|
function initDefaults() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
fetch("/instances/data.json")
|
||||||
let dataJson = JSON.parse(data);
|
.then(response => response.text())
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
.then(async data => {
|
||||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
let dataJson = JSON.parse(data)
|
||||||
}
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
browser.storage.local.get('cloudflareBlackList', async r => {
|
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||||
rimgoNormalRedirectsChecks = [...redirects.rimgo.normal];
|
}
|
||||||
for (const instance of r.cloudflareBlackList) {
|
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||||
const i = rimgoNormalRedirectsChecks.indexOf(instance);
|
rimgoNormalRedirectsChecks = [...redirects.rimgo.normal]
|
||||||
if (i > -1) rimgoNormalRedirectsChecks.splice(i, 1);
|
for (const instance of r.cloudflareBlackList) {
|
||||||
}
|
const i = rimgoNormalRedirectsChecks.indexOf(instance)
|
||||||
browser.storage.local.set({
|
if (i > -1) rimgoNormalRedirectsChecks.splice(i, 1)
|
||||||
disableImgur: false,
|
}
|
||||||
imgurRedirects: redirects,
|
browser.storage.local.set(
|
||||||
|
{
|
||||||
|
disableImgur: false,
|
||||||
|
imgurRedirects: redirects,
|
||||||
|
|
||||||
rimgoNormalRedirectsChecks: rimgoNormalRedirectsChecks,
|
rimgoNormalRedirectsChecks: rimgoNormalRedirectsChecks,
|
||||||
rimgoNormalCustomRedirects: [],
|
rimgoNormalCustomRedirects: [],
|
||||||
|
|
||||||
rimgoTorRedirectsChecks: [...redirects.rimgo.tor],
|
rimgoTorRedirectsChecks: [...redirects.rimgo.tor],
|
||||||
rimgoTorCustomRedirects: [],
|
rimgoTorCustomRedirects: [],
|
||||||
|
|
||||||
rimgoI2pRedirectsChecks: [...redirects.rimgo.i2p],
|
rimgoI2pRedirectsChecks: [...redirects.rimgo.i2p],
|
||||||
rimgoI2pCustomRedirects: [],
|
rimgoI2pCustomRedirects: [],
|
||||||
|
|
||||||
rimgoLokiRedirectsChecks: [...redirects.rimgo.loki],
|
rimgoLokiRedirectsChecks: [...redirects.rimgo.loki],
|
||||||
rimgoLokiCustomRedirects: []
|
rimgoLokiCustomRedirects: [],
|
||||||
}, () => resolve());
|
},
|
||||||
});
|
() => resolve()
|
||||||
});
|
)
|
||||||
});
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setRedirects,
|
setRedirects,
|
||||||
redirect,
|
redirect,
|
||||||
reverse,
|
reverse,
|
||||||
initDefaults,
|
initDefaults,
|
||||||
switchInstance,
|
switchInstance,
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,200 +1,208 @@
|
||||||
window.browser = window.browser || window.chrome;
|
window.browser = window.browser || window.chrome
|
||||||
import utils from './utils.js'
|
import utils from "./utils.js"
|
||||||
|
|
||||||
const targets = [
|
const targets = ["instagram.com", "www.instagram.com"]
|
||||||
"instagram.com",
|
|
||||||
"www.instagram.com",
|
|
||||||
];
|
|
||||||
|
|
||||||
const frontends = new Array("bibliogram")
|
const frontends = new Array("bibliogram")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
let redirects = {};
|
let redirects = {}
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
redirects[frontends[i]] = {}
|
redirects[frontends[i]] = {}
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
redirects[frontends[i]][protocols[x]] = []
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRedirects(val) {
|
function setRedirects(val) {
|
||||||
browser.storage.local.get('cloudflareBlackList', async r => {
|
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||||
redirects.bibliogram = val;
|
redirects.bibliogram = val
|
||||||
bibliogramNormalRedirectsChecks = [...redirects.bibliogram.normal];
|
bibliogramNormalRedirectsChecks = [...redirects.bibliogram.normal]
|
||||||
for (const instance of r.cloudflareBlackList) {
|
for (const instance of r.cloudflareBlackList) {
|
||||||
const a = bibliogramNormalRedirectsChecks.indexOf(instance);
|
const a = bibliogramNormalRedirectsChecks.indexOf(instance)
|
||||||
if (a > -1) bibliogramNormalRedirectsChecks.splice(a, 1);
|
if (a > -1) bibliogramNormalRedirectsChecks.splice(a, 1)
|
||||||
}
|
}
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
instagramRedirects: redirects,
|
instagramRedirects: redirects,
|
||||||
bibliogramNormalRedirectsChecks
|
bibliogramNormalRedirectsChecks,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let disableInstagram,
|
||||||
disableInstagram,
|
protocol,
|
||||||
protocol,
|
protocolFallback,
|
||||||
protocolFallback,
|
instagramRedirects,
|
||||||
instagramRedirects,
|
bibliogramNormalRedirectsChecks,
|
||||||
bibliogramNormalRedirectsChecks,
|
bibliogramTorRedirectsChecks,
|
||||||
bibliogramTorRedirectsChecks,
|
bibliogramNormalCustomRedirects,
|
||||||
bibliogramNormalCustomRedirects,
|
bibliogramTorCustomRedirects,
|
||||||
bibliogramTorCustomRedirects,
|
bibliogramI2pCustomRedirects,
|
||||||
bibliogramI2pCustomRedirects,
|
bibliogramLokiCustomRedirects
|
||||||
bibliogramLokiCustomRedirects;
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disableInstagram",
|
"disableInstagram",
|
||||||
"protocol",
|
"protocol",
|
||||||
"protocolFallback",
|
"protocolFallback",
|
||||||
"instagramRedirects",
|
"instagramRedirects",
|
||||||
"bibliogramNormalRedirectsChecks",
|
"bibliogramNormalRedirectsChecks",
|
||||||
"bibliogramTorRedirectsChecks",
|
"bibliogramTorRedirectsChecks",
|
||||||
"bibliogramNormalCustomRedirects",
|
"bibliogramNormalCustomRedirects",
|
||||||
"bibliogramTorCustomRedirects",
|
"bibliogramTorCustomRedirects",
|
||||||
"bibliogramI2pCustomRedirects",
|
"bibliogramI2pCustomRedirects",
|
||||||
"bibliogramLokiCustomRedirects"
|
"bibliogramLokiCustomRedirects",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
disableInstagram = r.disableInstagram;
|
disableInstagram = r.disableInstagram
|
||||||
protocol = r.protocol;
|
protocol = r.protocol
|
||||||
protocolFallback = r.protocolFallback;
|
protocolFallback = r.protocolFallback
|
||||||
instagramRedirects = r.instagramRedirects;
|
instagramRedirects = r.instagramRedirects
|
||||||
bibliogramNormalRedirectsChecks = r.bibliogramNormalRedirectsChecks;
|
bibliogramNormalRedirectsChecks = r.bibliogramNormalRedirectsChecks
|
||||||
bibliogramTorRedirectsChecks = r.bibliogramTorRedirectsChecks;
|
bibliogramTorRedirectsChecks = r.bibliogramTorRedirectsChecks
|
||||||
bibliogramNormalCustomRedirects = r.bibliogramNormalCustomRedirects;
|
bibliogramNormalCustomRedirects = r.bibliogramNormalCustomRedirects
|
||||||
bibliogramTorCustomRedirects = r.bibliogramTorCustomRedirects;
|
bibliogramTorCustomRedirects = r.bibliogramTorCustomRedirects
|
||||||
bibliogramI2pCustomRedirects = r.bibliogramI2pCustomRedirects;
|
bibliogramI2pCustomRedirects = r.bibliogramI2pCustomRedirects
|
||||||
bibliogramLokiCustomRedirects = r.bibliogramLokiCustomRedirects
|
bibliogramLokiCustomRedirects = r.bibliogramLokiCustomRedirects
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
function all() {
|
function all() {
|
||||||
return [
|
return [
|
||||||
...instagramRedirects.bibliogram.normal,
|
...instagramRedirects.bibliogram.normal,
|
||||||
...instagramRedirects.bibliogram.tor,
|
...instagramRedirects.bibliogram.tor,
|
||||||
...bibliogramNormalCustomRedirects,
|
...bibliogramNormalCustomRedirects,
|
||||||
...bibliogramTorCustomRedirects,
|
...bibliogramTorCustomRedirects,
|
||||||
...bibliogramI2pCustomRedirects,
|
...bibliogramI2pCustomRedirects,
|
||||||
...bibliogramLokiCustomRedirects
|
...bibliogramLokiCustomRedirects,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirect(url, type, initiator, disableOverride) {
|
function redirect(url, type, initiator, disableOverride) {
|
||||||
if (disableInstagram && !disableOverride) return;
|
if (disableInstagram && !disableOverride) return
|
||||||
if (initiator && all().includes(initiator.origin)) return 'BYPASSTAB';
|
if (initiator && all().includes(initiator.origin)) return "BYPASSTAB"
|
||||||
if (!targets.includes(url.host)) return;
|
if (!targets.includes(url.host)) return
|
||||||
if (!["main_frame", "sub_frame", "xmlhttprequest", "other", "image", "media"].includes(type)) 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)/];
|
const bypassPaths = [/about/, /explore/, /support/, /press/, /api/, /privacy/, /safety/, /admin/, /\/(accounts\/|embeds?.js)/]
|
||||||
if (bypassPaths.some(rx => rx.test(url.pathname))) return;
|
if (bypassPaths.some(rx => rx.test(url.pathname))) return
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...bibliogramLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...bibliogramLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...bibliogramI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...bibliogramI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...bibliogramNormalRedirectsChecks, ...bibliogramNormalCustomRedirects];
|
instancesList = [...bibliogramNormalRedirectsChecks, ...bibliogramNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) { return; }
|
if (instancesList.length === 0) {
|
||||||
let randomInstance = utils.getRandomInstance(instancesList)
|
return
|
||||||
|
}
|
||||||
|
let randomInstance = utils.getRandomInstance(instancesList)
|
||||||
|
|
||||||
const reservedPaths = ["u", "p", "privacy",];
|
const reservedPaths = ["u", "p", "privacy"]
|
||||||
if (url.pathname === "/" || reservedPaths.includes(url.pathname.split("/")[1]))
|
if (url.pathname === "/" || reservedPaths.includes(url.pathname.split("/")[1])) return `${randomInstance}${url.pathname}${url.search}`
|
||||||
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}`
|
||||||
if (url.pathname.startsWith("/reel") || url.pathname.startsWith("/tv"))
|
else return `${randomInstance}/u${url.pathname}${url.search}` // Likely a user profile, redirect to '/u/...'
|
||||||
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) {
|
function reverse(url) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
const protocolHost = utils.protocolHost(url);
|
const protocolHost = utils.protocolHost(url)
|
||||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
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("/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}`);
|
if (url.pathname.startsWith("/u")) resolve(`https://instagram.com${url.pathname.replace("/u", "")}${url.search}`)
|
||||||
resolve(`https://instagram.com${url.pathname}${url.search}`);
|
resolve(`https://instagram.com${url.pathname}${url.search}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchInstance(url, disableOverride) {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableInstagram && !disableOverride) { resolve(); return; }
|
if (disableInstagram && !disableOverride) {
|
||||||
let protocolHost = utils.protocolHost(url);
|
resolve()
|
||||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
return
|
||||||
|
}
|
||||||
|
let protocolHost = utils.protocolHost(url)
|
||||||
|
if (!all().includes(protocolHost)) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...bibliogramLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...bibliogramLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...bibliogramI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...bibliogramI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...bibliogramTorRedirectsChecks, ...bibliogramTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...bibliogramNormalRedirectsChecks, ...bibliogramNormalCustomRedirects];
|
instancesList = [...bibliogramNormalRedirectsChecks, ...bibliogramNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
|
|
||||||
const i = instancesList.indexOf(protocolHost);
|
const i = instancesList.indexOf(protocolHost)
|
||||||
if (i > -1) instancesList.splice(i, 1);
|
if (i > -1) instancesList.splice(i, 1)
|
||||||
if (instancesList.length === 0) { resolve(); return; }
|
if (instancesList.length === 0) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaults() {
|
function initDefaults() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
fetch("/instances/data.json")
|
||||||
let dataJson = JSON.parse(data);
|
.then(response => response.text())
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
.then(data => {
|
||||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
let dataJson = JSON.parse(data)
|
||||||
}
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
browser.storage.local.get('cloudflareBlackList', r => {
|
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||||
bibliogramNormalRedirectsChecks = [...redirects.bibliogram.normal];
|
}
|
||||||
for (const instance of r.cloudflareBlackList) {
|
browser.storage.local.get("cloudflareBlackList", r => {
|
||||||
const i = bibliogramNormalRedirectsChecks.indexOf(instance);
|
bibliogramNormalRedirectsChecks = [...redirects.bibliogram.normal]
|
||||||
if (i > -1) bibliogramNormalRedirectsChecks.splice(i, 1);
|
for (const instance of r.cloudflareBlackList) {
|
||||||
}
|
const i = bibliogramNormalRedirectsChecks.indexOf(instance)
|
||||||
browser.storage.local.set({
|
if (i > -1) bibliogramNormalRedirectsChecks.splice(i, 1)
|
||||||
disableInstagram: false,
|
}
|
||||||
instagramRedirects: redirects,
|
browser.storage.local.set({
|
||||||
|
disableInstagram: false,
|
||||||
|
instagramRedirects: redirects,
|
||||||
|
|
||||||
bibliogramNormalRedirectsChecks: bibliogramNormalRedirectsChecks,
|
bibliogramNormalRedirectsChecks: bibliogramNormalRedirectsChecks,
|
||||||
bibliogramNormalCustomRedirects: [],
|
bibliogramNormalCustomRedirects: [],
|
||||||
|
|
||||||
bibliogramTorRedirectsChecks: [...redirects.bibliogram.tor],
|
bibliogramTorRedirectsChecks: [...redirects.bibliogram.tor],
|
||||||
bibliogramTorCustomRedirects: [],
|
bibliogramTorCustomRedirects: [],
|
||||||
|
|
||||||
bibliogramI2pRedirectsChecks: [...redirects.bibliogram.i2p],
|
bibliogramI2pRedirectsChecks: [...redirects.bibliogram.i2p],
|
||||||
bibliogramI2pCustomRedirects: [],
|
bibliogramI2pCustomRedirects: [],
|
||||||
|
|
||||||
bibliogramLokiRedirectsChecks: [...redirects.bibliogram.loki],
|
bibliogramLokiRedirectsChecks: [...redirects.bibliogram.loki],
|
||||||
bibliogramLokiCustomRedirects: []
|
bibliogramLokiCustomRedirects: [],
|
||||||
})
|
})
|
||||||
resolve();
|
resolve()
|
||||||
}
|
})
|
||||||
)
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setRedirects,
|
setRedirects,
|
||||||
reverse,
|
reverse,
|
||||||
redirect,
|
redirect,
|
||||||
initDefaults,
|
initDefaults,
|
||||||
switchInstance,
|
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 frontends = new Array("librarian")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
@ -10,160 +10,166 @@ const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
let redirects = {}
|
let redirects = {}
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
redirects[frontends[i]] = {}
|
redirects[frontends[i]] = {}
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
redirects[frontends[i]][protocols[x]] = []
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRedirects(val) {
|
function setRedirects(val) {
|
||||||
browser.storage.local.get('cloudflareBlackList', r => {
|
browser.storage.local.get("cloudflareBlackList", r => {
|
||||||
redirects.librarian = val;
|
redirects.librarian = val
|
||||||
librarianNormalRedirectsChecks = [...redirects.librarian.normal];
|
librarianNormalRedirectsChecks = [...redirects.librarian.normal]
|
||||||
for (const instance of r.cloudflareBlackList) {
|
for (const instance of r.cloudflareBlackList) {
|
||||||
const a = librarianNormalRedirectsChecks.indexOf(instance);
|
const a = librarianNormalRedirectsChecks.indexOf(instance)
|
||||||
if (a > -1) librarianNormalRedirectsChecks.splice(a, 1);
|
if (a > -1) librarianNormalRedirectsChecks.splice(a, 1)
|
||||||
}
|
}
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
lbryTargetsRedirects: redirects,
|
lbryTargetsRedirects: redirects,
|
||||||
librarianNormalRedirectsChecks
|
librarianNormalRedirectsChecks,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let disableLbryTargets,
|
||||||
disableLbryTargets,
|
protocol,
|
||||||
protocol,
|
protocolFallback,
|
||||||
protocolFallback,
|
lbryTargetsRedirects,
|
||||||
lbryTargetsRedirects,
|
librarianNormalRedirectsChecks,
|
||||||
librarianNormalRedirectsChecks,
|
librarianNormalCustomRedirects,
|
||||||
librarianNormalCustomRedirects,
|
librarianTorRedirectsChecks,
|
||||||
librarianTorRedirectsChecks,
|
librarianTorCustomRedirects,
|
||||||
librarianTorCustomRedirects,
|
librarianI2pRedirectsChecks,
|
||||||
librarianI2pRedirectsChecks,
|
librarianI2pCustomRedirects,
|
||||||
librarianI2pCustomRedirects,
|
librarianLokiCustomRedirects
|
||||||
librarianLokiCustomRedirects;
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disableLbryTargets",
|
"disableLbryTargets",
|
||||||
"protocol",
|
"protocol",
|
||||||
"protocolFallback",
|
"protocolFallback",
|
||||||
"lbryTargetsRedirects",
|
"lbryTargetsRedirects",
|
||||||
"librarianNormalRedirectsChecks",
|
"librarianNormalRedirectsChecks",
|
||||||
"librarianNormalCustomRedirects",
|
"librarianNormalCustomRedirects",
|
||||||
"librarianTorRedirectsChecks",
|
"librarianTorRedirectsChecks",
|
||||||
"librarianTorCustomRedirects",
|
"librarianTorCustomRedirects",
|
||||||
"librarianI2pRedirectsChecks",
|
"librarianI2pRedirectsChecks",
|
||||||
"librarianI2pCustomRedirects",
|
"librarianI2pCustomRedirects",
|
||||||
"librarianLokiCustomRedirects"
|
"librarianLokiCustomRedirects",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
disableLbryTargets = r.disableLbryTargets;
|
disableLbryTargets = r.disableLbryTargets
|
||||||
protocol = r.protocol;
|
protocol = r.protocol
|
||||||
protocolFallback = r.protocolFallback;
|
protocolFallback = r.protocolFallback
|
||||||
lbryTargetsRedirects = r.lbryTargetsRedirects;
|
lbryTargetsRedirects = r.lbryTargetsRedirects
|
||||||
librarianNormalRedirectsChecks = r.librarianNormalRedirectsChecks;
|
librarianNormalRedirectsChecks = r.librarianNormalRedirectsChecks
|
||||||
librarianNormalCustomRedirects = r.librarianNormalCustomRedirects;
|
librarianNormalCustomRedirects = r.librarianNormalCustomRedirects
|
||||||
librarianTorRedirectsChecks = r.librarianTorRedirectsChecks;
|
librarianTorRedirectsChecks = r.librarianTorRedirectsChecks
|
||||||
librarianTorCustomRedirects = r.librarianTorCustomRedirects;
|
librarianTorCustomRedirects = r.librarianTorCustomRedirects
|
||||||
librarianI2pRedirectsChecks = r.librarianI2pRedirectsChecks;
|
librarianI2pRedirectsChecks = r.librarianI2pRedirectsChecks
|
||||||
librarianI2pCustomRedirects = r.librarianI2pCustomRedirects;
|
librarianI2pCustomRedirects = r.librarianI2pCustomRedirects
|
||||||
librarianLokiCustomRedirects = r.librarianLokiCustomRedirects;
|
librarianLokiCustomRedirects = r.librarianLokiCustomRedirects
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
function all() {
|
function all() {
|
||||||
return [
|
return [...redirects.librarian.normal, ...redirects.librarian.tor, ...librarianNormalCustomRedirects, ...librarianTorCustomRedirects, ...librarianI2pCustomRedirects, ...librarianLokiCustomRedirects]
|
||||||
...redirects.librarian.normal,
|
|
||||||
...redirects.librarian.tor,
|
|
||||||
...librarianNormalCustomRedirects,
|
|
||||||
...librarianTorCustomRedirects,
|
|
||||||
...librarianI2pCustomRedirects,
|
|
||||||
...librarianLokiCustomRedirects
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchInstance(url, disableOverride) {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableLbryTargets && !disableOverride) { resolve(); return; }
|
if (disableLbryTargets && !disableOverride) {
|
||||||
const protocolHost = utils.protocolHost(url);
|
resolve()
|
||||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
return
|
||||||
|
}
|
||||||
|
const protocolHost = utils.protocolHost(url)
|
||||||
|
if (!all().includes(protocolHost)) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...librarianLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...librarianLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...librarianI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...librarianI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects];
|
instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
|
|
||||||
const i = instancesList.indexOf(protocolHost);
|
const i = instancesList.indexOf(protocolHost)
|
||||||
if (i > -1) instancesList.splice(i, 1);
|
if (i > -1) instancesList.splice(i, 1)
|
||||||
if (instancesList.length === 0) { resolve(); return; }
|
if (instancesList.length === 0) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirect(url, type, initiator, disableOverride) {
|
function redirect(url, type, initiator, disableOverride) {
|
||||||
if (disableLbryTargets && !disableOverride) return;
|
if (disableLbryTargets && !disableOverride) return
|
||||||
if (initiator && (all().includes(initiator.origin) || targets.includes(initiator.host))) return;
|
if (initiator && (all().includes(initiator.origin) || targets.includes(initiator.host))) return
|
||||||
if (!targets.includes(url.host)) return;
|
if (!targets.includes(url.host)) return
|
||||||
if (type != "main_frame") return;
|
if (type != "main_frame") return
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...librarianLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...librarianLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...librarianI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...librarianI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...librarianTorRedirectsChecks, ...librarianTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects];
|
instancesList = [...librarianNormalRedirectsChecks, ...librarianNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) return;
|
if (instancesList.length === 0) return
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
return `${randomInstance}${url.pathname}${url.search}`;
|
return `${randomInstance}${url.pathname}${url.search}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaults() {
|
function initDefaults() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
fetch("/instances/data.json")
|
||||||
let dataJson = JSON.parse(data);
|
.then(response => response.text())
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
.then(async data => {
|
||||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
let dataJson = JSON.parse(data)
|
||||||
}
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
browser.storage.local.set({
|
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||||
disableLbryTargets: true,
|
}
|
||||||
lbryTargetsRedirects: redirects,
|
browser.storage.local.set(
|
||||||
|
{
|
||||||
|
disableLbryTargets: true,
|
||||||
|
lbryTargetsRedirects: redirects,
|
||||||
|
|
||||||
librarianNormalRedirectsChecks: [...redirects.librarian.normal],
|
librarianNormalRedirectsChecks: [...redirects.librarian.normal],
|
||||||
librarianNormalCustomRedirects: [],
|
librarianNormalCustomRedirects: [],
|
||||||
|
|
||||||
librarianTorRedirectsChecks: [...redirects.librarian.tor],
|
librarianTorRedirectsChecks: [...redirects.librarian.tor],
|
||||||
librarianTorCustomRedirects: [],
|
librarianTorCustomRedirects: [],
|
||||||
|
|
||||||
librarianI2pRedirectsChecks: [...redirects.librarian.i2p],
|
librarianI2pRedirectsChecks: [...redirects.librarian.i2p],
|
||||||
librarianI2pCustomRedirects: [],
|
librarianI2pCustomRedirects: [],
|
||||||
|
|
||||||
librarianLokiRedirectsChecks: [...redirects.librarian.loki],
|
librarianLokiRedirectsChecks: [...redirects.librarian.loki],
|
||||||
librarianLokiCustomRedirects: []
|
librarianLokiCustomRedirects: [],
|
||||||
}, () => resolve());
|
},
|
||||||
});
|
() => resolve()
|
||||||
})
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setRedirects,
|
setRedirects,
|
||||||
switchInstance,
|
switchInstance,
|
||||||
redirect,
|
redirect,
|
||||||
initDefaults,
|
initDefaults,
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
window.browser = window.browser || window.chrome;
|
window.browser = window.browser || window.chrome
|
||||||
|
|
||||||
function localisePage() {
|
function localisePage() {
|
||||||
function getMessage(tag) {
|
function getMessage(tag) {
|
||||||
return tag.replace(/__MSG_(\w+)__/g, (_match, v1) => {
|
return tag.replace(/__MSG_(\w+)__/g, (_match, v1) => {
|
||||||
return v1 ? browser.i18n.getMessage(v1) : null;
|
return v1 ? browser.i18n.getMessage(v1) : null
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const elements = document.querySelectorAll("[data-localise]");
|
const elements = document.querySelectorAll("[data-localise]")
|
||||||
for (let i in elements)
|
for (let i in elements)
|
||||||
if (elements.hasOwnProperty(i)) {
|
if (elements.hasOwnProperty(i)) {
|
||||||
const obj = elements[i];
|
const obj = elements[i]
|
||||||
const tag = obj.getAttribute("data-localise").toString();
|
const tag = obj.getAttribute("data-localise").toString()
|
||||||
const msg = getMessage(tag);
|
const msg = getMessage(tag)
|
||||||
if (msg && msg !== tag) obj.textContent = msg;
|
if (msg && msg !== tag) obj.textContent = msg
|
||||||
}
|
}
|
||||||
|
|
||||||
const placeholders = document.querySelectorAll("[data-localise-placeholder]");
|
const placeholders = document.querySelectorAll("[data-localise-placeholder]")
|
||||||
for (let i in placeholders)
|
for (let i in placeholders)
|
||||||
if (placeholders.hasOwnProperty(i)) {
|
if (placeholders.hasOwnProperty(i)) {
|
||||||
const obj = placeholders[i];
|
const obj = placeholders[i]
|
||||||
const tag = obj.getAttribute("data-localise-placeholder").toString();
|
const tag = obj.getAttribute("data-localise-placeholder").toString()
|
||||||
const msg = getMessage(tag);
|
const msg = getMessage(tag)
|
||||||
if (msg && msg !== tag) obj.placeholder = msg;
|
if (msg && msg !== tag) obj.placeholder = msg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
localisePage
|
localisePage,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,247 +1,294 @@
|
||||||
"use strict";
|
"use strict"
|
||||||
|
|
||||||
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|maps)\.)?(google\.).*(\/maps)|maps\.(google\.).*)/;
|
const targets = /^https?:\/{2}(((www|maps)\.)?(google\.).*(\/maps)|maps\.(google\.).*)/
|
||||||
|
|
||||||
let redirects = {
|
const frontends = new Array("facil")
|
||||||
'osm': {
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
"normal": [
|
|
||||||
"https://www.openstreetmap.org"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
'facil': {
|
|
||||||
"normal": [
|
|
||||||
"https://facilmap.org"
|
|
||||||
],
|
|
||||||
"tor": [],
|
|
||||||
"i2p": [],
|
|
||||||
"loki": []
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
let redirects = {}
|
||||||
|
|
||||||
let
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
disableMaps,
|
redirects[frontends[i]] = {}
|
||||||
mapsFrontend,
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
protocol,
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
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;
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
function redirect(url, initiator) {
|
function redirect(url, initiator) {
|
||||||
if (disableMaps) return;
|
if (disableMaps) return
|
||||||
if (initiator && initiator.host === "earth.google.com") return;
|
if (initiator && initiator.host === "earth.google.com") return
|
||||||
if (!url.href.match(targets)) return;
|
if (!url.href.match(targets)) return
|
||||||
const mapCentreRegex = /@(-?\d[0-9.]*),(-?\d[0-9.]*),(\d{1,2})[.z]/;
|
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 dataLatLngRegex = /!3d(-?[0-9]{1,}.[0-9]{1,})!4d(-?[0-9]{1,}.[0-9]{1,})/
|
||||||
const placeRegex = /\/place\/(.*)\//;
|
const placeRegex = /\/place\/(.*)\//
|
||||||
const travelModes = {
|
const travelModes = {
|
||||||
driving: "fossgis_osrm_car",
|
driving: "fossgis_osrm_car",
|
||||||
walking: "fossgis_osrm_foot",
|
walking: "fossgis_osrm_foot",
|
||||||
bicycling: "fossgis_osrm_bike",
|
bicycling: "fossgis_osrm_bike",
|
||||||
transit: "fossgis_osrm_car", // not implemented on OSM, default to car.
|
transit: "fossgis_osrm_car", // not implemented on OSM, default to car.
|
||||||
};
|
}
|
||||||
const travelModesFacil = {
|
const travelModesFacil = {
|
||||||
driving: "car",
|
driving: "car",
|
||||||
walking: "pedestrian",
|
walking: "pedestrian",
|
||||||
bicycling: "bicycle",
|
bicycling: "bicycle",
|
||||||
transit: "car", // not implemented on Facil, default to car.
|
transit: "car", // not implemented on Facil, default to car.
|
||||||
};
|
}
|
||||||
const osmLayers = {
|
const osmLayers = {
|
||||||
none: "S",
|
none: "S",
|
||||||
transit: "T",
|
transit: "T",
|
||||||
traffic: "S", // not implemented on OSM, default to standard.
|
traffic: "S", // not implemented on OSM, default to standard.
|
||||||
bicycling: "C",
|
bicycling: "C",
|
||||||
};
|
}
|
||||||
function addressToLatLng(address) {
|
function addressToLatLng(address) {
|
||||||
const xmlhttp = new XMLHttpRequest();
|
const xmlhttp = new XMLHttpRequest()
|
||||||
xmlhttp.open("GET", `https://nominatim.openstreetmap.org/search/${address}?format=json&limit=1`, false);
|
xmlhttp.open("GET", `https://nominatim.openstreetmap.org/search/${address}?format=json&limit=1`, false)
|
||||||
xmlhttp.send();
|
xmlhttp.send()
|
||||||
if (xmlhttp.status === 200) {
|
if (xmlhttp.status === 200) {
|
||||||
const json = JSON.parse(xmlhttp.responseText)[0];
|
const json = JSON.parse(xmlhttp.responseText)[0]
|
||||||
if (json) {
|
if (json) {
|
||||||
console.log('json', json)
|
console.log("json", json)
|
||||||
return [
|
return [`${json.lat},${json.lon}`, `${json.boundingbox[2]},${json.boundingbox[1]},${json.boundingbox[3]},${json.boundingbox[0]}`]
|
||||||
`${json.lat},${json.lon}`,
|
}
|
||||||
`${json.boundingbox[2]},${json.boundingbox[1]},${json.boundingbox[3]},${json.boundingbox[0]}`,
|
}
|
||||||
];
|
console.info("Error: Status is " + xmlhttp.status)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
console.info("Error: Status is " + xmlhttp.status);
|
|
||||||
}
|
|
||||||
|
|
||||||
let randomInstance;
|
let instancesList
|
||||||
if (mapsFrontend == 'osm') randomInstance = utils.getRandomInstance(redirects.osm.normal);
|
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') {
|
let mapCentre = "#"
|
||||||
if (protocol == 'loki') randomInstance = utils.getRandomInstance(...facilLokiCustomRedirects);
|
let prefs = {}
|
||||||
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 = "#";
|
if (url.pathname.match(mapCentreRegex)) {
|
||||||
let prefs = {};
|
// 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
|
if (lat && lon && zoom) {
|
||||||
var [, lat, lon, zoom] = url.pathname.match(mapCentreRegex);
|
if (mapsFrontend == "osm") mapCentre = `#map=${zoom}/${lat}/${lon}`
|
||||||
} else if (url.searchParams.has("center")) {
|
if (mapsFrontend == "facil") mapCentre = `#${zoom}/${lat}/${lon}`
|
||||||
var [lat, lon] = url.searchParams.get("center").split(",");
|
}
|
||||||
var zoom = url.searchParams.get("zoom") ?? "17";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lat && lon && zoom) {
|
if (url.searchParams.get("layer")) prefs.layers = osmLayers[url.searchParams.get("layer")]
|
||||||
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.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
|
let query = ""
|
||||||
// https://www.google.com/maps/embed/v1/place?key=AIzaSyD4iE2xVSpkLLOXoyqT-RuPwURN3ddScAI&q=Eiffel+Tower,Paris+France
|
if (url.searchParams.has("q")) query = url.searchParams.get("q")
|
||||||
console.log("embed life");
|
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 = "";
|
let [coords, boundingbox] = addressToLatLng(query)
|
||||||
if (url.searchParams.has("q")) query = url.searchParams.get("q");
|
prefs.bbox = boundingbox
|
||||||
else if (url.searchParams.has("query")) query = url.searchParams.has("query");
|
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"))
|
let travMod = url.searchParams.get("travelmode")
|
||||||
try { query = url.searchParams.get("pb").split(/!2s(.*?)!/)[1]; }
|
if (url.searchParams.has("travelmode")) prefs.engine = travelModes[travMod]
|
||||||
catch (error) { console.error(error); } // Unable to find map marker in URL.
|
|
||||||
|
|
||||||
let [coords, boundingbox] = addressToLatLng(query);
|
let orgVal = url.searchParams.get("origin")
|
||||||
prefs.bbox = boundingbox;
|
let destVal = url.searchParams.get("destination")
|
||||||
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
|
let org
|
||||||
// https://www.google.com/maps/dir/?api=1&origin=Space+Needle+Seattle+WA&destination=Pike+Place+Market+Seattle+WA&travelmode=bicycling
|
addressToLatLng(orgVal, a => (org = a))
|
||||||
|
let dest
|
||||||
|
addressToLatLng(destVal, a => (dest = a))
|
||||||
|
prefs.route = `${org};${dest}`
|
||||||
|
|
||||||
let travMod = url.searchParams.get("travelmode");
|
let prefsEncoded = new URLSearchParams(prefs).toString()
|
||||||
if (url.searchParams.has("travelmode")) prefs.engine = travelModes[travMod];
|
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 [, mlat, mlon] = url.pathname.match(dataLatLngRegex)
|
||||||
let destVal = url.searchParams.get("destination");
|
|
||||||
|
|
||||||
let org; addressToLatLng(orgVal, a => org = a);
|
if (mapsFrontend == "osm") return `${randomInstance}/search?query=${mlat}%2C${mlon}`
|
||||||
let dest; addressToLatLng(destVal, a => dest = a);
|
if (mapsFrontend == "facil") return `${randomInstance}/#q=${mlat}%2C${mlon}`
|
||||||
prefs.route = `${org};${dest}`;
|
} 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();
|
const [mlat, mlon] = url.searchParams.get("ll").split(",")
|
||||||
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
|
if (mapsFrontend == "osm") return `${randomInstance}/search?query=${mlat}%2C${mlon}`
|
||||||
// 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
|
if (mapsFrontend == "facil") return `${randomInstance}/#q=${mlat}%2C${mlon}`
|
||||||
console.log("data life");
|
} 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 == "osm") return `${randomInstance}/search?query=${mlat}%2C${mlon}`
|
||||||
if (mapsFrontend == 'facil') return `${randomInstance}/#q=${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
|
let query
|
||||||
// https://maps.google.com/?ll=38.882147,-76.99017
|
if (url.searchParams.has("q")) query = url.searchParams.get("q")
|
||||||
console.log("ll life");
|
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}`;
|
let prefsEncoded = new URLSearchParams(prefs).toString()
|
||||||
if (mapsFrontend == 'facil') return `${randomInstance}/#q=${mlat}%2C${mlon}`
|
console.log("mapCentre", mapCentre)
|
||||||
} else if (url.searchParams.has("viewpoint")) { // Get marker from viewpoint param.
|
console.log("prefs", prefs)
|
||||||
// https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=48.857832,2.295226&heading=-45&pitch=38&fov=80
|
console.log("prefsEncoded", prefsEncoded)
|
||||||
console.log("viewpoint life");
|
if (mapsFrontend == "osm") return `${randomInstance}/${mapCentre}&${prefsEncoded}`
|
||||||
|
if (mapsFrontend == "facil") return `${randomInstance}/${mapCentre}/Mpnk`
|
||||||
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`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function initDefaults() {
|
function initDefaults() {
|
||||||
return new Promise(resolve =>
|
return new Promise(async resolve => {
|
||||||
browser.storage.local.set({
|
fetch("/instances/data.json")
|
||||||
disableMaps: false,
|
.then(response => response.text())
|
||||||
mapsFrontend: 'osm',
|
.then(async data => {
|
||||||
mapsRedirects: redirects,
|
let dataJson = JSON.parse(data)
|
||||||
facilNormalRedirectsChecks: [...redirects.facil.normal],
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
facilNormalCustomRedirects: [],
|
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],
|
facilTorRedirectsChecks: [...redirects.facil.tor],
|
||||||
facilTorCustomRedirects: [],
|
facilTorCustomRedirects: [],
|
||||||
|
|
||||||
facilI2pRedirectsChecks: [...redirects.facil.i2p],
|
facilI2pRedirectsChecks: [...redirects.facil.i2p],
|
||||||
facilI2pCustomRedirects: [],
|
facilI2pCustomRedirects: [],
|
||||||
|
|
||||||
facilLokiRedirectsChecks: [...redirects.facil.loki],
|
|
||||||
facilLokiCustomRedirects: []
|
|
||||||
}, () => resolve())
|
|
||||||
)
|
|
||||||
|
|
||||||
|
facilLokiRedirectsChecks: [...redirects.facil.loki],
|
||||||
|
facilLokiCustomRedirects: [],
|
||||||
|
},
|
||||||
|
() => resolve()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
redirect,
|
setRedirects,
|
||||||
initDefaults,
|
redirect,
|
||||||
};
|
initDefaults,
|
||||||
|
}
|
||||||
|
|
|
@ -1,207 +1,219 @@
|
||||||
window.browser = window.browser || window.chrome;
|
window.browser = window.browser || window.chrome
|
||||||
import utils from './utils.js'
|
import utils from "./utils.js"
|
||||||
|
|
||||||
const targets = [
|
const targets = [
|
||||||
// /(?:.*\.)*(?<!(link\.|cdn\-images\-\d+\.))medium\.com(\/.*)?$/,
|
// /(?:.*\.)*(?<!(link\.|cdn\-images\-\d+\.))medium\.com(\/.*)?$/,
|
||||||
/^medium\.com/,
|
/^medium\.com/,
|
||||||
/.*\.medium\.com/,
|
/.*\.medium\.com/,
|
||||||
// // Other domains of medium blogs, source(s): https://findingtom.com/best-medium-blogs-to-follow/#1-forge
|
// // Other domains of medium blogs, source(s): https://findingtom.com/best-medium-blogs-to-follow/#1-forge
|
||||||
|
|
||||||
/^towardsdatascience\.com/,
|
/^towardsdatascience\.com/,
|
||||||
/^uxdesign\.cc/,
|
/^uxdesign\.cc/,
|
||||||
/^uxplanet\.org/,
|
/^uxplanet\.org/,
|
||||||
/^betterprogramming\.pub/,
|
/^betterprogramming\.pub/,
|
||||||
/^aninjusticemag\.com/,
|
/^aninjusticemag\.com/,
|
||||||
/^betterhumans\.pub/,
|
/^betterhumans\.pub/,
|
||||||
/^psiloveyou\.xyz/,
|
/^psiloveyou\.xyz/,
|
||||||
/^entrepreneurshandbook\.co/,
|
/^entrepreneurshandbook\.co/,
|
||||||
/^blog\.coinbase\.com/,
|
/^blog\.coinbase\.com/,
|
||||||
|
|
||||||
/^ levelup\.gitconnected\.com /,
|
/^ levelup\.gitconnected\.com /,
|
||||||
/^javascript\.plainenglish\.io /,
|
/^javascript\.plainenglish\.io /,
|
||||||
/^blog\.bitsrc\.io /,
|
/^blog\.bitsrc\.io /,
|
||||||
/^ itnext\.io /,
|
/^ itnext\.io /,
|
||||||
/^codeburst\.io /,
|
/^codeburst\.io /,
|
||||||
/^infosecwriteups\.com /,
|
/^infosecwriteups\.com /,
|
||||||
/^ blog\.devgenius.io /,
|
/^ blog\.devgenius.io /,
|
||||||
/^ writingcooperative\.com /,
|
/^ writingcooperative\.com /,
|
||||||
];
|
]
|
||||||
|
|
||||||
const frontends = new Array("scribe")
|
const frontends = new Array("scribe")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
let redirects = {};
|
let redirects = {}
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
redirects[frontends[i]] = {}
|
redirects[frontends[i]] = {}
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
redirects[frontends[i]][protocols[x]] = []
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRedirects(val) {
|
function setRedirects(val) {
|
||||||
browser.storage.local.get('cloudflareBlackList', r => {
|
browser.storage.local.get("cloudflareBlackList", r => {
|
||||||
redirects.scribe = val;
|
redirects.scribe = val
|
||||||
scribeNormalRedirectsChecks = [...redirects.scribe.normal];
|
scribeNormalRedirectsChecks = [...redirects.scribe.normal]
|
||||||
for (const instance of r.cloudflareBlackList) {
|
for (const instance of r.cloudflareBlackList) {
|
||||||
const a = scribeNormalRedirectsChecks.indexOf(instance);
|
const a = scribeNormalRedirectsChecks.indexOf(instance)
|
||||||
if (a > -1) scribeNormalRedirectsChecks.splice(a, 1);
|
if (a > -1) scribeNormalRedirectsChecks.splice(a, 1)
|
||||||
}
|
}
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
mediumRedirects: redirects,
|
mediumRedirects: redirects,
|
||||||
scribeNormalRedirectsChecks
|
scribeNormalRedirectsChecks,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let disableMedium,
|
||||||
disableMedium,
|
mediumRedirects,
|
||||||
mediumRedirects,
|
scribeNormalRedirectsChecks,
|
||||||
scribeNormalRedirectsChecks,
|
scribeNormalCustomRedirects,
|
||||||
scribeNormalCustomRedirects,
|
scribeTorRedirectsChecks,
|
||||||
scribeTorRedirectsChecks,
|
scribeTorCustomRedirects,
|
||||||
scribeTorCustomRedirects,
|
scribeI2pCustomRedirects,
|
||||||
scribeI2pCustomRedirects,
|
scribeLokiCustomRedirects,
|
||||||
scribeLokiCustomRedirects,
|
protocol,
|
||||||
protocol,
|
protocolFallback
|
||||||
protocolFallback;
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disableMedium",
|
"disableMedium",
|
||||||
"mediumRedirects",
|
"mediumRedirects",
|
||||||
"scribeNormalRedirectsChecks",
|
"scribeNormalRedirectsChecks",
|
||||||
"scribeNormalCustomRedirects",
|
"scribeNormalCustomRedirects",
|
||||||
"scribeTorRedirectsChecks",
|
"scribeTorRedirectsChecks",
|
||||||
"scribeTorCustomRedirects",
|
"scribeTorCustomRedirects",
|
||||||
"scribeI2pCustomRedirects",
|
"scribeI2pCustomRedirects",
|
||||||
"scribeLokiCustomRedirects",
|
"scribeLokiCustomRedirects",
|
||||||
"protocol",
|
"protocol",
|
||||||
"protocolFallback"
|
"protocolFallback",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
disableMedium = r.disableMedium;
|
disableMedium = r.disableMedium
|
||||||
mediumRedirects = r.mediumRedirects;
|
mediumRedirects = r.mediumRedirects
|
||||||
scribeNormalRedirectsChecks = r.scribeNormalRedirectsChecks;
|
scribeNormalRedirectsChecks = r.scribeNormalRedirectsChecks
|
||||||
scribeNormalCustomRedirects = r.scribeNormalCustomRedirects;
|
scribeNormalCustomRedirects = r.scribeNormalCustomRedirects
|
||||||
scribeTorRedirectsChecks = r.scribeTorRedirectsChecks;
|
scribeTorRedirectsChecks = r.scribeTorRedirectsChecks
|
||||||
scribeTorCustomRedirects = r.scribeTorCustomRedirects;
|
scribeTorCustomRedirects = r.scribeTorCustomRedirects
|
||||||
scribeI2pCustomRedirects = r.scribeI2pCustomRedirects;
|
scribeI2pCustomRedirects = r.scribeI2pCustomRedirects
|
||||||
scribeLokiCustomRedirects = r.scribeLokiCustomRedirects;
|
scribeLokiCustomRedirects = r.scribeLokiCustomRedirects
|
||||||
protocol = r.protocol;
|
protocol = r.protocol
|
||||||
protocolFallback = r.protocolFallback;
|
protocolFallback = r.protocolFallback
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
function redirect(url, type, initiator, disableOverride) {
|
function redirect(url, type, initiator, disableOverride) {
|
||||||
if (disableMedium && !disableOverride) return;
|
if (disableMedium && !disableOverride) return
|
||||||
if (url.pathname == "/" && !disableOverride) return;
|
if (url.pathname == "/" && !disableOverride) return
|
||||||
if (type != "main_frame" && "sub_frame" && "xmlhttprequest" && "other") return;
|
if (type != "main_frame" && "sub_frame" && "xmlhttprequest" && "other") return
|
||||||
if (initiator && (
|
if (
|
||||||
[
|
initiator &&
|
||||||
...mediumRedirects.scribe.normal,
|
[...mediumRedirects.scribe.normal, ...mediumRedirects.scribe.tor, ...scribeNormalCustomRedirects, ...scribeTorCustomRedirects, ...scribeI2pCustomRedirects, ...scribeLokiCustomRedirects].includes(
|
||||||
...mediumRedirects.scribe.tor,
|
initiator.origin
|
||||||
...scribeNormalCustomRedirects,
|
)
|
||||||
...scribeTorCustomRedirects,
|
)
|
||||||
...scribeI2pCustomRedirects,
|
return
|
||||||
...scribeLokiCustomRedirects
|
|
||||||
].includes(initiator.origin))) return;
|
|
||||||
|
|
||||||
if (!targets.some(rx => rx.test(url.host))) return;
|
if (!targets.some(rx => rx.test(url.host))) return
|
||||||
if (/^\/(@[a-zA-Z.]{0,}(\/|)$)/.test(url.pathname)) return;
|
if (/^\/(@[a-zA-Z.]{0,}(\/|)$)/.test(url.pathname)) return
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...scribeLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...scribeLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...scribeI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...scribeI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects];
|
instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) { return; }
|
if (instancesList.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList)
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
return `${randomInstance}${url.pathname}${url.search}`;
|
return `${randomInstance}${url.pathname}${url.search}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchInstance(url, disableOverride) {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableMedium && !disableOverride) { resolve(); return; }
|
if (disableMedium && !disableOverride) {
|
||||||
let protocolHost = utils.protocolHost(url);
|
resolve()
|
||||||
const all = [
|
return
|
||||||
...mediumRedirects.scribe.tor,
|
}
|
||||||
...mediumRedirects.scribe.normal,
|
let protocolHost = utils.protocolHost(url)
|
||||||
|
const all = [
|
||||||
|
...mediumRedirects.scribe.tor,
|
||||||
|
...mediumRedirects.scribe.normal,
|
||||||
|
|
||||||
...scribeNormalCustomRedirects,
|
...scribeNormalCustomRedirects,
|
||||||
...scribeTorCustomRedirects,
|
...scribeTorCustomRedirects,
|
||||||
...scribeI2pCustomRedirects,
|
...scribeI2pCustomRedirects,
|
||||||
...scribeLokiCustomRedirects
|
...scribeLokiCustomRedirects,
|
||||||
];
|
]
|
||||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
if (!all.includes(protocolHost)) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...scribeLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...scribeLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...scribeI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...scribeI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects];
|
instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
|
|
||||||
const i = instancesList.indexOf(protocolHost);
|
const i = instancesList.indexOf(protocolHost)
|
||||||
if (i > -1) instancesList.splice(i, 1);
|
if (i > -1) instancesList.splice(i, 1)
|
||||||
if (instancesList.length === 0) { resolve(); return; }
|
if (instancesList.length === 0) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaults() {
|
function initDefaults() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
fetch("/instances/data.json")
|
||||||
let dataJson = JSON.parse(data);
|
.then(response => response.text())
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
.then(data => {
|
||||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
let dataJson = JSON.parse(data)
|
||||||
}
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
browser.storage.local.get('cloudflareBlackList',
|
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||||
async r => {
|
}
|
||||||
scribeNormalRedirectsChecks = [...redirects.scribe.normal];
|
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||||
for (const instance of r.cloudflareBlackList) {
|
scribeNormalRedirectsChecks = [...redirects.scribe.normal]
|
||||||
let i = scribeNormalRedirectsChecks.indexOf(instance);
|
for (const instance of r.cloudflareBlackList) {
|
||||||
if (i > -1) scribeNormalRedirectsChecks.splice(i, 1);
|
let i = scribeNormalRedirectsChecks.indexOf(instance)
|
||||||
}
|
if (i > -1) scribeNormalRedirectsChecks.splice(i, 1)
|
||||||
browser.storage.local.set({
|
}
|
||||||
disableMedium: false,
|
browser.storage.local.set(
|
||||||
mediumRedirects: redirects,
|
{
|
||||||
|
disableMedium: false,
|
||||||
|
mediumRedirects: redirects,
|
||||||
|
|
||||||
scribeNormalRedirectsChecks: scribeNormalRedirectsChecks,
|
scribeNormalRedirectsChecks: scribeNormalRedirectsChecks,
|
||||||
scribeNormalCustomRedirects: [],
|
scribeNormalCustomRedirects: [],
|
||||||
|
|
||||||
scribeTorRedirectsChecks: [...redirects.scribe.tor],
|
scribeTorRedirectsChecks: [...redirects.scribe.tor],
|
||||||
scribeTorCustomRedirects: [],
|
scribeTorCustomRedirects: [],
|
||||||
|
|
||||||
scribeI2pRedirectsChecks: [...redirects.scribe.i2p],
|
scribeI2pRedirectsChecks: [...redirects.scribe.i2p],
|
||||||
scribeI2pCustomRedirects: [],
|
scribeI2pCustomRedirects: [],
|
||||||
|
|
||||||
scribeLokiRedirectsChecks: [...redirects.scribe.loki],
|
scribeLokiRedirectsChecks: [...redirects.scribe.loki],
|
||||||
scribeLokiCustomRedirects: []
|
scribeLokiCustomRedirects: [],
|
||||||
}, () => resolve())
|
},
|
||||||
})
|
() => resolve()
|
||||||
})
|
)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setRedirects,
|
setRedirects,
|
||||||
redirect,
|
redirect,
|
||||||
switchInstance,
|
switchInstance,
|
||||||
initDefaults,
|
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 = {
|
const frontends = new Array("simpleertube")
|
||||||
"simpleertube": {
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
"normal": [
|
|
||||||
"https://tube.simple-web.org",
|
let redirects = {}
|
||||||
"https://tube.ftild3.org",
|
|
||||||
"https://stube.alefvanoon.xyz",
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
"https://st.phreedom.club",
|
redirects[frontends[i]] = {}
|
||||||
"https://simpleertube.esmailelbob.xyz",
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
],
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
"tor": [],
|
}
|
||||||
"i2p": [],
|
|
||||||
"loki": []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRedirects(val) {
|
function setRedirects(val) {
|
||||||
redirects.simpleertube = val;
|
browser.storage.local.get("cloudflareBlackList", r => {
|
||||||
browser.storage.local.set({ peertubeTargetsRedirects: redirects })
|
redirects.simpleertube = val
|
||||||
for (const item of simpleertubeNormalRedirectsChecks)
|
simpleertubeNormalRedirectsChecks = [...redirects.simpleertube.normal]
|
||||||
if (!redirects.simpleertube.normal.includes(item)) {
|
for (const instance of r.cloudflareBlackList) {
|
||||||
var index = simpleertubeNormalRedirectsChecks.indexOf(item);
|
const a = simpleertubeNormalRedirectsChecks.indexOf(instance)
|
||||||
if (index !== -1) simpleertubeNormalRedirectsChecks.splice(index, 1);
|
if (a > -1) simpleertubeNormalRedirectsChecks.splice(a, 1)
|
||||||
}
|
}
|
||||||
browser.storage.local.set({ simpleertubeNormalRedirectsChecks })
|
browser.storage.local.set({
|
||||||
|
peertubeRedirects: redirects,
|
||||||
for (const item of simpleertubeTorRedirectsChecks)
|
simpleertubeNormalRedirectsChecks,
|
||||||
if (!redirects.simpleertube.normal.includes(item)) {
|
})
|
||||||
var index = simpleertubeTorRedirectsChecks.indexOf(item);
|
})
|
||||||
if (index !== -1) simpleertubeTorRedirectsChecks.splice(index, 1);
|
|
||||||
}
|
|
||||||
browser.storage.local.set({ simpleertubeTorRedirectsChecks })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let disablePeertubeTargets,
|
||||||
disablePeertubeTargets,
|
peertubeRedirects,
|
||||||
peertubeRedirects,
|
simpleertubeNormalRedirectsChecks,
|
||||||
simpleertubeNormalRedirectsChecks,
|
simpleertubeNormalCustomRedirects,
|
||||||
simpleertubeNormalCustomRedirects,
|
simpleertubeTorRedirectsChecks,
|
||||||
simpleertubeTorRedirectsChecks,
|
simpleertubeTorCustomRedirects,
|
||||||
simpleertubeTorCustomRedirects,
|
simpleertubeI2pRedirectsChecks,
|
||||||
simpleertubeI2pCustomRedirects,
|
simpleertubeI2pCustomRedirects,
|
||||||
simpleertubeLokiCustomRedirects,
|
simpleertubeLokiRedirectsChecks,
|
||||||
peerTubeTargets,
|
simpleertubeLokiCustomRedirects,
|
||||||
protocol,
|
peerTubeTargets,
|
||||||
protocolFallback;
|
protocol,
|
||||||
|
protocolFallback
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disablePeertubeTargets",
|
"disablePeertubeTargets",
|
||||||
"peertubeRedirects",
|
"peertubeRedirects",
|
||||||
"simpleertubeNormalRedirectsChecks",
|
"simpleertubeNormalRedirectsChecks",
|
||||||
"simpleertubeNormalCustomRedirects",
|
"simpleertubeNormalCustomRedirects",
|
||||||
"simpleertubeTorRedirectsChecks",
|
"simpleertubeTorRedirectsChecks",
|
||||||
"simpleertubeTorCustomRedirects",
|
"simpleertubeTorCustomRedirects",
|
||||||
"simpleertubeI2pCustomRedirects",
|
"simpleertubeI2pRedirectsChecks",
|
||||||
"simpleertubeLokiCustomRedirects",
|
"simpleertubeI2pCustomRedirects",
|
||||||
"peerTubeTargets",
|
"simpleertubeLokiRedirectsChecks",
|
||||||
"protocol",
|
"simpleertubeLokiCustomRedirects",
|
||||||
"protocolFallback"
|
"peerTubeTargets",
|
||||||
],
|
"protocol",
|
||||||
r => {
|
"protocolFallback",
|
||||||
disablePeertubeTargets = r.disablePeertubeTargets;
|
],
|
||||||
peertubeRedirects = r.peertubeRedirects;
|
r => {
|
||||||
simpleertubeNormalRedirectsChecks = r.simpleertubeNormalRedirectsChecks;
|
disablePeertubeTargets = r.disablePeertubeTargets
|
||||||
simpleertubeNormalCustomRedirects = r.simpleertubeNormalCustomRedirects;
|
peertubeRedirects = r.peertubeRedirects
|
||||||
simpleertubeTorRedirectsChecks = r.simpleertubeTorRedirectsChecks;
|
simpleertubeNormalRedirectsChecks = r.simpleertubeNormalRedirectsChecks
|
||||||
simpleertubeTorCustomRedirects = r.simpleertubeTorCustomRedirects;
|
simpleertubeNormalCustomRedirects = r.simpleertubeNormalCustomRedirects
|
||||||
simpleertubeI2pCustomRedirects = r.simpleertubeI2pCustomRedirects;
|
simpleertubeTorRedirectsChecks = r.simpleertubeTorRedirectsChecks
|
||||||
simpleertubeLokiCustomRedirects = r.simpleertubeLokiCustomRedirects;
|
simpleertubeTorCustomRedirects = r.simpleertubeTorCustomRedirects
|
||||||
peerTubeTargets = r.peerTubeTargets;
|
simpleertubeI2pRedirectsChecks = r.simpleertubeI2pRedirectsChecks
|
||||||
protocol = r.protocol;
|
simpleertubeI2pCustomRedirects = r.simpleertubeI2pCustomRedirects
|
||||||
protocolFallback = r.protocolFallback;
|
simpleertubeLokiRedirectsChecks = r.simpleertubeLokiRedirectsChecks
|
||||||
resolve();
|
simpleertubeLokiCustomRedirects = r.simpleertubeLokiCustomRedirects
|
||||||
}
|
peerTubeTargets = r.peerTubeTargets
|
||||||
)
|
protocol = r.protocol
|
||||||
})
|
protocolFallback = r.protocolFallback
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
function all() {
|
function all() {
|
||||||
return [
|
return [
|
||||||
...redirects.simpleertube.normal,
|
...simpleertubeNormalRedirectsChecks,
|
||||||
...redirects.simpleertube.tor,
|
...simpleertubeTorRedirectsChecks,
|
||||||
...simpleertubeNormalCustomRedirects,
|
...simpleertubeI2pRedirectsChecks,
|
||||||
...simpleertubeTorCustomRedirects,
|
...simpleertubeLokiRedirectsChecks,
|
||||||
...simpleertubeI2pCustomRedirects,
|
...simpleertubeNormalCustomRedirects,
|
||||||
...simpleertubeLokiCustomRedirects
|
...simpleertubeTorCustomRedirects,
|
||||||
];
|
...simpleertubeI2pCustomRedirects,
|
||||||
|
...simpleertubeLokiCustomRedirects,
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirect(url, type, initiator, disableOverride) {
|
function redirect(url, type, initiator, disableOverride) {
|
||||||
if (disablePeertubeTargets && !disableOverride) return;
|
if (disablePeertubeTargets && !disableOverride) return
|
||||||
if (initiator && (all().includes(initiator.origin) || peerTubeTargets.includes(initiator.host))) return;
|
if (initiator && (all().includes(initiator.origin) || peerTubeTargets.includes(initiator.host))) return
|
||||||
let protocolHost = utils.protocolHost(url);
|
let protocolHost = utils.protocolHost(url)
|
||||||
if (!peerTubeTargets.includes(protocolHost)) return;
|
if (!peerTubeTargets.includes(protocolHost)) return
|
||||||
if (type != "main_frame") return;
|
if (type != "main_frame") return
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...simpleertubeLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...simpleertubeLokiRedirectsChecks, ...simpleertubeLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...simpleertubeI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...simpleertubeI2pRedirectsChecks, ...simpleertubeI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects];
|
instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) { return; }
|
if (instancesList.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
if (url.host == 'search.joinpeertube.org' || url.host == 'sepiasearch.org') return randomInstance;
|
if (url.host == "search.joinpeertube.org" || url.host == "sepiasearch.org") return randomInstance
|
||||||
return `${randomInstance}/${url.host}${url.pathname}${url.search}`;
|
return `${randomInstance}/${url.host}${url.pathname}${url.search}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchInstance(url, disableOverride) {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disablePeertubeTargets && !disableOverride) { resolve(); return; }
|
if (disablePeertubeTargets && !disableOverride) {
|
||||||
const protocolHost = utils.protocolHost(url);
|
resolve()
|
||||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
return
|
||||||
|
}
|
||||||
|
const protocolHost = utils.protocolHost(url)
|
||||||
|
if (!all().includes(protocolHost)) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...simpleertubeLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...simpleertubeLokiRedirectsChecks, ...simpleertubeLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...simpleertubeI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...simpleertubeI2pRedirectsChecks, ...simpleertubeI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...simpleertubeTorRedirectsChecks, ...simpleertubeTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects];
|
instancesList = [...simpleertubeNormalRedirectsChecks, ...simpleertubeNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
|
|
||||||
const i = instancesList.indexOf(protocolHost);
|
const i = instancesList.indexOf(protocolHost)
|
||||||
if (i > -1) instancesList.splice(i, 1);
|
if (i > -1) instancesList.splice(i, 1)
|
||||||
if (instancesList.length === 0) { resolve(); return; }
|
if (instancesList.length === 0) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaults() {
|
function initDefaults() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
fetch("/instances/data.json")
|
||||||
let dataJson = JSON.parse(data);
|
.then(response => response.text())
|
||||||
browser.storage.local.get('cloudflareBlackList', async r => {
|
.then(data => {
|
||||||
simpleertubeNormalRedirectsChecks = [...redirects.simpleertube.normal];
|
let dataJson = JSON.parse(data)
|
||||||
for (const instance of r.cloudflareBlackList) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
let i = simpleertubeNormalRedirectsChecks.indexOf(instance);
|
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||||
if (i > -1) simpleertubeNormalRedirectsChecks.splice(i, 1);
|
}
|
||||||
}
|
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||||
browser.storage.local.set({
|
simpleertubeNormalRedirectsChecks = [...redirects.simpleertube.normal]
|
||||||
peerTubeTargets: ['https://search.joinpeertube.org', ...dataJson.peertube],
|
for (const instance of r.cloudflareBlackList) {
|
||||||
disablePeertubeTargets: true,
|
let i = simpleertubeNormalRedirectsChecks.indexOf(instance)
|
||||||
peertubeRedirects: redirects,
|
if (i > -1) simpleertubeNormalRedirectsChecks.splice(i, 1)
|
||||||
|
}
|
||||||
|
browser.storage.local.set(
|
||||||
|
{
|
||||||
|
peerTubeTargets: ["https://search.joinpeertube.org", ...dataJson.peertube],
|
||||||
|
disablePeertubeTargets: true,
|
||||||
|
peertubeRedirects: redirects,
|
||||||
|
|
||||||
simpleertubeNormalRedirectsChecks: simpleertubeNormalRedirectsChecks,
|
simpleertubeNormalRedirectsChecks: simpleertubeNormalRedirectsChecks,
|
||||||
simpleertubeNormalCustomRedirects: [],
|
simpleertubeNormalCustomRedirects: [],
|
||||||
|
|
||||||
simpleertubeTorRedirectsChecks: [...redirects.simpleertube.tor],
|
simpleertubeTorRedirectsChecks: [...redirects.simpleertube.tor],
|
||||||
simpleertubeTorCustomRedirects: [],
|
simpleertubeTorCustomRedirects: [],
|
||||||
|
|
||||||
simpleertubeI2pRedirectsChecks: [...redirects.simpleertube.i2p],
|
simpleertubeI2pRedirectsChecks: [...redirects.simpleertube.i2p],
|
||||||
simpleertubeI2pCustomRedirects: [],
|
simpleertubeI2pCustomRedirects: [],
|
||||||
|
|
||||||
simpleertubeLokiRedirectsChecks: [...redirects.simpleertube.loki],
|
simpleertubeLokiRedirectsChecks: [...redirects.simpleertube.loki],
|
||||||
simpleertubeLokiCustomRedirects: []
|
simpleertubeLokiCustomRedirects: [],
|
||||||
}, () => resolve());
|
},
|
||||||
})
|
() => resolve()
|
||||||
})
|
)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setRedirects,
|
setRedirects,
|
||||||
switchInstance,
|
switchInstance,
|
||||||
redirect,
|
redirect,
|
||||||
initDefaults,
|
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 = [
|
const targets = [/^https?:\/{2}(www\.|)quora\.com.*/]
|
||||||
/^https?:\/{2}(www\.|)quora\.com.*/
|
|
||||||
];
|
|
||||||
|
|
||||||
let redirects = {}
|
let redirects = {}
|
||||||
|
|
||||||
|
@ -12,183 +10,183 @@ const frontends = new Array("quetre")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
redirects[frontends[i]] = {}
|
redirects[frontends[i]] = {}
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
redirects[frontends[i]][protocols[x]] = []
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRedirects(val) {
|
function setRedirects(val) {
|
||||||
browser.storage.local.get('cloudflareBlackList', r => {
|
browser.storage.local.get("cloudflareBlackList", r => {
|
||||||
redirects.quetre = val;
|
redirects.quetre = val
|
||||||
quetreNormalRedirectsChecks = [...redirects.quetre.normal];
|
quetreNormalRedirectsChecks = [...redirects.quetre.normal]
|
||||||
for (const instance of r.cloudflareBlackList) {
|
for (const instance of r.cloudflareBlackList) {
|
||||||
const a = quetreNormalRedirectsChecks.indexOf(instance);
|
const a = quetreNormalRedirectsChecks.indexOf(instance)
|
||||||
if (a > -1) quetreNormalRedirectsChecks.splice(a, 1);
|
if (a > -1) quetreNormalRedirectsChecks.splice(a, 1)
|
||||||
}
|
}
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
quoraRedirects: redirects,
|
quoraRedirects: redirects,
|
||||||
quetreNormalRedirectsChecks
|
quetreNormalRedirectsChecks,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let disableQuora,
|
||||||
disableQuora,
|
protocol,
|
||||||
protocol,
|
protocolFallback,
|
||||||
protocolFallback,
|
quoraRedirects,
|
||||||
quoraRedirects,
|
quetreNormalRedirectsChecks,
|
||||||
quetreNormalRedirectsChecks,
|
quetreNormalCustomRedirects,
|
||||||
quetreNormalCustomRedirects,
|
quetreTorRedirectsChecks,
|
||||||
quetreTorRedirectsChecks,
|
quetreTorCustomRedirects,
|
||||||
quetreTorCustomRedirects,
|
quetreI2pCustomRedirects,
|
||||||
quetreI2pCustomRedirects,
|
quetreLokiCustomRedirects
|
||||||
quetreLokiCustomRedirects;
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disableQuora",
|
"disableQuora",
|
||||||
"protocol",
|
"protocol",
|
||||||
"protocolFallback",
|
"protocolFallback",
|
||||||
"quoraRedirects",
|
"quoraRedirects",
|
||||||
"quetreNormalRedirectsChecks",
|
"quetreNormalRedirectsChecks",
|
||||||
"quetreNormalCustomRedirects",
|
"quetreNormalCustomRedirects",
|
||||||
"quetreTorRedirectsChecks",
|
"quetreTorRedirectsChecks",
|
||||||
"quetreTorCustomRedirects",
|
"quetreTorCustomRedirects",
|
||||||
"quetreI2pCustomRedirects",
|
"quetreI2pCustomRedirects",
|
||||||
"quetreLokiCustomRedirects"
|
"quetreLokiCustomRedirects",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
disableQuora = r.disableQuora;
|
disableQuora = r.disableQuora
|
||||||
protocol = r.protocol;
|
protocol = r.protocol
|
||||||
protocolFallback = r.protocolFallback;
|
protocolFallback = r.protocolFallback
|
||||||
quoraRedirects = r.quoraRedirects;
|
quoraRedirects = r.quoraRedirects
|
||||||
quetreNormalRedirectsChecks = r.quetreNormalRedirectsChecks;
|
quetreNormalRedirectsChecks = r.quetreNormalRedirectsChecks
|
||||||
quetreNormalCustomRedirects = r.quetreNormalCustomRedirects;
|
quetreNormalCustomRedirects = r.quetreNormalCustomRedirects
|
||||||
quetreTorRedirectsChecks = r.quetreTorRedirectsChecks;
|
quetreTorRedirectsChecks = r.quetreTorRedirectsChecks
|
||||||
quetreTorCustomRedirects = r.quetreTorCustomRedirects;
|
quetreTorCustomRedirects = r.quetreTorCustomRedirects
|
||||||
quetreI2pCustomRedirects = r.quetreI2pCustomRedirects;
|
quetreI2pCustomRedirects = r.quetreI2pCustomRedirects
|
||||||
quetreLokiCustomRedirects = r.quetreLokiCustomRedirects;
|
quetreLokiCustomRedirects = r.quetreLokiCustomRedirects
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
function redirect(url, type, initiator, disableOverride) {
|
function redirect(url, type, initiator, disableOverride) {
|
||||||
if (disableQuora && !disableOverride) return;
|
if (disableQuora && !disableOverride) return
|
||||||
if (url.pathname == "/" && !disableOverride) return;
|
if (url.pathname == "/" && !disableOverride) return
|
||||||
if (type != "main_frame") return;
|
if (type != "main_frame") return
|
||||||
const all = [
|
const all = [...quoraRedirects.quetre.normal, ...quetreNormalCustomRedirects]
|
||||||
...quoraRedirects.quetre.normal,
|
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return
|
||||||
...quetreNormalCustomRedirects
|
if (!targets.some(rx => rx.test(url.href))) return
|
||||||
];
|
|
||||||
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return;
|
|
||||||
if (!targets.some(rx => rx.test(url.href))) return;
|
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...quetreLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...quetreLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...quetreI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...quetreI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...quetreNormalRedirectsChecks, ...quetreNormalCustomRedirects];
|
instancesList = [...quetreNormalRedirectsChecks, ...quetreNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) { return; }
|
if (instancesList.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
return `${randomInstance}${url.pathname}`;
|
return `${randomInstance}${url.pathname}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function reverse(url) {
|
function reverse(url) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
let protocolHost = utils.protocolHost(url);
|
let protocolHost = utils.protocolHost(url)
|
||||||
const all = [
|
const all = [...quoraRedirects.quetre.normal, ...quoraRedirects.quetre.tor, ...quetreNormalCustomRedirects, ...quetreTorCustomRedirects, ...quetreI2pCustomRedirects, ...quetreLokiCustomRedirects]
|
||||||
...quoraRedirects.quetre.normal,
|
if (!all.includes(protocolHost)) {
|
||||||
...quoraRedirects.quetre.tor,
|
resolve()
|
||||||
...quetreNormalCustomRedirects,
|
return
|
||||||
...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) {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableQuora && !disableOverride) { resolve(); return; }
|
if (disableQuora && !disableOverride) {
|
||||||
let protocolHost = utils.protocolHost(url);
|
resolve()
|
||||||
const all = [
|
return
|
||||||
...quoraRedirects.quetre.tor,
|
}
|
||||||
...quoraRedirects.quetre.normal,
|
let protocolHost = utils.protocolHost(url)
|
||||||
|
const all = [...quoraRedirects.quetre.tor, ...quoraRedirects.quetre.normal, ...quetreNormalCustomRedirects, ...quetreTorCustomRedirects, ...quetreI2pCustomRedirects, ...quetreLokiCustomRedirects]
|
||||||
|
if (!all.includes(protocolHost)) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
...quetreNormalCustomRedirects,
|
let instancesList = []
|
||||||
...quetreTorCustomRedirects,
|
if (protocol == "loki") instancesList = [...quetreLokiCustomRedirects]
|
||||||
...quetreI2pCustomRedirects,
|
else if (protocol == "i2p") instancesList = [...quetreI2pCustomRedirects]
|
||||||
...quetreLokiCustomRedirects
|
else if (protocol == "tor") instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects]
|
||||||
];
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
instancesList = [...quetreNormalRedirectsChecks, ...quetreNormalCustomRedirects]
|
||||||
|
}
|
||||||
|
|
||||||
let instancesList = [];
|
const i = instancesList.indexOf(protocolHost)
|
||||||
if (protocol == 'loki') instancesList = [...quetreLokiCustomRedirects];
|
if (i > -1) instancesList.splice(i, 1)
|
||||||
else if (protocol == 'i2p') instancesList = [...quetreI2pCustomRedirects];
|
if (instancesList.length === 0) {
|
||||||
else if (protocol == 'tor') instancesList = [...quetreTorRedirectsChecks, ...quetreTorCustomRedirects];
|
resolve()
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
return
|
||||||
instancesList = [...quetreNormalRedirectsChecks, ...quetreNormalCustomRedirects];
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const i = instancesList.indexOf(protocolHost);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
if (i > -1) instancesList.splice(i, 1);
|
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||||
if (instancesList.length === 0) { resolve(); return; }
|
})
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
|
||||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaults() {
|
function initDefaults() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
fetch("/instances/data.json")
|
||||||
let dataJson = JSON.parse(data);
|
.then(response => response.text())
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
.then(async data => {
|
||||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
let dataJson = JSON.parse(data)
|
||||||
}
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
browser.storage.local.set({
|
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||||
disableQuora: false,
|
}
|
||||||
|
browser.storage.local.set(
|
||||||
|
{
|
||||||
|
disableQuora: false,
|
||||||
|
|
||||||
quoraRedirects: redirects,
|
quoraRedirects: redirects,
|
||||||
|
|
||||||
quetreNormalRedirectsChecks: [...redirects.quetre.normal],
|
quetreNormalRedirectsChecks: [...redirects.quetre.normal],
|
||||||
quetreNormalCustomRedirects: [],
|
quetreNormalCustomRedirects: [],
|
||||||
|
|
||||||
quetreTorRedirectsChecks: [...redirects.quetre.tor],
|
quetreTorRedirectsChecks: [...redirects.quetre.tor],
|
||||||
quetreTorCustomRedirects: [],
|
quetreTorCustomRedirects: [],
|
||||||
|
|
||||||
quetreI2pRedirectsChecks: [...redirects.quetre.i2p],
|
quetreI2pRedirectsChecks: [...redirects.quetre.i2p],
|
||||||
quetreI2pCustomRedirects: [],
|
quetreI2pCustomRedirects: [],
|
||||||
|
|
||||||
quetreLokiRedirectsChecks: [...redirects.quetre.loki],
|
quetreLokiRedirectsChecks: [...redirects.quetre.loki],
|
||||||
quetreLokiCustomRedirects: []
|
quetreLokiCustomRedirects: [],
|
||||||
}, () => resolve());
|
},
|
||||||
});
|
() => resolve()
|
||||||
})
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setRedirects,
|
setRedirects,
|
||||||
|
|
||||||
redirect,
|
redirect,
|
||||||
reverse,
|
reverse,
|
||||||
switchInstance,
|
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 = [
|
const targets = [/^https?:\/{2}(www\.|old\.|np\.|new\.|amp\.|)reddit\.com/, /^https?:\/{2}(i\.|preview\.)redd\.it/]
|
||||||
/^https?:\/{2}(www\.|old\.|np\.|new\.|amp\.|)reddit\.com/,
|
let redirects = {}
|
||||||
/^https?:\/{2}(i\.|preview\.)redd\.it/,
|
|
||||||
];
|
|
||||||
let redirects = {};
|
|
||||||
|
|
||||||
const frontends = new Array("libreddit", "teddit")
|
const frontends = new Array("libreddit", "teddit")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
redirects[frontends[i]] = {}
|
redirects[frontends[i]] = {}
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
redirects[frontends[i]][protocols[x]] = []
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRedirects(val) {
|
function setRedirects(val) {
|
||||||
browser.storage.local.get('cloudflareBlackList', r => {
|
browser.storage.local.get("cloudflareBlackList", r => {
|
||||||
redirects = val;
|
redirects = val
|
||||||
libredditNormalRedirectsChecks = [...redirects.libreddit.normal];
|
libredditNormalRedirectsChecks = [...redirects.libreddit.normal]
|
||||||
tedditNormalRedirectsChecks = [...redirects.teddit.normal]
|
tedditNormalRedirectsChecks = [...redirects.teddit.normal]
|
||||||
for (const instance of r.cloudflareBlackList) {
|
for (const instance of r.cloudflareBlackList) {
|
||||||
const a = libredditNormalRedirectsChecks.indexOf(instance);
|
const a = libredditNormalRedirectsChecks.indexOf(instance)
|
||||||
if (a > -1) libredditNormalRedirectsChecks.splice(a, 1);
|
if (a > -1) libredditNormalRedirectsChecks.splice(a, 1)
|
||||||
|
|
||||||
const b = tedditNormalRedirectsChecks.indexOf(instance);
|
const b = tedditNormalRedirectsChecks.indexOf(instance)
|
||||||
if (b > -1) tedditNormalRedirectsChecks.splice(b, 1);
|
if (b > -1) tedditNormalRedirectsChecks.splice(b, 1)
|
||||||
}
|
}
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
redditRedirects: redirects,
|
redditRedirects: redirects,
|
||||||
libredditNormalRedirectsChecks,
|
libredditNormalRedirectsChecks,
|
||||||
tedditNormalRedirectsChecks
|
tedditNormalRedirectsChecks,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let disableReddit,
|
||||||
disableReddit,
|
redditFrontend,
|
||||||
redditFrontend,
|
redditRedirects,
|
||||||
redditRedirects,
|
protocol,
|
||||||
protocol,
|
protocolFallback,
|
||||||
protocolFallback,
|
libredditNormalRedirectsChecks,
|
||||||
|
libredditNormalCustomRedirects,
|
||||||
libredditNormalRedirectsChecks,
|
libredditTorRedirectsChecks,
|
||||||
libredditNormalCustomRedirects,
|
libredditTorCustomRedirects,
|
||||||
|
libredditI2pCustomRedirects,
|
||||||
libredditTorRedirectsChecks,
|
libredditLokiCustomRedirects,
|
||||||
libredditTorCustomRedirects,
|
tedditNormalRedirectsChecks,
|
||||||
|
tedditNormalCustomRedirects,
|
||||||
libredditI2pCustomRedirects,
|
tedditTorRedirectsChecks,
|
||||||
|
tedditTorCustomRedirects,
|
||||||
libredditLokiCustomRedirects,
|
tedditI2pCustomRedirects,
|
||||||
|
tedditLokiCustomRedirects
|
||||||
tedditNormalRedirectsChecks,
|
|
||||||
tedditNormalCustomRedirects,
|
|
||||||
|
|
||||||
tedditTorRedirectsChecks,
|
|
||||||
tedditTorCustomRedirects,
|
|
||||||
|
|
||||||
tedditI2pCustomRedirects,
|
|
||||||
tedditLokiCustomRedirects;
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disableReddit",
|
"disableReddit",
|
||||||
"redditFrontend",
|
"redditFrontend",
|
||||||
"redditRedirects",
|
"redditRedirects",
|
||||||
"protocol",
|
"protocol",
|
||||||
"protocolFallback",
|
"protocolFallback",
|
||||||
"libredditNormalRedirectsChecks",
|
"libredditNormalRedirectsChecks",
|
||||||
"libredditNormalCustomRedirects",
|
"libredditNormalCustomRedirects",
|
||||||
"libredditTorRedirectsChecks",
|
"libredditTorRedirectsChecks",
|
||||||
"libredditTorCustomRedirects",
|
"libredditTorCustomRedirects",
|
||||||
"libredditI2pCustomRedirects",
|
"libredditI2pCustomRedirects",
|
||||||
"libredditLokiCustomRedirects",
|
"libredditLokiCustomRedirects",
|
||||||
"tedditNormalRedirectsChecks",
|
"tedditNormalRedirectsChecks",
|
||||||
"tedditNormalCustomRedirects",
|
"tedditNormalCustomRedirects",
|
||||||
"tedditTorRedirectsChecks",
|
"tedditTorRedirectsChecks",
|
||||||
"tedditTorCustomRedirects",
|
"tedditTorCustomRedirects",
|
||||||
"tedditI2pCustomRedirects",
|
"tedditI2pCustomRedirects",
|
||||||
"tedditLokiCustomRedirects"
|
"tedditLokiCustomRedirects",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
disableReddit = r.disableReddit;
|
disableReddit = r.disableReddit
|
||||||
redditFrontend = r.redditFrontend;
|
redditFrontend = r.redditFrontend
|
||||||
redditRedirects = r.redditRedirects;
|
redditRedirects = r.redditRedirects
|
||||||
protocol = r.protocol;
|
protocol = r.protocol
|
||||||
protocolFallback = r.protocolFallback;
|
protocolFallback = r.protocolFallback
|
||||||
libredditNormalRedirectsChecks = r.libredditNormalRedirectsChecks;
|
libredditNormalRedirectsChecks = r.libredditNormalRedirectsChecks
|
||||||
libredditNormalCustomRedirects = r.libredditNormalCustomRedirects;
|
libredditNormalCustomRedirects = r.libredditNormalCustomRedirects
|
||||||
libredditTorRedirectsChecks = r.libredditTorRedirectsChecks;
|
libredditTorRedirectsChecks = r.libredditTorRedirectsChecks
|
||||||
libredditTorCustomRedirects = r.libredditTorCustomRedirects;
|
libredditTorCustomRedirects = r.libredditTorCustomRedirects
|
||||||
libredditI2pCustomRedirects = r.libredditI2pCustomRedirects;
|
libredditI2pCustomRedirects = r.libredditI2pCustomRedirects
|
||||||
libredditLokiCustomRedirects = r.libredditLokiCustomRedirects;
|
libredditLokiCustomRedirects = r.libredditLokiCustomRedirects
|
||||||
tedditNormalRedirectsChecks = r.tedditNormalRedirectsChecks;
|
tedditNormalRedirectsChecks = r.tedditNormalRedirectsChecks
|
||||||
tedditNormalCustomRedirects = r.tedditNormalCustomRedirects;
|
tedditNormalCustomRedirects = r.tedditNormalCustomRedirects
|
||||||
tedditTorRedirectsChecks = r.tedditTorRedirectsChecks;
|
tedditTorRedirectsChecks = r.tedditTorRedirectsChecks
|
||||||
tedditTorCustomRedirects = r.tedditTorCustomRedirects;
|
tedditTorCustomRedirects = r.tedditTorCustomRedirects
|
||||||
tedditI2pCustomRedirects = r.tedditI2pCustomRedirects;
|
tedditI2pCustomRedirects = r.tedditI2pCustomRedirects
|
||||||
tedditLokiCustomRedirects = r.tedditLokiCustomRedirects;
|
tedditLokiCustomRedirects = r.tedditLokiCustomRedirects
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
function initLibredditCookies(test, from) {
|
function initLibredditCookies(test, from) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
const protocolHost = utils.protocolHost(from);
|
const protocolHost = utils.protocolHost(from)
|
||||||
if (![
|
if (
|
||||||
...libredditNormalRedirectsChecks,
|
![
|
||||||
...libredditTorRedirectsChecks,
|
...libredditNormalRedirectsChecks,
|
||||||
...libredditNormalCustomRedirects,
|
...libredditTorRedirectsChecks,
|
||||||
...libredditTorCustomRedirects,
|
...libredditNormalCustomRedirects,
|
||||||
...libredditI2pCustomRedirects,
|
...libredditTorCustomRedirects,
|
||||||
...libredditLokiCustomRedirects
|
...libredditI2pCustomRedirects,
|
||||||
].includes(protocolHost)) { resolve(); return; }
|
...libredditLokiCustomRedirects,
|
||||||
|
].includes(protocolHost)
|
||||||
|
) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!test) {
|
if (!test) {
|
||||||
let checkedInstances = [];
|
let checkedInstances = []
|
||||||
if (protocol == 'loki') checkedInstances = [...libredditLokiCustomRedirects];
|
if (protocol == "loki") checkedInstances = [...libredditLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') checkedInstances = [...libredditI2pCustomRedirects];
|
else if (protocol == "i2p") checkedInstances = [...libredditI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects];
|
else if (protocol == "tor") checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]
|
||||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects];
|
checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
await utils.copyCookie('libreddit', from, checkedInstances, "theme");
|
await utils.copyCookie("libreddit", from, checkedInstances, "theme")
|
||||||
await utils.copyCookie('libreddit', from, checkedInstances, "front_page");
|
await utils.copyCookie("libreddit", from, checkedInstances, "front_page")
|
||||||
await utils.copyCookie('libreddit', from, checkedInstances, "layout");
|
await utils.copyCookie("libreddit", from, checkedInstances, "layout")
|
||||||
await utils.copyCookie('libreddit', from, checkedInstances, "wide");
|
await utils.copyCookie("libreddit", from, checkedInstances, "wide")
|
||||||
await utils.copyCookie('libreddit', from, checkedInstances, "post_sort");
|
await utils.copyCookie("libreddit", from, checkedInstances, "post_sort")
|
||||||
await utils.copyCookie('libreddit', from, checkedInstances, "comment_sort");
|
await utils.copyCookie("libreddit", from, checkedInstances, "comment_sort")
|
||||||
await utils.copyCookie('libreddit', from, checkedInstances, "show_nsfw");
|
await utils.copyCookie("libreddit", from, checkedInstances, "show_nsfw")
|
||||||
await utils.copyCookie('libreddit', from, checkedInstances, "autoplay_videos");
|
await utils.copyCookie("libreddit", from, checkedInstances, "autoplay_videos")
|
||||||
await utils.copyCookie('libreddit', from, checkedInstances, "use_hls");
|
await utils.copyCookie("libreddit", from, checkedInstances, "use_hls")
|
||||||
await utils.copyCookie('libreddit', from, checkedInstances, "hide_hls_notification");
|
await utils.copyCookie("libreddit", from, checkedInstances, "hide_hls_notification")
|
||||||
await utils.copyCookie('libreddit', from, checkedInstances, "subscriptions");
|
await utils.copyCookie("libreddit", from, checkedInstances, "subscriptions")
|
||||||
await utils.copyCookie('libreddit', from, checkedInstances, "filters");
|
await utils.copyCookie("libreddit", from, checkedInstances, "filters")
|
||||||
}
|
}
|
||||||
resolve(true);
|
resolve(true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function pasteLibredditCookies() {
|
function pasteLibredditCookies() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableReddit || redditFrontend != 'libreddit' || protocol === undefined) { resolve(); return; }
|
if (disableReddit || redditFrontend != "libreddit" || protocol === undefined) {
|
||||||
let checkedInstances = [];
|
resolve()
|
||||||
if (protocol == 'loki') checkedInstances = [...libredditLokiCustomRedirects];
|
return
|
||||||
else if (protocol == 'i2p') checkedInstances = [...libredditI2pCustomRedirects];
|
}
|
||||||
else if (protocol == 'tor') checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects];
|
let checkedInstances = []
|
||||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
if (protocol == "loki") checkedInstances = [...libredditLokiCustomRedirects]
|
||||||
checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects];
|
else if (protocol == "i2p") checkedInstances = [...libredditI2pCustomRedirects]
|
||||||
}
|
else if (protocol == "tor") checkedInstances = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]
|
||||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "theme");
|
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "front_page");
|
checkedInstances = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]
|
||||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "layout");
|
}
|
||||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "wide");
|
utils.getCookiesFromStorage("libreddit", checkedInstances, "theme")
|
||||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "post_sort");
|
utils.getCookiesFromStorage("libreddit", checkedInstances, "front_page")
|
||||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "comment_sort");
|
utils.getCookiesFromStorage("libreddit", checkedInstances, "layout")
|
||||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "show_nsfw");
|
utils.getCookiesFromStorage("libreddit", checkedInstances, "wide")
|
||||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "autoplay_videos");
|
utils.getCookiesFromStorage("libreddit", checkedInstances, "post_sort")
|
||||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "use_hls");
|
utils.getCookiesFromStorage("libreddit", checkedInstances, "comment_sort")
|
||||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "hide_hls_notification");
|
utils.getCookiesFromStorage("libreddit", checkedInstances, "show_nsfw")
|
||||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "subscriptions");
|
utils.getCookiesFromStorage("libreddit", checkedInstances, "autoplay_videos")
|
||||||
utils.getCookiesFromStorage('libreddit', checkedInstances, "filters");
|
utils.getCookiesFromStorage("libreddit", checkedInstances, "use_hls")
|
||||||
resolve();
|
utils.getCookiesFromStorage("libreddit", checkedInstances, "hide_hls_notification")
|
||||||
})
|
utils.getCookiesFromStorage("libreddit", checkedInstances, "subscriptions")
|
||||||
|
utils.getCookiesFromStorage("libreddit", checkedInstances, "filters")
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function initTedditCookies(test, from) {
|
function initTedditCookies(test, from) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
let protocolHost = utils.protocolHost(from);
|
let protocolHost = utils.protocolHost(from)
|
||||||
if (![
|
if (
|
||||||
...tedditNormalRedirectsChecks,
|
![...tedditNormalRedirectsChecks, ...tedditTorRedirectsChecks, ...tedditNormalCustomRedirects, ...tedditTorCustomRedirects, ...tedditI2pCustomRedirects, ...tedditI2pCustomRedirects].includes(
|
||||||
...tedditTorRedirectsChecks,
|
protocolHost
|
||||||
...tedditNormalCustomRedirects,
|
)
|
||||||
...tedditTorCustomRedirects,
|
)
|
||||||
...tedditI2pCustomRedirects,
|
resolve()
|
||||||
...tedditI2pCustomRedirects
|
|
||||||
|
|
||||||
].includes(protocolHost)) resolve();
|
if (!test) {
|
||||||
|
let checkedInstances = []
|
||||||
if (!test) {
|
if (protocol == "loki") checkedInstances = [...tedditLokiCustomRedirects]
|
||||||
let checkedInstances = [];
|
else if (protocol == "i2p") checkedInstances = [...tedditI2pCustomRedirects]
|
||||||
if (protocol == 'loki') checkedInstances = [...tedditLokiCustomRedirects];
|
else if (protocol == "tor") checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]
|
||||||
else if (protocol == 'i2p') checkedInstances = [...tedditI2pCustomRedirects];
|
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
else if (protocol == 'tor') checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects];
|
checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]
|
||||||
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, 'collapse_child_comments')
|
await utils.copyCookie("teddit", from, checkedInstances, "domain_twitter")
|
||||||
await utils.copyCookie('teddit', from, checkedInstances, 'domain_instagram')
|
await utils.copyCookie("teddit", from, checkedInstances, "domain_youtube")
|
||||||
await utils.copyCookie('teddit', from, checkedInstances, 'domain_twitter')
|
await utils.copyCookie("teddit", from, checkedInstances, "flairs")
|
||||||
await utils.copyCookie('teddit', from, checkedInstances, 'domain_youtube')
|
await utils.copyCookie("teddit", from, checkedInstances, "highlight_controversial")
|
||||||
await utils.copyCookie('teddit', from, checkedInstances, 'flairs')
|
await utils.copyCookie("teddit", from, checkedInstances, "nsfw_enabled")
|
||||||
await utils.copyCookie('teddit', from, checkedInstances, 'highlight_controversial')
|
await utils.copyCookie("teddit", from, checkedInstances, "post_media_max_height")
|
||||||
await utils.copyCookie('teddit', from, checkedInstances, 'nsfw_enabled')
|
await utils.copyCookie("teddit", from, checkedInstances, "show_upvoted_percentage")
|
||||||
await utils.copyCookie('teddit', from, checkedInstances, 'post_media_max_height')
|
await utils.copyCookie("teddit", from, checkedInstances, "show_upvotes")
|
||||||
await utils.copyCookie('teddit', from, checkedInstances, 'show_upvoted_percentage')
|
await utils.copyCookie("teddit", from, checkedInstances, "theme")
|
||||||
await utils.copyCookie('teddit', from, checkedInstances, 'show_upvotes')
|
await utils.copyCookie("teddit", from, checkedInstances, "videos_muted")
|
||||||
await utils.copyCookie('teddit', from, checkedInstances, 'theme')
|
}
|
||||||
await utils.copyCookie('teddit', from, checkedInstances, 'videos_muted')
|
resolve(true)
|
||||||
}
|
})
|
||||||
resolve(true);
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function pasteTedditCookies() {
|
function pasteTedditCookies() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableReddit || redditFrontend != 'teddit' || protocol === undefined) { resolve(); return; }
|
if (disableReddit || redditFrontend != "teddit" || protocol === undefined) {
|
||||||
let checkedInstances = [];
|
resolve()
|
||||||
if (protocol == 'loki') checkedInstances = [...tedditLokiCustomRedirects];
|
return
|
||||||
else if (protocol == 'i2p') checkedInstances = [...tedditI2pCustomRedirects];
|
}
|
||||||
else if (protocol == 'tor') checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects];
|
let checkedInstances = []
|
||||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
if (protocol == "loki") checkedInstances = [...tedditLokiCustomRedirects]
|
||||||
checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects];
|
else if (protocol == "i2p") checkedInstances = [...tedditI2pCustomRedirects]
|
||||||
}
|
else if (protocol == "tor") checkedInstances = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]
|
||||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'collapse_child_comments')
|
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'domain_instagram')
|
checkedInstances = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]
|
||||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'domain_twitter')
|
}
|
||||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'domain_youtube')
|
utils.getCookiesFromStorage("teddit", checkedInstances, "collapse_child_comments")
|
||||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'flairs')
|
utils.getCookiesFromStorage("teddit", checkedInstances, "domain_instagram")
|
||||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'highlight_controversial')
|
utils.getCookiesFromStorage("teddit", checkedInstances, "domain_twitter")
|
||||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'nsfw_enabled')
|
utils.getCookiesFromStorage("teddit", checkedInstances, "domain_youtube")
|
||||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'post_media_max_height')
|
utils.getCookiesFromStorage("teddit", checkedInstances, "flairs")
|
||||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'show_upvoted_percentage')
|
utils.getCookiesFromStorage("teddit", checkedInstances, "highlight_controversial")
|
||||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'show_upvotes')
|
utils.getCookiesFromStorage("teddit", checkedInstances, "nsfw_enabled")
|
||||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'theme')
|
utils.getCookiesFromStorage("teddit", checkedInstances, "post_media_max_height")
|
||||||
utils.getCookiesFromStorage('teddit', checkedInstances, 'videos_muted')
|
utils.getCookiesFromStorage("teddit", checkedInstances, "show_upvoted_percentage")
|
||||||
resolve();
|
utils.getCookiesFromStorage("teddit", checkedInstances, "show_upvotes")
|
||||||
})
|
utils.getCookiesFromStorage("teddit", checkedInstances, "theme")
|
||||||
|
utils.getCookiesFromStorage("teddit", checkedInstances, "videos_muted")
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function all() {
|
function all() {
|
||||||
return [
|
return [
|
||||||
...redditRedirects.libreddit.normal,
|
...redditRedirects.libreddit.normal,
|
||||||
...redditRedirects.libreddit.tor,
|
...redditRedirects.libreddit.tor,
|
||||||
...redditRedirects.teddit.normal,
|
...redditRedirects.teddit.normal,
|
||||||
...redditRedirects.teddit.tor,
|
...redditRedirects.teddit.tor,
|
||||||
...libredditNormalCustomRedirects,
|
...libredditNormalCustomRedirects,
|
||||||
...libredditTorCustomRedirects,
|
...libredditTorCustomRedirects,
|
||||||
...libredditI2pCustomRedirects,
|
...libredditI2pCustomRedirects,
|
||||||
...libredditLokiCustomRedirects,
|
...libredditLokiCustomRedirects,
|
||||||
...tedditNormalCustomRedirects,
|
...tedditNormalCustomRedirects,
|
||||||
...tedditTorCustomRedirects,
|
...tedditTorCustomRedirects,
|
||||||
...tedditI2pCustomRedirects,
|
...tedditI2pCustomRedirects,
|
||||||
...tedditLokiCustomRedirects
|
...tedditLokiCustomRedirects,
|
||||||
];
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://libreddit.exonip.de/vid/1mq8d0ma3yk81/720.mp4
|
// https://libreddit.exonip.de/vid/1mq8d0ma3yk81/720.mp4
|
||||||
|
@ -267,188 +264,189 @@ function all() {
|
||||||
// https://teddit.net/vids/1mq8d0ma3yk81.mp4
|
// https://teddit.net/vids/1mq8d0ma3yk81.mp4
|
||||||
// https://teddit.net/pics/w:null_4v3t1vgvrzk81.png
|
// https://teddit.net/pics/w:null_4v3t1vgvrzk81.png
|
||||||
|
|
||||||
|
|
||||||
// redd.it/t5379n
|
// redd.it/t5379n
|
||||||
// https://v.redd.it/z08avb339n801/DASH_1_2_M
|
// https://v.redd.it/z08avb339n801/DASH_1_2_M
|
||||||
// https://i.redd.it/bfkhs659tzk81.jpg
|
// https://i.redd.it/bfkhs659tzk81.jpg
|
||||||
function redirect(url, type, initiator, disableOverride) {
|
function redirect(url, type, initiator, disableOverride) {
|
||||||
if (disableReddit && !disableOverride) return;
|
if (disableReddit && !disableOverride) return
|
||||||
if (!targets.some(rx => rx.test(url.href))) return;
|
if (!targets.some(rx => rx.test(url.href))) return
|
||||||
if (initiator && all().includes(initiator.origin)) return 'BYPASSTAB';
|
if (initiator && all().includes(initiator.origin)) return "BYPASSTAB"
|
||||||
if (!["main_frame", "xmlhttprequest", "other", "image", "media"].includes(type)) return;
|
if (!["main_frame", "xmlhttprequest", "other", "image", "media"].includes(type)) return
|
||||||
const bypassPaths = /\/(gallery\/poll\/rpan\/settings\/topics)/;
|
const bypassPaths = /\/(gallery\/poll\/rpan\/settings\/topics)/
|
||||||
if (url.pathname.match(bypassPaths)) return;
|
if (url.pathname.match(bypassPaths)) return
|
||||||
|
|
||||||
let libredditInstancesList = [];
|
let libredditInstancesList = []
|
||||||
let tedditInstancesList = [];
|
let tedditInstancesList = []
|
||||||
|
|
||||||
if (protocol == 'loki') {
|
if (protocol == "loki") {
|
||||||
libredditInstancesList = [...libredditLokiCustomRedirects];
|
libredditInstancesList = [...libredditLokiCustomRedirects]
|
||||||
tedditInstancesList = [...tedditLokiCustomRedirects];
|
tedditInstancesList = [...tedditLokiCustomRedirects]
|
||||||
}
|
} else if (protocol == "i2p") {
|
||||||
else if (protocol == 'i2p') {
|
libredditInstancesList = [...libredditI2pCustomRedirects]
|
||||||
libredditInstancesList = [...libredditI2pCustomRedirects];
|
tedditInstancesList = [...tedditI2pCustomRedirects]
|
||||||
tedditInstancesList = [...tedditI2pCustomRedirects];
|
} else if (protocol == "tor") {
|
||||||
}
|
libredditInstancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]
|
||||||
else if (protocol == 'tor') {
|
tedditInstancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]
|
||||||
libredditInstancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects];
|
}
|
||||||
tedditInstancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects];
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
}
|
libredditInstancesList = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
tedditInstancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]
|
||||||
libredditInstancesList = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects];
|
}
|
||||||
tedditInstancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (url.host === "i.redd.it") {
|
if (url.host === "i.redd.it") {
|
||||||
if (redditFrontend == 'teddit') {
|
if (redditFrontend == "teddit") {
|
||||||
if (tedditInstancesList.length === 0) return;
|
if (tedditInstancesList.length === 0) return
|
||||||
let tedditRandomInstance = utils.getRandomInstance(tedditInstancesList);
|
let tedditRandomInstance = utils.getRandomInstance(tedditInstancesList)
|
||||||
return `${tedditRandomInstance}/pics/w:null_${url.pathname.substring(1)}${url.search}`;
|
return `${tedditRandomInstance}/pics/w:null_${url.pathname.substring(1)}${url.search}`
|
||||||
}
|
}
|
||||||
if (redditFrontend == 'libreddit') {
|
if (redditFrontend == "libreddit") {
|
||||||
if (libredditInstancesList.length === 0) return;
|
if (libredditInstancesList.length === 0) return
|
||||||
let libredditRandomInstance = utils.getRandomInstance(libredditInstancesList);
|
let libredditRandomInstance = utils.getRandomInstance(libredditInstancesList)
|
||||||
return `${libredditRandomInstance}/img${url.pathname}${url.search}`
|
return `${libredditRandomInstance}/img${url.pathname}${url.search}`
|
||||||
}
|
}
|
||||||
}
|
} else if (url.host === "redd.it") {
|
||||||
else if (url.host === "redd.it") {
|
if (redditFrontend == "libreddit" && !url.pathname.match(/^\/+[^\/]+\/+[^\/]/)) {
|
||||||
if (redditFrontend == 'libreddit' && !url.pathname.match(/^\/+[^\/]+\/+[^\/]/)) {
|
if (libredditInstancesList.length === 0) return
|
||||||
if (libredditInstancesList.length === 0) return;
|
let libredditRandomInstance = utils.getRandomInstance(libredditInstancesList)
|
||||||
let libredditRandomInstance = utils.getRandomInstance(libredditInstancesList);
|
// https://redd.it/foo => https://libredd.it/comments/foo
|
||||||
// https://redd.it/foo => https://libredd.it/comments/foo
|
return `${libredditRandomInstance}/comments${url.pathname}${url.search}`
|
||||||
return `${libredditRandomInstance}/comments${url.pathname}${url.search}`;
|
}
|
||||||
}
|
if (redditFrontend == "teddit" && !url.pathname.match(/^\/+[^\/]+\/+[^\/]/)) {
|
||||||
if (redditFrontend == 'teddit' && !url.pathname.match(/^\/+[^\/]+\/+[^\/]/)) {
|
if (tedditInstancesList.length === 0) return
|
||||||
if (tedditInstancesList.length === 0) return;
|
let tedditRandomInstance = utils.getRandomInstance(tedditInstancesList)
|
||||||
let tedditRandomInstance = utils.getRandomInstance(tedditInstancesList);
|
// https://redd.it/foo => https://teddit.net/comments/foo
|
||||||
// https://redd.it/foo => https://teddit.net/comments/foo
|
return `${tedditRandomInstance}/comments${url.pathname}${url.search}`
|
||||||
return `${tedditRandomInstance}/comments${url.pathname}${url.search}`
|
}
|
||||||
}
|
} else if (url.host === "preview.redd.it") {
|
||||||
}
|
if (redditFrontend == "teddit") return
|
||||||
else if (url.host === 'preview.redd.it') {
|
if (redditFrontend == "libreddit") {
|
||||||
if (redditFrontend == 'teddit') return;
|
if (libredditInstancesList.length === 0) return
|
||||||
if (redditFrontend == 'libreddit') {
|
const libredditRandomInstance = utils.getRandomInstance(libredditInstancesList)
|
||||||
if (libredditInstancesList.length === 0) return;
|
return `${libredditRandomInstance}/preview/pre${url.pathname}${url.search}`
|
||||||
const libredditRandomInstance = utils.getRandomInstance(libredditInstancesList);
|
}
|
||||||
return `${libredditRandomInstance}/preview/pre${url.pathname}${url.search}`;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let randomInstance;
|
let randomInstance
|
||||||
if (redditFrontend == 'libreddit') {
|
if (redditFrontend == "libreddit") {
|
||||||
if (libredditInstancesList.length === 0) return;
|
if (libredditInstancesList.length === 0) return
|
||||||
randomInstance = utils.getRandomInstance(libredditInstancesList);
|
randomInstance = utils.getRandomInstance(libredditInstancesList)
|
||||||
}
|
}
|
||||||
if (redditFrontend == 'teddit') {
|
if (redditFrontend == "teddit") {
|
||||||
if (tedditInstancesList.length === 0) return;
|
if (tedditInstancesList.length === 0) return
|
||||||
randomInstance = utils.getRandomInstance(tedditInstancesList);
|
randomInstance = utils.getRandomInstance(tedditInstancesList)
|
||||||
}
|
}
|
||||||
return `${randomInstance}${url.pathname}${url.search}`;
|
return `${randomInstance}${url.pathname}${url.search}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchInstance(url, disableOverride) {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableReddit && !disableOverride) { resolve(); return; }
|
if (disableReddit && !disableOverride) {
|
||||||
const protocolHost = utils.protocolHost(url);
|
resolve()
|
||||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
return
|
||||||
let instancesList = [];
|
}
|
||||||
if (redditFrontend == 'libreddit') {
|
const protocolHost = utils.protocolHost(url)
|
||||||
if (protocol == 'loki') instancesList = [...libredditLokiCustomRedirects];
|
if (!all().includes(protocolHost)) {
|
||||||
else if (protocol == 'i2p') instancesList = [...libredditI2pCustomRedirects];
|
resolve()
|
||||||
else if (protocol == 'tor') instancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects];
|
return
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
}
|
||||||
instancesList = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects];
|
let instancesList = []
|
||||||
}
|
if (redditFrontend == "libreddit") {
|
||||||
if ([
|
if (protocol == "loki") instancesList = [...libredditLokiCustomRedirects]
|
||||||
...redditRedirects.teddit.normal,
|
else if (protocol == "i2p") instancesList = [...libredditI2pCustomRedirects]
|
||||||
...redditRedirects.teddit.tor
|
else if (protocol == "tor") instancesList = [...libredditTorRedirectsChecks, ...libredditTorCustomRedirects]
|
||||||
].includes(protocolHost)) url.pathname = url.pathname.replace("/pics/w:null_", "/img/");
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
}
|
instancesList = [...libredditNormalRedirectsChecks, ...libredditNormalCustomRedirects]
|
||||||
else if (redditFrontend == 'teddit') {
|
}
|
||||||
if (protocol == 'loki') instancesList = [...tedditLokiCustomRedirects];
|
if ([...redditRedirects.teddit.normal, ...redditRedirects.teddit.tor].includes(protocolHost)) url.pathname = url.pathname.replace("/pics/w:null_", "/img/")
|
||||||
else if (protocol == 'i2p') instancesList = [...tedditI2pCustomRedirects];
|
} else if (redditFrontend == "teddit") {
|
||||||
else if (protocol == 'tor') instancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects];
|
if (protocol == "loki") instancesList = [...tedditLokiCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
else if (protocol == "i2p") instancesList = [...tedditI2pCustomRedirects]
|
||||||
instancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects];
|
else if (protocol == "tor") instancesList = [...tedditTorRedirectsChecks, ...tedditTorCustomRedirects]
|
||||||
}
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
if ([
|
instancesList = [...tedditNormalRedirectsChecks, ...tedditNormalCustomRedirects]
|
||||||
...redditRedirects.libreddit.normal,
|
}
|
||||||
...redditRedirects.libreddit.tor
|
if ([...redditRedirects.libreddit.normal, ...redditRedirects.libreddit.tor].includes(protocolHost)) url.pathname = url.pathname.replace("/img/", "/pics/w:null_")
|
||||||
].includes(protocolHost)
|
}
|
||||||
) url.pathname = url.pathname.replace("/img/", "/pics/w:null_");
|
|
||||||
}
|
|
||||||
|
|
||||||
const i = instancesList.indexOf(protocolHost);
|
const i = instancesList.indexOf(protocolHost)
|
||||||
if (i > -1) instancesList.splice(i, 1);
|
if (i > -1) instancesList.splice(i, 1)
|
||||||
if (instancesList.length === 0) { resolve(); return; }
|
if (instancesList.length === 0) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaults() {
|
function initDefaults() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
fetch("/instances/data.json")
|
||||||
let dataJson = JSON.parse(data);
|
.then(response => response.text())
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
.then(async data => {
|
||||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
let dataJson = JSON.parse(data)
|
||||||
}
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
browser.storage.local.get('cloudflareBlackList', async r => {
|
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||||
libredditNormalRedirectsChecks = [...redirects.libreddit.normal];
|
}
|
||||||
tedditNormalRedirectsChecks = [...redirects.teddit.normal]
|
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||||
for (const instance of r.cloudflareBlackList) {
|
libredditNormalRedirectsChecks = [...redirects.libreddit.normal]
|
||||||
let i;
|
tedditNormalRedirectsChecks = [...redirects.teddit.normal]
|
||||||
|
for (const instance of r.cloudflareBlackList) {
|
||||||
|
let i
|
||||||
|
|
||||||
i = libredditNormalRedirectsChecks.indexOf(instance);
|
i = libredditNormalRedirectsChecks.indexOf(instance)
|
||||||
if (i > -1) libredditNormalRedirectsChecks.splice(i, 1);
|
if (i > -1) libredditNormalRedirectsChecks.splice(i, 1)
|
||||||
|
|
||||||
i = tedditNormalRedirectsChecks.indexOf(instance);
|
i = tedditNormalRedirectsChecks.indexOf(instance)
|
||||||
if (i > -1) tedditNormalRedirectsChecks.splice(i, 1);
|
if (i > -1) tedditNormalRedirectsChecks.splice(i, 1)
|
||||||
}
|
}
|
||||||
browser.storage.local.set({
|
browser.storage.local.set(
|
||||||
disableReddit: false,
|
{
|
||||||
redditFrontend: 'libreddit',
|
disableReddit: false,
|
||||||
redditRedirects: redirects,
|
redditFrontend: "libreddit",
|
||||||
|
redditRedirects: redirects,
|
||||||
|
|
||||||
libredditNormalRedirectsChecks: libredditNormalRedirectsChecks,
|
libredditNormalRedirectsChecks: libredditNormalRedirectsChecks,
|
||||||
libredditNormalCustomRedirects: [],
|
libredditNormalCustomRedirects: [],
|
||||||
|
|
||||||
libredditTorRedirectsChecks: [...redirects.libreddit.tor],
|
libredditTorRedirectsChecks: [...redirects.libreddit.tor],
|
||||||
libredditTorCustomRedirects: [],
|
libredditTorCustomRedirects: [],
|
||||||
|
|
||||||
libredditI2pRedirectsChecks: [...redirects.libreddit.i2p],
|
libredditI2pRedirectsChecks: [...redirects.libreddit.i2p],
|
||||||
libredditI2pCustomRedirects: [],
|
libredditI2pCustomRedirects: [],
|
||||||
|
|
||||||
libredditLokiRedirectsChecks: [...redirects.libreddit.loki],
|
libredditLokiRedirectsChecks: [...redirects.libreddit.loki],
|
||||||
libredditLokiCustomRedirects: [],
|
libredditLokiCustomRedirects: [],
|
||||||
|
|
||||||
tedditNormalRedirectsChecks: tedditNormalRedirectsChecks,
|
tedditNormalRedirectsChecks: tedditNormalRedirectsChecks,
|
||||||
tedditNormalCustomRedirects: [],
|
tedditNormalCustomRedirects: [],
|
||||||
|
|
||||||
tedditTorRedirectsChecks: [...redirects.teddit.tor],
|
tedditTorRedirectsChecks: [...redirects.teddit.tor],
|
||||||
tedditTorCustomRedirects: [],
|
tedditTorCustomRedirects: [],
|
||||||
|
|
||||||
tedditI2pRedirectsChecks: [...redirects.teddit.i2p],
|
tedditI2pRedirectsChecks: [...redirects.teddit.i2p],
|
||||||
tedditI2pCustomRedirects: [],
|
tedditI2pCustomRedirects: [],
|
||||||
|
|
||||||
tedditLokiRedirectsChecks: [...redirects.teddit.loki],
|
tedditLokiRedirectsChecks: [...redirects.teddit.loki],
|
||||||
tedditLokiCustomRedirects: []
|
tedditLokiCustomRedirects: [],
|
||||||
}, () => resolve());
|
},
|
||||||
});
|
() => resolve()
|
||||||
});
|
)
|
||||||
});
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setRedirects,
|
setRedirects,
|
||||||
initLibredditCookies,
|
initLibredditCookies,
|
||||||
pasteLibredditCookies,
|
pasteLibredditCookies,
|
||||||
initTedditCookies,
|
initTedditCookies,
|
||||||
pasteTedditCookies,
|
pasteTedditCookies,
|
||||||
|
|
||||||
redirect,
|
redirect,
|
||||||
initDefaults,
|
initDefaults,
|
||||||
switchInstance,
|
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 = [
|
const targets = [/^https?:\/{2}(www\.|)reuters\.com.*/]
|
||||||
/^https?:\/{2}(www\.|)reuters\.com.*/
|
|
||||||
];
|
|
||||||
|
|
||||||
let redirects = {
|
const frontends = new Array("neuters")
|
||||||
"neuters": {
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
"normal": [
|
|
||||||
"https://neuters.de"
|
let redirects = {}
|
||||||
],
|
|
||||||
"tor": [],
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
"i2p": [],
|
redirects[frontends[i]] = {}
|
||||||
"loki": []
|
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) {
|
function setRedirects(val) {
|
||||||
browser.storage.local.get('cloudflareBlackList', r => {
|
browser.storage.local.get("cloudflareBlackList", r => {
|
||||||
redirects.neuters = val;
|
redirects.neuters = val
|
||||||
neutersNormalRedirectsChecks = [...redirects.neuters.normal];
|
neutersNormalRedirectsChecks = [...redirects.neuters.normal]
|
||||||
for (const instance of r.cloudflareBlackList) {
|
for (const instance of r.cloudflareBlackList) {
|
||||||
const a = neutersNormalRedirectsChecks.indexOf(instance);
|
const a = neutersNormalRedirectsChecks.indexOf(instance)
|
||||||
if (a > -1) neutersNormalRedirectsChecks.splice(a, 1);
|
if (a > -1) neutersNormalRedirectsChecks.splice(a, 1)
|
||||||
}
|
}
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
neutersRedirects: redirects,
|
neutersRedirects: redirects,
|
||||||
neutersNormalRedirectsChecks
|
neutersNormalRedirectsChecks,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let disableReuters,
|
||||||
disableReuters,
|
protocol,
|
||||||
protocol,
|
protocolFallback,
|
||||||
protocolFallback,
|
reutersRedirects,
|
||||||
reutersRedirects,
|
neutersNormalRedirectsChecks,
|
||||||
neutersNormalRedirectsChecks,
|
neutersNormalCustomRedirects,
|
||||||
neutersNormalCustomRedirects,
|
neutersTorRedirectsChecks,
|
||||||
neutersTorRedirectsChecks,
|
neutersTorCustomRedirects,
|
||||||
neutersTorCustomRedirects,
|
neutersI2pCustomRedirects,
|
||||||
neutersI2pCustomRedirects,
|
neutersLokiCustomRedirects
|
||||||
neutersLokiCustomRedirects;
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disableReuters",
|
"disableReuters",
|
||||||
"protocol",
|
"protocol",
|
||||||
"protocolFallback",
|
"protocolFallback",
|
||||||
"reutersRedirects",
|
"reutersRedirects",
|
||||||
"neutersNormalRedirectsChecks",
|
"neutersNormalRedirectsChecks",
|
||||||
"neutersNormalCustomRedirects",
|
"neutersNormalCustomRedirects",
|
||||||
"neutersTorRedirectsChecks",
|
"neutersTorRedirectsChecks",
|
||||||
"neutersTorCustomRedirects",
|
"neutersTorCustomRedirects",
|
||||||
"neutersI2pCustomRedirects",
|
"neutersI2pCustomRedirects",
|
||||||
"neutersLokiCustomRedirects"
|
"neutersLokiCustomRedirects",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
disableReuters = r.disableReuters;
|
disableReuters = r.disableReuters
|
||||||
protocol = r.protocol;
|
protocol = r.protocol
|
||||||
protocolFallback = r.protocolFallback;
|
protocolFallback = r.protocolFallback
|
||||||
reutersRedirects = r.reutersRedirects;
|
reutersRedirects = r.reutersRedirects
|
||||||
neutersNormalRedirectsChecks = r.neutersNormalRedirectsChecks;
|
neutersNormalRedirectsChecks = r.neutersNormalRedirectsChecks
|
||||||
neutersNormalCustomRedirects = r.neutersNormalCustomRedirects;
|
neutersNormalCustomRedirects = r.neutersNormalCustomRedirects
|
||||||
neutersTorRedirectsChecks = r.neutersTorRedirectsChecks;
|
neutersTorRedirectsChecks = r.neutersTorRedirectsChecks
|
||||||
neutersTorCustomRedirects = r.neutersTorCustomRedirects;
|
neutersTorCustomRedirects = r.neutersTorCustomRedirects
|
||||||
neutersI2pCustomRedirects = r.neutersI2pCustomRedirects;
|
neutersI2pCustomRedirects = r.neutersI2pCustomRedirects
|
||||||
neutersLokiCustomRedirects = r.neutersLokiCustomRedirects;
|
neutersLokiCustomRedirects = r.neutersLokiCustomRedirects
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
function redirect(url, type, initiator, disableOverride) {
|
function redirect(url, type, initiator, disableOverride) {
|
||||||
if (disableReuters && !disableOverride) return;
|
if (disableReuters && !disableOverride) return
|
||||||
if (type != "main_frame") return;
|
if (type != "main_frame") return
|
||||||
const all = [
|
const all = [...reutersRedirects.neuters.normal, ...neutersNormalCustomRedirects]
|
||||||
...reutersRedirects.neuters.normal,
|
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return
|
||||||
...neutersNormalCustomRedirects
|
if (!targets.some(rx => rx.test(url.href))) return
|
||||||
];
|
|
||||||
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return;
|
|
||||||
if (!targets.some(rx => rx.test(url.href))) return;
|
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...neutersLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...neutersLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...neutersI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...neutersI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...neutersTorRedirectsChecks, ...neutersTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...neutersTorRedirectsChecks, ...neutersTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...neutersNormalRedirectsChecks, ...neutersNormalCustomRedirects];
|
instancesList = [...neutersNormalRedirectsChecks, ...neutersNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) return;
|
if (instancesList.length === 0) return
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
// stolen from https://addons.mozilla.org/en-US/firefox/addon/reuters-redirect/
|
// stolen from https://addons.mozilla.org/en-US/firefox/addon/reuters-redirect/
|
||||||
if (
|
if (url.pathname.startsWith("/article/") || url.pathname.startsWith("/pf/") || url.pathname.startsWith("/arc/") || url.pathname.startsWith("/resizer/")) return null
|
||||||
url.pathname.startsWith('/article/') ||
|
else if (url.pathname.endsWith("/")) return `${randomInstance}${url.pathname}`
|
||||||
url.pathname.startsWith('/pf/') ||
|
else return `${randomInstance}${url.pathname}/`
|
||||||
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() {
|
function initDefaults() {
|
||||||
return new Promise(resolve => {
|
return new Promise(async resolve => {
|
||||||
browser.storage.local.set({
|
fetch("/instances/data.json")
|
||||||
disableReuters: true,
|
.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],
|
neutersNormalRedirectsChecks: [...redirects.neuters.normal],
|
||||||
neutersNormalCustomRedirects: [],
|
neutersNormalCustomRedirects: [],
|
||||||
|
|
||||||
neutersTorRedirectsChecks: [...redirects.neuters.tor],
|
neutersTorRedirectsChecks: [...redirects.neuters.tor],
|
||||||
neutersTorCustomRedirects: [],
|
neutersTorCustomRedirects: [],
|
||||||
|
|
||||||
neutersI2pRedirectsChecks: [...redirects.neuters.i2p],
|
neutersI2pRedirectsChecks: [...redirects.neuters.i2p],
|
||||||
neutersI2pCustomRedirects: [],
|
neutersI2pCustomRedirects: [],
|
||||||
|
|
||||||
neutersLokiRedirectsChecks: [...redirects.neuters.loki],
|
neutersLokiRedirectsChecks: [...redirects.neuters.loki],
|
||||||
neutersLokiCustomRedirects: []
|
neutersLokiCustomRedirects: [],
|
||||||
}, () => resolve());
|
},
|
||||||
});
|
() => resolve()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setRedirects,
|
setRedirects,
|
||||||
redirect,
|
redirect,
|
||||||
initDefaults
|
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 = [
|
const targets = [/^https?:\/{2}send\.libredirect\.invalid\/$/, /^ https ?: \/\/send\.firefox\.com\/$/, /^https?:\/{2}sendfiles\.online\/$/]
|
||||||
/^https?:\/{2}send\.libredirect\.invalid\/$/,
|
|
||||||
/^ https ?: \/\/send\.firefox\.com\/$/,
|
|
||||||
/^https?:\/{2}sendfiles\.online\/$/
|
|
||||||
];
|
|
||||||
|
|
||||||
const frontends = new Array("send")
|
const frontends = new Array("send")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
@ -14,167 +10,183 @@ const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
let redirects = {}
|
let redirects = {}
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
redirects[frontends[i]] = {}
|
redirects[frontends[i]] = {}
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
redirects[frontends[i]][protocols[x]] = []
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRedirects(val) {
|
function setRedirects(val) {
|
||||||
browser.storage.local.get('cloudflareBlackList', r => {
|
browser.storage.local.get("cloudflareBlackList", r => {
|
||||||
redirects.send = val;
|
redirects.send = val
|
||||||
sendNormalRedirectsChecks = [...redirects.send.normal];
|
sendNormalRedirectsChecks = [...redirects.send.normal]
|
||||||
for (const instance of r.cloudflareBlackList) {
|
for (const instance of r.cloudflareBlackList) {
|
||||||
const a = sendNormalRedirectsChecks.indexOf(instance);
|
const a = sendNormalRedirectsChecks.indexOf(instance)
|
||||||
if (a > -1) sendNormalRedirectsChecks.splice(a, 1);
|
if (a > -1) sendNormalRedirectsChecks.splice(a, 1)
|
||||||
}
|
}
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
sendTargetsRedirects: redirects,
|
sendTargetsRedirects: redirects,
|
||||||
sendNormalRedirectsChecks,
|
sendNormalRedirectsChecks,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let disableSendTarget,
|
||||||
disableSendTarget,
|
sendTargetsRedirects,
|
||||||
sendTargetsRedirects,
|
sendNormalRedirectsChecks,
|
||||||
sendNormalRedirectsChecks,
|
sendNormalCustomRedirects,
|
||||||
sendNormalCustomRedirects,
|
sendTorRedirectsChecks,
|
||||||
sendTorRedirectsChecks,
|
sendTorCustomRedirects,
|
||||||
sendTorCustomRedirects,
|
sendI2pCustomRedirects,
|
||||||
sendI2pCustomRedirects,
|
sendLokiCustomRedirects,
|
||||||
sendLokiCustomRedirects,
|
protocol,
|
||||||
protocol,
|
protocolFallback
|
||||||
protocolFallback;
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disableSendTarget",
|
"disableSendTarget",
|
||||||
"sendTargetsRedirects",
|
"sendTargetsRedirects",
|
||||||
"protocol",
|
"protocol",
|
||||||
"protocolFallback",
|
"protocolFallback",
|
||||||
"sendNormalRedirectsChecks",
|
"sendNormalRedirectsChecks",
|
||||||
"sendNormalCustomRedirects",
|
"sendNormalCustomRedirects",
|
||||||
"sendTorRedirectsChecks",
|
"sendTorRedirectsChecks",
|
||||||
"sendTorCustomRedirects",
|
"sendTorCustomRedirects",
|
||||||
"sendI2pCustomRedirects",
|
"sendI2pCustomRedirects",
|
||||||
"sendLokiCustomRedirects"
|
"sendLokiCustomRedirects",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
disableSendTarget = r.disableSendTarget;
|
disableSendTarget = r.disableSendTarget
|
||||||
sendTargetsRedirects = r.sendTargetsRedirects;
|
sendTargetsRedirects = r.sendTargetsRedirects
|
||||||
sendNormalRedirectsChecks = r.sendNormalRedirectsChecks;
|
sendNormalRedirectsChecks = r.sendNormalRedirectsChecks
|
||||||
sendNormalCustomRedirects = r.sendNormalCustomRedirects;
|
sendNormalCustomRedirects = r.sendNormalCustomRedirects
|
||||||
sendTorRedirectsChecks = r.sendTorRedirectsChecks;
|
sendTorRedirectsChecks = r.sendTorRedirectsChecks
|
||||||
sendTorCustomRedirects = r.sendTorCustomRedirects;
|
sendTorCustomRedirects = r.sendTorCustomRedirects
|
||||||
sendI2pCustomRedirects = r.sendI2pCustomRedirects;
|
sendI2pCustomRedirects = r.sendI2pCustomRedirects
|
||||||
sendLokiCustomRedirects = r.sendLokiCustomRedirects;
|
sendLokiCustomRedirects = r.sendLokiCustomRedirects
|
||||||
protocol = r.protocol;
|
protocol = r.protocol
|
||||||
protocolFallback = r.protocolFallback;
|
protocolFallback = r.protocolFallback
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
function all() {
|
function all() {
|
||||||
return [
|
return [
|
||||||
...sendTargetsRedirects.send.normal,
|
...sendTargetsRedirects.send.normal,
|
||||||
...sendTargetsRedirects.send.tor,
|
...sendTargetsRedirects.send.tor,
|
||||||
...sendNormalCustomRedirects,
|
...sendNormalCustomRedirects,
|
||||||
...sendTorRedirectsChecks,
|
...sendTorRedirectsChecks,
|
||||||
...sendTorCustomRedirects,
|
...sendTorCustomRedirects,
|
||||||
...sendI2pCustomRedirects,
|
...sendI2pCustomRedirects,
|
||||||
...sendLokiCustomRedirects
|
...sendLokiCustomRedirects,
|
||||||
];
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchInstance(url, disableOverride) {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableSendTarget && !disableOverride) { resolve(); return; }
|
if (disableSendTarget && !disableOverride) {
|
||||||
const protocolHost = utils.protocolHost(url);
|
resolve()
|
||||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
return
|
||||||
if (url.pathname != '/') { resolve(); return; }
|
}
|
||||||
|
const protocolHost = utils.protocolHost(url)
|
||||||
|
if (!all().includes(protocolHost)) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (url.pathname != "/") {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...sendLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...sendLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...sendI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...sendI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects];
|
instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
|
|
||||||
const i = instancesList.indexOf(protocolHost);
|
const i = instancesList.indexOf(protocolHost)
|
||||||
if (i > -1) instancesList.splice(i, 1);
|
if (i > -1) instancesList.splice(i, 1)
|
||||||
if (instancesList.length === 0) { resolve(); return; }
|
if (instancesList.length === 0) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirect(url, type, initiator, disableOverride) {
|
function redirect(url, type, initiator, disableOverride) {
|
||||||
if (disableSendTarget && !disableOverride) return;
|
if (disableSendTarget && !disableOverride) return
|
||||||
if (type != "main_frame") return;
|
if (type != "main_frame") return
|
||||||
if (initiator && (all().includes(initiator.origin) || targets.includes(initiator.host))) return;
|
if (initiator && (all().includes(initiator.origin) || targets.includes(initiator.host))) return
|
||||||
if (!targets.some(rx => rx.test(url.href))) return;
|
if (!targets.some(rx => rx.test(url.href))) return
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...sendLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...sendLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...sendI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...sendI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...sendTorRedirectsChecks, ...sendTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects];
|
instancesList = [...sendNormalRedirectsChecks, ...sendNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) return;
|
if (instancesList.length === 0) return
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
return randomInstance;
|
return randomInstance
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaults() {
|
function initDefaults() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
fetch("/instances/data.json")
|
||||||
let dataJson = JSON.parse(data);
|
.then(response => response.text())
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
.then(async data => {
|
||||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
let dataJson = JSON.parse(data)
|
||||||
}
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
browser.storage.local.get('cloudflareBlackList', async r => {
|
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||||
sendNormalRedirectsChecks = [...redirects.send.normal];
|
}
|
||||||
for (const instance of r.cloudflareBlackList) {
|
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||||
let i = sendNormalRedirectsChecks.indexOf(instance);
|
sendNormalRedirectsChecks = [...redirects.send.normal]
|
||||||
if (i > -1) sendNormalRedirectsChecks.splice(i, 1);
|
for (const instance of r.cloudflareBlackList) {
|
||||||
}
|
let i = sendNormalRedirectsChecks.indexOf(instance)
|
||||||
browser.storage.local.set({
|
if (i > -1) sendNormalRedirectsChecks.splice(i, 1)
|
||||||
disableSendTarget: false,
|
}
|
||||||
sendTargetsRedirects: redirects,
|
browser.storage.local.set(
|
||||||
|
{
|
||||||
|
disableSendTarget: false,
|
||||||
|
sendTargetsRedirects: redirects,
|
||||||
|
|
||||||
sendNormalRedirectsChecks: sendNormalRedirectsChecks,
|
sendNormalRedirectsChecks: sendNormalRedirectsChecks,
|
||||||
sendNormalCustomRedirects: [],
|
sendNormalCustomRedirects: [],
|
||||||
|
|
||||||
sendTorRedirectsChecks: [...redirects.send.tor],
|
sendTorRedirectsChecks: [...redirects.send.tor],
|
||||||
sendTorCustomRedirects: [],
|
sendTorCustomRedirects: [],
|
||||||
|
|
||||||
sendI2pRedirectsChecks: [...redirects.send.i2p],
|
sendI2pRedirectsChecks: [...redirects.send.i2p],
|
||||||
sendI2pCustomRedirects: [],
|
sendI2pCustomRedirects: [],
|
||||||
|
|
||||||
sendLokiRedirectsChecks: [...redirects.send.loki],
|
sendLokiRedirectsChecks: [...redirects.send.loki],
|
||||||
sendLokiCustomRedirects: []
|
sendLokiCustomRedirects: [],
|
||||||
}, () => resolve())
|
},
|
||||||
})
|
() => resolve()
|
||||||
})
|
)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setRedirects,
|
setRedirects,
|
||||||
redirect,
|
redirect,
|
||||||
switchInstance,
|
switchInstance,
|
||||||
initDefaults,
|
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 = [
|
const targets = [/^https?:\/{2}(www\.|)tiktok\.com.*/]
|
||||||
/^https?:\/{2}(www\.|)tiktok\.com.*/
|
|
||||||
];
|
|
||||||
|
|
||||||
const frontends = new Array("proxiTok")
|
const frontends = new Array("proxiTok")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
@ -12,232 +10,251 @@ const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
let redirects = {}
|
let redirects = {}
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
redirects[frontends[i]] = {}
|
redirects[frontends[i]] = {}
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
redirects[frontends[i]][protocols[x]] = []
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRedirects(val) {
|
function setRedirects(val) {
|
||||||
browser.storage.local.get('cloudflareBlackList', r => {
|
browser.storage.local.get("cloudflareBlackList", r => {
|
||||||
redirects.proxiTok = val;
|
redirects.proxiTok = val
|
||||||
proxiTokNormalRedirectsChecks = [...redirects.proxiTok.normal];
|
proxiTokNormalRedirectsChecks = [...redirects.proxiTok.normal]
|
||||||
for (const instance of r.cloudflareBlackList) {
|
for (const instance of r.cloudflareBlackList) {
|
||||||
const a = proxiTokNormalRedirectsChecks.indexOf(instance);
|
const a = proxiTokNormalRedirectsChecks.indexOf(instance)
|
||||||
if (a > -1) proxiTokNormalRedirectsChecks.splice(a, 1);
|
if (a > -1) proxiTokNormalRedirectsChecks.splice(a, 1)
|
||||||
}
|
}
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
tiktokRedirects: redirects,
|
tiktokRedirects: redirects,
|
||||||
proxiTokNormalRedirectsChecks
|
proxiTokNormalRedirectsChecks,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function initProxiTokCookies(test, from) {
|
function initProxiTokCookies(test, from) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
let protocolHost = utils.protocolHost(from);
|
let protocolHost = utils.protocolHost(from)
|
||||||
if (![
|
if (
|
||||||
...proxiTokNormalRedirectsChecks,
|
![
|
||||||
...proxiTokNormalCustomRedirects,
|
...proxiTokNormalRedirectsChecks,
|
||||||
...proxiTokTorRedirectsChecks,
|
...proxiTokNormalCustomRedirects,
|
||||||
...proxiTokTorCustomRedirects,
|
...proxiTokTorRedirectsChecks,
|
||||||
...proxiTokI2pCustomRedirects,
|
...proxiTokTorCustomRedirects,
|
||||||
...proxiTokLokiCustomRedirects,
|
...proxiTokI2pCustomRedirects,
|
||||||
].includes(protocolHost)) resolve();
|
...proxiTokLokiCustomRedirects,
|
||||||
|
].includes(protocolHost)
|
||||||
|
)
|
||||||
|
resolve()
|
||||||
|
|
||||||
if (!test) {
|
if (!test) {
|
||||||
let checkedInstances = [];
|
let checkedInstances = []
|
||||||
if (protocol == 'loki') checkedInstances = [...proxiTokI2pCustomRedirects];
|
if (protocol == "loki") checkedInstances = [...proxiTokI2pCustomRedirects]
|
||||||
else if (protocol == 'i2p') checkedInstances = [...proxiTokLokiCustomRedirects];
|
else if (protocol == "i2p") checkedInstances = [...proxiTokLokiCustomRedirects]
|
||||||
else if (protocol == 'tor') checkedInstances = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects];
|
else if (protocol == "tor") checkedInstances = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]
|
||||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
checkedInstances = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects];
|
checkedInstances = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
await utils.copyCookie('proxitok', from, checkedInstances, 'theme');
|
await utils.copyCookie("proxitok", from, checkedInstances, "theme")
|
||||||
await utils.copyCookie('proxitok', from, checkedInstances, 'api-legacy');
|
await utils.copyCookie("proxitok", from, checkedInstances, "api-legacy")
|
||||||
}
|
}
|
||||||
resolve(true);
|
resolve(true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function pasteProxiTokCookies() {
|
function pasteProxiTokCookies() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableTiktok || protocol === undefined) { resolve(); return; }
|
if (disableTiktok || protocol === undefined) {
|
||||||
let checkedInstances = [];
|
resolve()
|
||||||
if (protocol == 'loki') checkedInstances = [...proxiTokI2pCustomRedirects];
|
return
|
||||||
else if (protocol == 'i2p') checkedInstances = [...proxiTokLokiCustomRedirects];
|
}
|
||||||
else if (protocol == 'tor') checkedInstances = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects];
|
let checkedInstances = []
|
||||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
if (protocol == "loki") checkedInstances = [...proxiTokI2pCustomRedirects]
|
||||||
checkedInstances = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects];
|
else if (protocol == "i2p") checkedInstances = [...proxiTokLokiCustomRedirects]
|
||||||
}
|
else if (protocol == "tor") checkedInstances = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]
|
||||||
utils.getCookiesFromStorage('proxitok', checkedInstances, 'theme');
|
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
utils.getCookiesFromStorage('proxitok', checkedInstances, 'api-legacy');
|
checkedInstances = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]
|
||||||
resolve();
|
}
|
||||||
})
|
utils.getCookiesFromStorage("proxitok", checkedInstances, "theme")
|
||||||
|
utils.getCookiesFromStorage("proxitok", checkedInstances, "api-legacy")
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let disableTiktok,
|
||||||
disableTiktok,
|
protocol,
|
||||||
protocol,
|
protocolFallback,
|
||||||
protocolFallback,
|
tiktokRedirects,
|
||||||
tiktokRedirects,
|
proxiTokNormalRedirectsChecks,
|
||||||
proxiTokNormalRedirectsChecks,
|
proxiTokNormalCustomRedirects,
|
||||||
proxiTokNormalCustomRedirects,
|
proxiTokTorRedirectsChecks,
|
||||||
proxiTokTorRedirectsChecks,
|
proxiTokTorCustomRedirects,
|
||||||
proxiTokTorCustomRedirects,
|
proxiTokI2pCustomRedirects,
|
||||||
proxiTokI2pCustomRedirects,
|
proxiTokLokiCustomRedirects
|
||||||
proxiTokLokiCustomRedirects;
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disableTiktok",
|
"disableTiktok",
|
||||||
"protocol",
|
"protocol",
|
||||||
"protocolFallback",
|
"protocolFallback",
|
||||||
"tiktokRedirects",
|
"tiktokRedirects",
|
||||||
"proxiTokNormalRedirectsChecks",
|
"proxiTokNormalRedirectsChecks",
|
||||||
"proxiTokNormalCustomRedirects",
|
"proxiTokNormalCustomRedirects",
|
||||||
"proxiTokTorRedirectsChecks",
|
"proxiTokTorRedirectsChecks",
|
||||||
"proxiTokTorCustomRedirects",
|
"proxiTokTorCustomRedirects",
|
||||||
"proxiTokI2pCustomRedirects",
|
"proxiTokI2pCustomRedirects",
|
||||||
"proxiTokLokiCustomRedirects"
|
"proxiTokLokiCustomRedirects",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
disableTiktok = r.disableTiktok;
|
disableTiktok = r.disableTiktok
|
||||||
protocol = r.protocol;
|
protocol = r.protocol
|
||||||
protocolFallback = r.protocolFallback;
|
protocolFallback = r.protocolFallback
|
||||||
tiktokRedirects = r.tiktokRedirects;
|
tiktokRedirects = r.tiktokRedirects
|
||||||
proxiTokNormalRedirectsChecks = r.proxiTokNormalRedirectsChecks;
|
proxiTokNormalRedirectsChecks = r.proxiTokNormalRedirectsChecks
|
||||||
proxiTokNormalCustomRedirects = r.proxiTokNormalCustomRedirects;
|
proxiTokNormalCustomRedirects = r.proxiTokNormalCustomRedirects
|
||||||
proxiTokTorRedirectsChecks = r.proxiTokTorRedirectsChecks;
|
proxiTokTorRedirectsChecks = r.proxiTokTorRedirectsChecks
|
||||||
proxiTokTorCustomRedirects = r.proxiTokTorCustomRedirects;
|
proxiTokTorCustomRedirects = r.proxiTokTorCustomRedirects
|
||||||
proxiTokI2pCustomRedirects = r.proxiTokI2pCustomRedirects;
|
proxiTokI2pCustomRedirects = r.proxiTokI2pCustomRedirects
|
||||||
proxiTokLokiCustomRedirects = r.proxiTokLokiCustomRedirects;
|
proxiTokLokiCustomRedirects = r.proxiTokLokiCustomRedirects
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
// https://www.tiktok.com/@keysikaspol/video/7061265241887345946
|
// https://www.tiktok.com/@keysikaspol/video/7061265241887345946
|
||||||
// https://www.tiktok.com/@keysikaspol
|
// https://www.tiktok.com/@keysikaspol
|
||||||
function redirect(url, type, initiator, disableOverride) {
|
function redirect(url, type, initiator, disableOverride) {
|
||||||
if (disableTiktok && !disableOverride) return;
|
if (disableTiktok && !disableOverride) return
|
||||||
if (type != "main_frame") return;
|
if (type != "main_frame") return
|
||||||
const all = [
|
const all = [...tiktokRedirects.proxiTok.normal, ...proxiTokNormalCustomRedirects]
|
||||||
...tiktokRedirects.proxiTok.normal,
|
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return
|
||||||
...proxiTokNormalCustomRedirects
|
if (!targets.some(rx => rx.test(url.href))) return
|
||||||
];
|
|
||||||
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return;
|
|
||||||
if (!targets.some(rx => rx.test(url.href))) return;
|
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...proxiTokI2pCustomRedirects];
|
if (protocol == "loki") instancesList = [...proxiTokI2pCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...proxiTokLokiCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...proxiTokLokiCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects];
|
instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) return;
|
if (instancesList.length === 0) return
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
return `${randomInstance}${url.pathname}`;
|
return `${randomInstance}${url.pathname}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function reverse(url) {
|
function reverse(url) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
let protocolHost = utils.protocolHost(url);
|
let protocolHost = utils.protocolHost(url)
|
||||||
const all = [
|
const all = [
|
||||||
...tiktokRedirects.proxiTok.normal,
|
...tiktokRedirects.proxiTok.normal,
|
||||||
...tiktokRedirects.proxiTok.tor,
|
...tiktokRedirects.proxiTok.tor,
|
||||||
...proxiTokNormalCustomRedirects,
|
...proxiTokNormalCustomRedirects,
|
||||||
...proxiTokTorCustomRedirects,
|
...proxiTokTorCustomRedirects,
|
||||||
...proxiTokI2pCustomRedirects,
|
...proxiTokI2pCustomRedirects,
|
||||||
...proxiTokLokiCustomRedirects
|
...proxiTokLokiCustomRedirects,
|
||||||
];
|
]
|
||||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
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) {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableTiktok && !disableOverride) { resolve(); return; }
|
if (disableTiktok && !disableOverride) {
|
||||||
let protocolHost = utils.protocolHost(url);
|
resolve()
|
||||||
const all = [
|
return
|
||||||
...tiktokRedirects.proxiTok.tor,
|
}
|
||||||
...tiktokRedirects.proxiTok.normal,
|
let protocolHost = utils.protocolHost(url)
|
||||||
|
const all = [
|
||||||
|
...tiktokRedirects.proxiTok.tor,
|
||||||
|
...tiktokRedirects.proxiTok.normal,
|
||||||
|
|
||||||
...proxiTokNormalCustomRedirects,
|
...proxiTokNormalCustomRedirects,
|
||||||
...proxiTokTorCustomRedirects,
|
...proxiTokTorCustomRedirects,
|
||||||
...proxiTokI2pCustomRedirects,
|
...proxiTokI2pCustomRedirects,
|
||||||
...proxiTokLokiCustomRedirects
|
...proxiTokLokiCustomRedirects,
|
||||||
];
|
]
|
||||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
if (!all.includes(protocolHost)) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...proxiTokI2pCustomRedirects];
|
if (protocol == "loki") instancesList = [...proxiTokI2pCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...proxiTokLokiCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...proxiTokLokiCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...proxiTokTorRedirectsChecks, ...proxiTokTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects];
|
instancesList = [...proxiTokNormalRedirectsChecks, ...proxiTokNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
|
|
||||||
const i = instancesList.indexOf(protocolHost);
|
const i = instancesList.indexOf(protocolHost)
|
||||||
if (i > -1) instancesList.splice(i, 1);
|
if (i > -1) instancesList.splice(i, 1)
|
||||||
if (instancesList.length === 0) { resolve(); return; }
|
if (instancesList.length === 0) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaults() {
|
function initDefaults() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
fetch("/instances/data.json")
|
||||||
let dataJson = JSON.parse(data);
|
.then(response => response.text())
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
.then(async data => {
|
||||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
let dataJson = JSON.parse(data)
|
||||||
}
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
browser.storage.local.set({
|
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||||
disableTiktok: false,
|
}
|
||||||
|
browser.storage.local.set(
|
||||||
|
{
|
||||||
|
disableTiktok: false,
|
||||||
|
|
||||||
tiktokRedirects: redirects,
|
tiktokRedirects: redirects,
|
||||||
|
|
||||||
proxiTokNormalRedirectsChecks: [...redirects.proxiTok.normal],
|
proxiTokNormalRedirectsChecks: [...redirects.proxiTok.normal],
|
||||||
proxiTokNormalCustomRedirects: [],
|
proxiTokNormalCustomRedirects: [],
|
||||||
|
|
||||||
proxiTokTorRedirectsChecks: [...redirects.proxiTok.tor],
|
proxiTokTorRedirectsChecks: [...redirects.proxiTok.tor],
|
||||||
proxiTokTorCustomRedirects: [],
|
proxiTokTorCustomRedirects: [],
|
||||||
|
|
||||||
proxiTokI2pRedirectsChecks: [...redirects.proxiTok.i2p],
|
proxiTokI2pRedirectsChecks: [...redirects.proxiTok.i2p],
|
||||||
proxiTokI2pCustomRedirects: [],
|
proxiTokI2pCustomRedirects: [],
|
||||||
|
|
||||||
proxiTokLokiRedirectsChecks: [...redirects.proxiTok.loki],
|
proxiTokLokiRedirectsChecks: [...redirects.proxiTok.loki],
|
||||||
proxiTokLokiCustomRedirects: []
|
proxiTokLokiCustomRedirects: [],
|
||||||
}, () => resolve());
|
},
|
||||||
});
|
() => resolve()
|
||||||
})
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setRedirects,
|
setRedirects,
|
||||||
|
|
||||||
redirect,
|
redirect,
|
||||||
reverse,
|
reverse,
|
||||||
switchInstance,
|
switchInstance,
|
||||||
|
|
||||||
initProxiTokCookies,
|
initProxiTokCookies,
|
||||||
pasteProxiTokCookies,
|
pasteProxiTokCookies,
|
||||||
|
|
||||||
initDefaults
|
initDefaults,
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
window.browser = window.browser || window.chrome;
|
window.browser = window.browser || window.chrome
|
||||||
|
|
||||||
browser.storage.local.set(
|
browser.storage.local.set({
|
||||||
{
|
["lingva_chakra-ui-color-mode"]: localStorage.getItem("chakra-ui-color-mode"),
|
||||||
['lingva_chakra-ui-color-mode']: localStorage.getItem('chakra-ui-color-mode'),
|
lingva_isauto: localStorage.getItem("isauto"),
|
||||||
lingva_isauto: localStorage.getItem('isauto'),
|
lingva_source: localStorage.getItem("source"),
|
||||||
lingva_source: localStorage.getItem('source'),
|
lingva_target: localStorage.getItem("target"),
|
||||||
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(
|
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"])
|
||||||
"lingva_chakra-ui-color-mode",
|
if (r.lingva_isauto !== undefined) localStorage.setItem("isauto", r.lingva_isauto)
|
||||||
"lingva_isauto",
|
if (r.lingva_source !== undefined) localStorage.setItem("source", r.lingva_source)
|
||||||
"lingva_source",
|
if (r.lingva_target !== undefined) localStorage.setItem("target", r.lingva_target)
|
||||||
"lingva_target",
|
window.close()
|
||||||
],
|
})
|
||||||
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 = [
|
const targets = [/^https?:\/{2}translate\.google(\.[a-z]{2,3}){1,2}\//]
|
||||||
/^https?:\/{2}translate\.google(\.[a-z]{2,3}){1,2}\//,
|
|
||||||
];
|
|
||||||
|
|
||||||
const frontends = new Array("simplyTranslate", "lingva")
|
const frontends = new Array("simplyTranslate", "lingva")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
let redirects = {};
|
let redirects = {}
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
redirects[frontends[i]] = {}
|
redirects[frontends[i]] = {}
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
redirects[frontends[i]][protocols[x]] = []
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let translateDisable,
|
||||||
translateDisable,
|
translateFrontend,
|
||||||
translateFrontend,
|
protocol,
|
||||||
protocol,
|
protocolFallback,
|
||||||
protocolFallback,
|
translateRedirects,
|
||||||
translateRedirects,
|
simplyTranslateNormalRedirectsChecks,
|
||||||
simplyTranslateNormalRedirectsChecks,
|
simplyTranslateNormalCustomRedirects,
|
||||||
simplyTranslateNormalCustomRedirects,
|
simplyTranslateTorRedirectsChecks,
|
||||||
simplyTranslateTorRedirectsChecks,
|
simplyTranslateTorCustomRedirects,
|
||||||
simplyTranslateTorCustomRedirects,
|
simplyTranslateI2pRedirectsChecks,
|
||||||
simplyTranslateI2pRedirectsChecks,
|
simplyTranslateI2pCustomRedirects,
|
||||||
simplyTranslateI2pCustomRedirects,
|
simplyTranslateLokiRedirectsChecks,
|
||||||
simplyTranslateLokiRedirectsChecks,
|
simplyTranslateLokiCustomRedirects,
|
||||||
simplyTranslateLokiCustomRedirects,
|
lingvaNormalRedirectsChecks,
|
||||||
lingvaNormalRedirectsChecks,
|
lingvaNormalCustomRedirects,
|
||||||
lingvaNormalCustomRedirects,
|
lingvaTorRedirectsChecks,
|
||||||
lingvaTorRedirectsChecks,
|
lingvaTorCustomRedirects,
|
||||||
lingvaTorCustomRedirects,
|
lingvaI2pCustomRedirects,
|
||||||
lingvaI2pCustomRedirects,
|
lingvaLokiCustomRedirects
|
||||||
lingvaLokiCustomRedirects
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"translateDisable",
|
"translateDisable",
|
||||||
"translateFrontend",
|
"translateFrontend",
|
||||||
"protocol",
|
"protocol",
|
||||||
"protocolFallback",
|
"protocolFallback",
|
||||||
"translateRedirects",
|
"translateRedirects",
|
||||||
"simplyTranslateNormalRedirectsChecks",
|
"simplyTranslateNormalRedirectsChecks",
|
||||||
"simplyTranslateNormalCustomRedirects",
|
"simplyTranslateNormalCustomRedirects",
|
||||||
"simplyTranslateTorRedirectsChecks",
|
"simplyTranslateTorRedirectsChecks",
|
||||||
"simplyTranslateTorCustomRedirects",
|
"simplyTranslateTorCustomRedirects",
|
||||||
"simplyTranslateI2pRedirectsChecks",
|
"simplyTranslateI2pRedirectsChecks",
|
||||||
"simplyTranslateI2pCustomRedirects",
|
"simplyTranslateI2pCustomRedirects",
|
||||||
"simplyTranslateLokiRedirectsChecks",
|
"simplyTranslateLokiRedirectsChecks",
|
||||||
"simplyTranslateLokiCustomRedirects",
|
"simplyTranslateLokiCustomRedirects",
|
||||||
|
|
||||||
"lingvaNormalRedirectsChecks",
|
"lingvaNormalRedirectsChecks",
|
||||||
"lingvaNormalCustomRedirects",
|
"lingvaNormalCustomRedirects",
|
||||||
"lingvaTorRedirectsChecks",
|
"lingvaTorRedirectsChecks",
|
||||||
"lingvaTorCustomRedirects",
|
"lingvaTorCustomRedirects",
|
||||||
"lingvaI2pCustomRedirects",
|
"lingvaI2pCustomRedirects",
|
||||||
"lingvaLokiCustomRedirects"
|
"lingvaLokiCustomRedirects",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
translateDisable = r.translateDisable;
|
translateDisable = r.translateDisable
|
||||||
translateFrontend = r.translateFrontend;
|
translateFrontend = r.translateFrontend
|
||||||
protocol = r.protocol;
|
protocol = r.protocol
|
||||||
protocolFallback = r.protocolFallback
|
protocolFallback = r.protocolFallback
|
||||||
translateRedirects = r.translateRedirects;
|
translateRedirects = r.translateRedirects
|
||||||
simplyTranslateNormalRedirectsChecks = r.simplyTranslateNormalRedirectsChecks;
|
simplyTranslateNormalRedirectsChecks = r.simplyTranslateNormalRedirectsChecks
|
||||||
simplyTranslateNormalCustomRedirects = r.simplyTranslateNormalCustomRedirects;
|
simplyTranslateNormalCustomRedirects = r.simplyTranslateNormalCustomRedirects
|
||||||
simplyTranslateTorRedirectsChecks = r.simplyTranslateTorRedirectsChecks;
|
simplyTranslateTorRedirectsChecks = r.simplyTranslateTorRedirectsChecks
|
||||||
simplyTranslateTorCustomRedirects = r.simplyTranslateTorCustomRedirects;
|
simplyTranslateTorCustomRedirects = r.simplyTranslateTorCustomRedirects
|
||||||
simplyTranslateI2pRedirectsChecks = r.simplyTranslateI2pRedirectsChecks;
|
simplyTranslateI2pRedirectsChecks = r.simplyTranslateI2pRedirectsChecks
|
||||||
simplyTranslateI2pCustomRedirects = r.simplyTranslateI2pCustomRedirects;
|
simplyTranslateI2pCustomRedirects = r.simplyTranslateI2pCustomRedirects
|
||||||
simplyTranslateLokiRedirectsChecks = r.simplyTranslateLokiRedirectsChecks;
|
simplyTranslateLokiRedirectsChecks = r.simplyTranslateLokiRedirectsChecks
|
||||||
simplyTranslateLokiCustomRedirects = r.simplyTranslateLokiCustomRedirects;
|
simplyTranslateLokiCustomRedirects = r.simplyTranslateLokiCustomRedirects
|
||||||
lingvaNormalRedirectsChecks = r.lingvaNormalRedirectsChecks;
|
lingvaNormalRedirectsChecks = r.lingvaNormalRedirectsChecks
|
||||||
lingvaNormalCustomRedirects = r.lingvaNormalCustomRedirects;
|
lingvaNormalCustomRedirects = r.lingvaNormalCustomRedirects
|
||||||
lingvaTorRedirectsChecks = r.lingvaTorRedirectsChecks;
|
lingvaTorRedirectsChecks = r.lingvaTorRedirectsChecks
|
||||||
lingvaTorCustomRedirects = r.lingvaTorCustomRedirects;
|
lingvaTorCustomRedirects = r.lingvaTorCustomRedirects
|
||||||
lingvaI2pCustomRedirects = r.lingvaI2pCustomRedirects;
|
lingvaI2pCustomRedirects = r.lingvaI2pCustomRedirects
|
||||||
lingvaLokiCustomRedirects = r.lingvaLokiCustomRedirects;
|
lingvaLokiCustomRedirects = r.lingvaLokiCustomRedirects
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
function setRedirects(val) {
|
function setRedirects(val) {
|
||||||
browser.storage.local.get('cloudflareBlackList', r => {
|
browser.storage.local.get("cloudflareBlackList", r => {
|
||||||
redirects = val;
|
redirects = val
|
||||||
lingvaNormalRedirectsChecks = [...redirects.lingva.normal]
|
lingvaNormalRedirectsChecks = [...redirects.lingva.normal]
|
||||||
for (const instance of r.cloudflareBlackList) {
|
for (const instance of r.cloudflareBlackList) {
|
||||||
const i = lingvaNormalRedirectsChecks.indexOf(instance);
|
const i = lingvaNormalRedirectsChecks.indexOf(instance)
|
||||||
if (i > -1) lingvaNormalRedirectsChecks.splice(i, 1);
|
if (i > -1) lingvaNormalRedirectsChecks.splice(i, 1)
|
||||||
}
|
}
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
translateRedirects: redirects,
|
translateRedirects: redirects,
|
||||||
simplyTranslateNormalRedirectsChecks: redirects.simplyTranslate.normal,
|
simplyTranslateNormalRedirectsChecks: redirects.simplyTranslate.normal,
|
||||||
simplyTranslateTorRedirectsChecks: redirects.simplyTranslate.tor,
|
simplyTranslateTorRedirectsChecks: redirects.simplyTranslate.tor,
|
||||||
simplyTranslateI2pRedirectsChecks: redirects.simplyTranslate.i2p,
|
simplyTranslateI2pRedirectsChecks: redirects.simplyTranslate.i2p,
|
||||||
simplyTranslateLokiRedirectsChecks: redirects.simplyTranslate.loki,
|
simplyTranslateLokiRedirectsChecks: redirects.simplyTranslate.loki,
|
||||||
lingvaNormalRedirectsChecks,
|
lingvaNormalRedirectsChecks,
|
||||||
lingvaTorRedirectsChecks: redirects.lingva.tor,
|
lingvaTorRedirectsChecks: redirects.lingva.tor,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyPasteLingvaLocalStorage(test, url, tabId) {
|
function copyPasteLingvaLocalStorage(test, url, tabId) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (translateDisable || translateFrontend != 'lingva') { resolve(); return; }
|
if (translateDisable || translateFrontend != "lingva") {
|
||||||
const protocolHost = utils.protocolHost(url);
|
resolve()
|
||||||
if (![
|
return
|
||||||
...lingvaNormalRedirectsChecks,
|
}
|
||||||
...lingvaNormalCustomRedirects,
|
const protocolHost = utils.protocolHost(url)
|
||||||
...lingvaTorRedirectsChecks,
|
if (
|
||||||
...lingvaTorCustomRedirects,
|
![...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects, ...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects, ...lingvaI2pCustomRedirects, ...lingvaLokiCustomRedirects].includes(
|
||||||
...lingvaI2pCustomRedirects,
|
protocolHost
|
||||||
...lingvaLokiCustomRedirects
|
)
|
||||||
].includes(protocolHost)) { resolve(); return; }
|
) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!test) {
|
if (!test) {
|
||||||
browser.tabs.executeScript(
|
browser.tabs.executeScript(tabId, {
|
||||||
tabId,
|
file: "/assets/javascripts/translate/get_lingva_preferences.js",
|
||||||
{ file: "/assets/javascripts/translate/get_lingva_preferences.js", runAt: "document_start" }
|
runAt: "document_start",
|
||||||
);
|
})
|
||||||
|
|
||||||
let checkedInstances = [];
|
let checkedInstances = []
|
||||||
if (protocol == 'loki') checkedInstances = [...lingvaLokiCustomRedirects]; //...lingvaLokiRedirectsChecks,
|
if (protocol == "loki") checkedInstances = [...lingvaLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') checkedInstances = [...lingvaI2pCustomRedirects]; //...lingvaI2pRedirectsChecks,
|
//...lingvaLokiRedirectsChecks,
|
||||||
else if (protocol == 'tor') checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects];
|
else if (protocol == "i2p") checkedInstances = [...lingvaI2pCustomRedirects]
|
||||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
//...lingvaI2pRedirectsChecks,
|
||||||
checkedInstances = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects];
|
else if (protocol == "tor") checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]
|
||||||
}
|
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
const i = checkedInstances.indexOf(protocolHost);
|
checkedInstances = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]
|
||||||
if (i !== -1) checkedInstances.splice(i, 1);
|
}
|
||||||
if (checkedInstances.length === 0) { resolve(); return; }
|
const i = checkedInstances.indexOf(protocolHost)
|
||||||
for (const to of checkedInstances)
|
if (i !== -1) checkedInstances.splice(i, 1)
|
||||||
browser.tabs.create(
|
if (checkedInstances.length === 0) {
|
||||||
{ url: to },
|
resolve()
|
||||||
tab => browser.tabs.executeScript(tab.id, { file: "/assets/javascripts/translate/set_lingva_preferences.js", runAt: "document_start" })
|
return
|
||||||
);
|
}
|
||||||
}
|
for (const to of checkedInstances)
|
||||||
resolve(true);
|
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() {
|
function pasteLingvaLocalStorage() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (translateDisable || translateFrontend != 'lingva') { resolve(); return; }
|
if (translateDisable || translateFrontend != "lingva") {
|
||||||
let checkedInstances = [];
|
resolve()
|
||||||
if (protocol == 'loki') checkedInstances = [...lingvaLokiCustomRedirects]; //...lingvaLokiRedirectsChecks,
|
return
|
||||||
else if (protocol == 'i2p') checkedInstances = [...lingvaI2pCustomRedirects]; //...lingvaI2pRedirectsChecks,
|
}
|
||||||
else if (protocol == 'tor') checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects];
|
let checkedInstances = []
|
||||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
if (protocol == "loki") checkedInstances = [...lingvaLokiCustomRedirects]
|
||||||
checkedInstances = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects];
|
//...lingvaLokiRedirectsChecks,
|
||||||
}
|
else if (protocol == "i2p") checkedInstances = [...lingvaI2pCustomRedirects]
|
||||||
for (const to of checkedInstances)
|
//...lingvaI2pRedirectsChecks,
|
||||||
browser.tabs.create({ url: to },
|
else if (protocol == "tor") checkedInstances = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]
|
||||||
tab => browser.tabs.executeScript(tab.id, { file: "/assets/javascripts/translate/set_lingva_preferences.js", runAt: "document_start" }))
|
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
resolve();
|
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) {
|
function copyPasteSimplyTranslateCookies(test, from) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
const protocolHost = utils.protocolHost(from);
|
const protocolHost = utils.protocolHost(from)
|
||||||
if (![
|
if (
|
||||||
...simplyTranslateNormalRedirectsChecks,
|
![
|
||||||
...simplyTranslateNormalCustomRedirects,
|
...simplyTranslateNormalRedirectsChecks,
|
||||||
...simplyTranslateTorRedirectsChecks,
|
...simplyTranslateNormalCustomRedirects,
|
||||||
...simplyTranslateTorCustomRedirects,
|
...simplyTranslateTorRedirectsChecks,
|
||||||
...simplyTranslateI2pRedirectsChecks,
|
...simplyTranslateTorCustomRedirects,
|
||||||
...simplyTranslateI2pCustomRedirects,
|
...simplyTranslateI2pRedirectsChecks,
|
||||||
...simplyTranslateLokiRedirectsChecks,
|
...simplyTranslateI2pCustomRedirects,
|
||||||
...simplyTranslateLokiCustomRedirects,
|
...simplyTranslateLokiRedirectsChecks,
|
||||||
].includes(protocolHost)) { resolve(); return; }
|
...simplyTranslateLokiCustomRedirects,
|
||||||
if (!test) {
|
].includes(protocolHost)
|
||||||
let checkedInstances = [];
|
) {
|
||||||
if (protocol == 'loki') checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects]
|
resolve()
|
||||||
else if (protocol == 'i2p') checkedInstances = [...simplyTranslateI2pCustomRedirects, ...simplyTranslateI2pRedirectsChecks];
|
return
|
||||||
else if (protocol == 'tor') checkedInstances = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects];
|
}
|
||||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
if (!test) {
|
||||||
checkedInstances = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects];
|
let checkedInstances = []
|
||||||
}
|
if (protocol == "loki") checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects]
|
||||||
await utils.copyCookie('simplyTranslate', from, checkedInstances, 'from_lang');
|
else if (protocol == "i2p") checkedInstances = [...simplyTranslateI2pCustomRedirects, ...simplyTranslateI2pRedirectsChecks]
|
||||||
await utils.copyCookie('simplyTranslate', from, checkedInstances, 'to_lang');
|
else if (protocol == "tor") checkedInstances = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]
|
||||||
await utils.copyCookie('simplyTranslate', from, checkedInstances, 'tts_enabled');
|
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
await utils.copyCookie('simplyTranslate', from, checkedInstances, 'use_text_fields');
|
checkedInstances = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
resolve(true);
|
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() {
|
function pasteSimplyTranslateCookies() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (translateDisable || translateFrontend != 'simplyTranslate') { resolve(); return; }
|
if (translateDisable || translateFrontend != "simplyTranslate") {
|
||||||
let checkedInstances = [];
|
resolve()
|
||||||
if (protocol == 'loki') checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects]
|
return
|
||||||
else if (protocol == 'i2p') checkedInstances = [...simplyTranslateI2pCustomRedirects, ...simplyTranslateI2pRedirectsChecks];
|
}
|
||||||
else if (protocol == 'tor') checkedInstances = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects];
|
let checkedInstances = []
|
||||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
if (protocol == "loki") checkedInstances = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects]
|
||||||
checkedInstances = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects];
|
else if (protocol == "i2p") checkedInstances = [...simplyTranslateI2pCustomRedirects, ...simplyTranslateI2pRedirectsChecks]
|
||||||
}
|
else if (protocol == "tor") checkedInstances = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]
|
||||||
utils.getCookiesFromStorage('simplyTranslate', checkedInstances, 'from_lang');
|
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
utils.getCookiesFromStorage('simplyTranslate', checkedInstances, 'to_lang');
|
checkedInstances = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects]
|
||||||
utils.getCookiesFromStorage('simplyTranslate', checkedInstances, 'tts_enabled');
|
}
|
||||||
utils.getCookiesFromStorage('simplyTranslate', checkedInstances, 'use_text_fields');
|
utils.getCookiesFromStorage("simplyTranslate", checkedInstances, "from_lang")
|
||||||
resolve();
|
utils.getCookiesFromStorage("simplyTranslate", checkedInstances, "to_lang")
|
||||||
}
|
utils.getCookiesFromStorage("simplyTranslate", checkedInstances, "tts_enabled")
|
||||||
)
|
utils.getCookiesFromStorage("simplyTranslate", checkedInstances, "use_text_fields")
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirect(url, disableOverride) {
|
function redirect(url, disableOverride) {
|
||||||
if (translateDisable && !disableOverride) return;
|
if (translateDisable && !disableOverride) return
|
||||||
if (!targets.some(rx => rx.test(url.href))) return;
|
if (!targets.some(rx => rx.test(url.href))) return
|
||||||
|
|
||||||
if (translateFrontend == 'simplyTranslate') {
|
if (translateFrontend == "simplyTranslate") {
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...simplyTranslateI2pRedirectsChecks, ...simplyTranslateI2pCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...simplyTranslateI2pRedirectsChecks, ...simplyTranslateI2pCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects];
|
instancesList = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) return;
|
if (instancesList.length === 0) return
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList)
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
return `${randomInstance}/${url.search}`;
|
return `${randomInstance}/${url.search}`
|
||||||
}
|
} else if (translateFrontend == "lingva") {
|
||||||
else if (translateFrontend == 'lingva') {
|
let params_arr = url.search.split("&")
|
||||||
let params_arr = url.search.split('&');
|
params_arr[0] = params_arr[0].substring(1)
|
||||||
params_arr[0] = params_arr[0].substring(1);
|
let params = {}
|
||||||
let params = {};
|
for (let i = 0; i < params_arr.length; i++) {
|
||||||
for (let i = 0; i < params_arr.length; i++) {
|
let pair = params_arr[i].split("=")
|
||||||
let pair = params_arr[i].split('=');
|
params[pair[0]] = pair[1]
|
||||||
params[pair[0]] = pair[1];
|
}
|
||||||
}
|
let instancesList = []
|
||||||
let instancesList = [];
|
if (protocol == "loki") instancesList = [...lingvaLokiCustomRedirects]
|
||||||
if (protocol == 'loki') instancesList = [...lingvaLokiCustomRedirects]; //...lingvaLokiRedirectsChecks,
|
//...lingvaLokiRedirectsChecks,
|
||||||
else if (protocol == 'i2p') instancesList = [...lingvaI2pCustomRedirects]; //...lingvaI2pRedirectsChecks,
|
else if (protocol == "i2p") instancesList = [...lingvaI2pCustomRedirects] //...lingvaI2pRedirectsChecks,
|
||||||
if (protocol == 'tor') instancesList = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects];
|
if (protocol == "tor") instancesList = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects];
|
instancesList = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) return;
|
if (instancesList.length === 0) return
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList)
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
if (params.sl && params.tl && params.text) {
|
if (params.sl && params.tl && params.text) {
|
||||||
return `${randomInstance}/${params.sl}/${params.tl}/${params.text}`
|
return `${randomInstance}/${params.sl}/${params.tl}/${params.text}`
|
||||||
}
|
}
|
||||||
return randomInstance;
|
return randomInstance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchInstance(url, disableOverride) {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (translateDisable && !disableOverride) { resolve(); return; }
|
if (translateDisable && !disableOverride) {
|
||||||
const protocolHost = utils.protocolHost(url);
|
resolve()
|
||||||
if (![
|
return
|
||||||
...translateRedirects.simplyTranslate.normal,
|
}
|
||||||
...translateRedirects.simplyTranslate.tor,
|
const protocolHost = utils.protocolHost(url)
|
||||||
...translateRedirects.simplyTranslate.i2p,
|
if (
|
||||||
...translateRedirects.simplyTranslate.loki,
|
![
|
||||||
|
...translateRedirects.simplyTranslate.normal,
|
||||||
|
...translateRedirects.simplyTranslate.tor,
|
||||||
|
...translateRedirects.simplyTranslate.i2p,
|
||||||
|
...translateRedirects.simplyTranslate.loki,
|
||||||
|
|
||||||
...simplyTranslateNormalCustomRedirects,
|
...simplyTranslateNormalCustomRedirects,
|
||||||
...simplyTranslateTorCustomRedirects,
|
...simplyTranslateTorCustomRedirects,
|
||||||
...simplyTranslateI2pCustomRedirects,
|
...simplyTranslateI2pCustomRedirects,
|
||||||
...simplyTranslateLokiCustomRedirects,
|
...simplyTranslateLokiCustomRedirects,
|
||||||
|
|
||||||
...translateRedirects.lingva.normal,
|
...translateRedirects.lingva.normal,
|
||||||
...translateRedirects.lingva.tor,
|
...translateRedirects.lingva.tor,
|
||||||
|
|
||||||
...lingvaNormalCustomRedirects,
|
...lingvaNormalCustomRedirects,
|
||||||
...lingvaTorCustomRedirects,
|
...lingvaTorCustomRedirects,
|
||||||
...lingvaI2pCustomRedirects,
|
...lingvaI2pCustomRedirects,
|
||||||
...lingvaLokiCustomRedirects
|
...lingvaLokiCustomRedirects,
|
||||||
].includes(protocolHost)) { resolve(); return; }
|
].includes(protocolHost)
|
||||||
|
) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let instancesList;
|
let instancesList
|
||||||
|
|
||||||
if (protocol == 'loki') {
|
if (protocol == "loki") {
|
||||||
if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects];
|
if (translateFrontend == "simplyTranslate") instancesList = [...simplyTranslateLokiRedirectsChecks, ...simplyTranslateLokiCustomRedirects]
|
||||||
else if (translateFrontend == 'lingva') instancesList = [...lingvaLokiCustomRedirects]; //...lingvaLokiRedirectsChecks,
|
else if (translateFrontend == "lingva") instancesList = [...lingvaLokiCustomRedirects] //...lingvaLokiRedirectsChecks,
|
||||||
}
|
} else if (protocol == "i2p") {
|
||||||
else if (protocol == 'i2p') {
|
if (translateFrontend == "simplyTranslate") instancesList = [...simplyTranslateI2pRedirectsChecks, ...simplyTranslateI2pCustomRedirects]
|
||||||
if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateI2pRedirectsChecks, ...simplyTranslateI2pCustomRedirects];
|
else if (translateFrontend == "lingva") instancesList = [...lingvaI2pCustomRedirects] //...lingvaI2pRedirectsChecks,
|
||||||
else if (translateFrontend == 'lingva') instancesList = [...lingvaI2pCustomRedirects]; //...lingvaI2pRedirectsChecks,
|
} else if (protocol == "tor") {
|
||||||
}
|
if (translateFrontend == "simplyTranslate") instancesList = [...simplyTranslateTorRedirectsChecks, ...simplyTranslateTorCustomRedirects]
|
||||||
else if (protocol == 'tor') {
|
else if (translateFrontend == "lingva") instancesList = [...lingvaTorRedirectsChecks, ...lingvaTorCustomRedirects]
|
||||||
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]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
else if (translateFrontend == "lingva") instancesList = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects]
|
||||||
if (translateFrontend == 'simplyTranslate') instancesList = [...simplyTranslateNormalRedirectsChecks, ...simplyTranslateNormalCustomRedirects];
|
}
|
||||||
else if (translateFrontend == 'lingva') instancesList = [...lingvaNormalRedirectsChecks, ...lingvaNormalCustomRedirects];
|
|
||||||
}
|
|
||||||
|
|
||||||
const i = instancesList.indexOf(protocolHost);
|
const i = instancesList.indexOf(protocolHost)
|
||||||
if (i > -1) instancesList.splice(i, 1);
|
if (i > -1) instancesList.splice(i, 1)
|
||||||
if (instancesList.length === 0) { resolve(); return; }
|
if (instancesList.length === 0) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaults() {
|
function initDefaults() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
fetch("/instances/data.json")
|
||||||
let dataJson = JSON.parse(data);
|
.then(response => response.text())
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
.then(data => {
|
||||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
let dataJson = JSON.parse(data)
|
||||||
}
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
browser.storage.local.get('cloudflareBlackList',
|
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||||
async r => {
|
}
|
||||||
lingvaNormalRedirectsChecks = [...redirects.lingva.normal]
|
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||||
for (const instance of r.cloudflareBlackList) {
|
lingvaNormalRedirectsChecks = [...redirects.lingva.normal]
|
||||||
const i = lingvaNormalRedirectsChecks.indexOf(instance);
|
for (const instance of r.cloudflareBlackList) {
|
||||||
if (i > -1) lingvaNormalRedirectsChecks.splice(i, 1);
|
const i = lingvaNormalRedirectsChecks.indexOf(instance)
|
||||||
}
|
if (i > -1) lingvaNormalRedirectsChecks.splice(i, 1)
|
||||||
browser.storage.local.set({
|
}
|
||||||
translateDisable: false,
|
browser.storage.local.set(
|
||||||
translateFrontend: "simplyTranslate",
|
{
|
||||||
translateRedirects: redirects,
|
translateDisable: false,
|
||||||
|
translateFrontend: "simplyTranslate",
|
||||||
|
translateRedirects: redirects,
|
||||||
|
|
||||||
simplyTranslateNormalRedirectsChecks: [...redirects.simplyTranslate.normal],
|
simplyTranslateNormalRedirectsChecks: [...redirects.simplyTranslate.normal],
|
||||||
simplyTranslateNormalCustomRedirects: [],
|
simplyTranslateNormalCustomRedirects: [],
|
||||||
|
|
||||||
simplyTranslateTorRedirectsChecks: [...redirects.simplyTranslate.tor],
|
|
||||||
simplyTranslateTorCustomRedirects: [],
|
|
||||||
|
|
||||||
simplyTranslateI2pRedirectsChecks: [...redirects.simplyTranslate.i2p],
|
|
||||||
simplyTranslateI2pCustomRedirects: [],
|
|
||||||
|
|
||||||
simplyTranslateLokiRedirectsChecks: [...redirects.simplyTranslate.loki],
|
|
||||||
simplyTranslateLokiCustomRedirects: [],
|
|
||||||
|
|
||||||
lingvaNormalRedirectsChecks: lingvaNormalRedirectsChecks,
|
simplyTranslateTorRedirectsChecks: [...redirects.simplyTranslate.tor],
|
||||||
lingvaNormalCustomRedirects: [],
|
simplyTranslateTorCustomRedirects: [],
|
||||||
|
|
||||||
lingvaTorRedirectsChecks: [...redirects.lingva.tor],
|
simplyTranslateI2pRedirectsChecks: [...redirects.simplyTranslate.i2p],
|
||||||
lingvaTorCustomRedirects: [],
|
simplyTranslateI2pCustomRedirects: [],
|
||||||
|
|
||||||
lingvaI2pRedirectsChecks: [...redirects.lingva.i2p],
|
simplyTranslateLokiRedirectsChecks: [...redirects.simplyTranslate.loki],
|
||||||
lingvaI2pCustomRedirects: [],
|
simplyTranslateLokiCustomRedirects: [],
|
||||||
|
|
||||||
lingvaLokiRedirectsChecks: [...redirects.lingva.loki],
|
lingvaNormalRedirectsChecks: lingvaNormalRedirectsChecks,
|
||||||
lingvaLokiCustomRedirects: []
|
lingvaNormalCustomRedirects: [],
|
||||||
}, () => resolve())
|
|
||||||
})
|
lingvaTorRedirectsChecks: [...redirects.lingva.tor],
|
||||||
})
|
lingvaTorCustomRedirects: [],
|
||||||
})
|
|
||||||
|
lingvaI2pRedirectsChecks: [...redirects.lingva.i2p],
|
||||||
|
lingvaI2pCustomRedirects: [],
|
||||||
|
|
||||||
|
lingvaLokiRedirectsChecks: [...redirects.lingva.loki],
|
||||||
|
lingvaLokiCustomRedirects: [],
|
||||||
|
},
|
||||||
|
() => resolve()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
copyPasteSimplyTranslateCookies,
|
copyPasteSimplyTranslateCookies,
|
||||||
pasteSimplyTranslateCookies,
|
pasteSimplyTranslateCookies,
|
||||||
copyPasteLingvaLocalStorage,
|
copyPasteLingvaLocalStorage,
|
||||||
pasteLingvaLocalStorage,
|
pasteLingvaLocalStorage,
|
||||||
setRedirects,
|
setRedirects,
|
||||||
redirect,
|
redirect,
|
||||||
initDefaults,
|
initDefaults,
|
||||||
switchInstance,
|
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 = [
|
const targets = [/^https?:\/{2}(www\.|mobile\.|)twitter\.com/, /^https?:\/{2}(pbs\.|video\.|)twimg\.com/, /^https?:\/{2}platform\.twitter\.com\/embed/, /^https?:\/{2}t\.co/]
|
||||||
/^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 frontends = new Array("nitter")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
@ -15,287 +10,295 @@ const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
let redirects = {}
|
let redirects = {}
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
redirects[frontends[i]] = {}
|
redirects[frontends[i]] = {}
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
redirects[frontends[i]][protocols[x]] = []
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRedirects(val) {
|
function setRedirects(val) {
|
||||||
browser.storage.local.get(['cloudflareBlackList', 'authenticateBlackList'], r => {
|
browser.storage.local.get(["cloudflareBlackList", "authenticateBlackList"], r => {
|
||||||
redirects.nitter = val;
|
redirects.nitter = val
|
||||||
nitterNormalRedirectsChecks = [...redirects.nitter.normal];
|
nitterNormalRedirectsChecks = [...redirects.nitter.normal]
|
||||||
for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList]) {
|
for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList]) {
|
||||||
let i = nitterNormalRedirectsChecks.indexOf(instance);
|
let i = nitterNormalRedirectsChecks.indexOf(instance)
|
||||||
if (i > -1) nitterNormalRedirectsChecks.splice(i, 1);
|
if (i > -1) nitterNormalRedirectsChecks.splice(i, 1)
|
||||||
}
|
}
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
twitterRedirects: redirects,
|
twitterRedirects: redirects,
|
||||||
nitterNormalRedirectsChecks,
|
nitterNormalRedirectsChecks,
|
||||||
nitterTorRedirectsChecks: [...redirects.nitter.tor]
|
nitterTorRedirectsChecks: [...redirects.nitter.tor],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let disableTwitter,
|
||||||
disableTwitter,
|
protocol,
|
||||||
protocol,
|
protocolFallback,
|
||||||
protocolFallback,
|
twitterRedirects,
|
||||||
twitterRedirects,
|
twitterRedirectType,
|
||||||
twitterRedirectType,
|
nitterNormalRedirectsChecks,
|
||||||
nitterNormalRedirectsChecks,
|
nitterNormalCustomRedirects,
|
||||||
nitterNormalCustomRedirects,
|
nitterTorRedirectsChecks,
|
||||||
nitterTorRedirectsChecks,
|
nitterTorCustomRedirects,
|
||||||
nitterTorCustomRedirects,
|
nitterI2pCustomRedirects,
|
||||||
nitterI2pCustomRedirects,
|
nitterLokiCustomRedirects
|
||||||
nitterLokiCustomRedirects;
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disableTwitter",
|
"disableTwitter",
|
||||||
"protocol",
|
"protocol",
|
||||||
"protocolFallback",
|
"protocolFallback",
|
||||||
"twitterRedirects",
|
"twitterRedirects",
|
||||||
"twitterRedirectType",
|
"twitterRedirectType",
|
||||||
"nitterNormalRedirectsChecks",
|
"nitterNormalRedirectsChecks",
|
||||||
"nitterNormalCustomRedirects",
|
"nitterNormalCustomRedirects",
|
||||||
"nitterTorRedirectsChecks",
|
"nitterTorRedirectsChecks",
|
||||||
"nitterTorCustomRedirects",
|
"nitterTorCustomRedirects",
|
||||||
"nitterI2pCustomRedirects",
|
"nitterI2pCustomRedirects",
|
||||||
"nitterLokiCustomRedirects"
|
"nitterLokiCustomRedirects",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
disableTwitter = r.disableTwitter;
|
disableTwitter = r.disableTwitter
|
||||||
protocol = r.protocol;
|
protocol = r.protocol
|
||||||
protocolFallback = r.protocolFallback;
|
protocolFallback = r.protocolFallback
|
||||||
twitterRedirects = r.twitterRedirects;
|
twitterRedirects = r.twitterRedirects
|
||||||
twitterRedirectType = r.twitterRedirectType;
|
twitterRedirectType = r.twitterRedirectType
|
||||||
nitterNormalRedirectsChecks = r.nitterNormalRedirectsChecks;
|
nitterNormalRedirectsChecks = r.nitterNormalRedirectsChecks
|
||||||
nitterNormalCustomRedirects = r.nitterNormalCustomRedirects;
|
nitterNormalCustomRedirects = r.nitterNormalCustomRedirects
|
||||||
nitterTorRedirectsChecks = r.nitterTorRedirectsChecks;
|
nitterTorRedirectsChecks = r.nitterTorRedirectsChecks
|
||||||
nitterTorCustomRedirects = r.nitterTorCustomRedirects;
|
nitterTorCustomRedirects = r.nitterTorCustomRedirects
|
||||||
nitterI2pCustomRedirects = r.nitterI2pCustomRedirects;
|
nitterI2pCustomRedirects = r.nitterI2pCustomRedirects
|
||||||
nitterLokiCustomRedirects = r.nitterLokiCustomRedirects;
|
nitterLokiCustomRedirects = r.nitterLokiCustomRedirects
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
function all() {
|
function all() {
|
||||||
return [
|
return [...nitterNormalRedirectsChecks, ...nitterTorRedirectsChecks, ...nitterNormalCustomRedirects, ...nitterTorCustomRedirects, ...nitterI2pCustomRedirects, ...nitterLokiCustomRedirects]
|
||||||
...nitterNormalRedirectsChecks,
|
|
||||||
...nitterTorRedirectsChecks,
|
|
||||||
...nitterNormalCustomRedirects,
|
|
||||||
...nitterTorCustomRedirects,
|
|
||||||
...nitterI2pCustomRedirects,
|
|
||||||
...nitterLokiCustomRedirects
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirect(url, type, initiator, disableOverride) {
|
function redirect(url, type, initiator, disableOverride) {
|
||||||
if (disableTwitter && !disableOverride) return;
|
if (disableTwitter && !disableOverride) return
|
||||||
if (!targets.some(rx => rx.test(url.href))) return;
|
if (!targets.some(rx => rx.test(url.href))) return
|
||||||
if (url.pathname.split("/").includes("home")) return;
|
if (url.pathname.split("/").includes("home")) return
|
||||||
if (initiator && all().includes(initiator.origin)) return 'BYPASSTAB';
|
if (initiator && all().includes(initiator.origin)) return "BYPASSTAB"
|
||||||
if (twitterRedirectType == 'sub_frame' && type == "main_frame") return;
|
if (twitterRedirectType == "sub_frame" && type == "main_frame") return
|
||||||
if (twitterRedirectType == 'main_frame' && type != "main_frame") return;
|
if (twitterRedirectType == "main_frame" && type != "main_frame") return
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...nitterI2pCustomRedirects];
|
if (protocol == "loki") instancesList = [...nitterI2pCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...nitterLokiCustomRedirects];
|
else if (protocol == "i2p") instancesList = [...nitterLokiCustomRedirects]
|
||||||
else if (protocol == 'tor') instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects];
|
instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) return;
|
if (instancesList.length === 0) return
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
// https://pbs.twimg.com/profile_images/648888480974508032/66_cUYfj_400x400.jpg
|
// https://pbs.twimg.com/profile_images/648888480974508032/66_cUYfj_400x400.jpg
|
||||||
if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video") {
|
if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video") {
|
||||||
const [, id, format, extra] = url.search.match(/(.*)\?format=(.*)&(.*)/);
|
const [, id, format, extra] = url.search.match(/(.*)\?format=(.*)&(.*)/)
|
||||||
const query = encodeURIComponent(`${id}.${format}?${extra}`);
|
const query = encodeURIComponent(`${id}.${format}?${extra}`)
|
||||||
return `${randomInstance}/pic${url.pathname}${query}`;
|
return `${randomInstance}/pic${url.pathname}${query}`
|
||||||
}
|
} else if (url.pathname.split("/").includes("tweets")) return `${randomInstance}${url.pathname.replace("/tweets", "")}${url.search}`
|
||||||
else if (url.pathname.split("/").includes("tweets"))
|
else if (url.host == "t.co") return `${randomInstance}/t.co${url.pathname}`
|
||||||
return `${randomInstance}${url.pathname.replace("/tweets", "")}${url.search}`;
|
else return `${randomInstance}${url.pathname}${url.search}`
|
||||||
else if (url.host == 't.co')
|
|
||||||
return `${randomInstance}/t.co${url.pathname}`;
|
|
||||||
else
|
|
||||||
return `${randomInstance}${url.pathname}${url.search}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function reverse(url) {
|
function reverse(url) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
const protocolHost = utils.protocolHost(url);
|
const protocolHost = utils.protocolHost(url)
|
||||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
if (!all().includes(protocolHost)) {
|
||||||
resolve(`https://twitter.com${url.pathname}${url.search}`);
|
resolve()
|
||||||
})
|
return
|
||||||
|
}
|
||||||
|
resolve(`https://twitter.com${url.pathname}${url.search}`)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchInstance(url, disableOverride) {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableTwitter && !disableOverride) { resolve(); return; }
|
if (disableTwitter && !disableOverride) {
|
||||||
const protocolHost = utils.protocolHost(url);
|
resolve()
|
||||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
return
|
||||||
let instancesList = [];
|
}
|
||||||
if (protocol == 'loki') instancesList = [...nitterI2pCustomRedirects];
|
const protocolHost = utils.protocolHost(url)
|
||||||
else if (protocol == 'i2p') instancesList = [...nitterLokiCustomRedirects];
|
if (!all().includes(protocolHost)) {
|
||||||
else if (protocol == 'tor') instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects];
|
resolve()
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
return
|
||||||
instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects];
|
}
|
||||||
}
|
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);
|
let index = instancesList.indexOf(protocolHost)
|
||||||
if (index > -1) instancesList.splice(index, 1);
|
if (index > -1) instancesList.splice(index, 1)
|
||||||
if (instancesList.length === 0) { resolve(); return; }
|
if (instancesList.length === 0) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeXFrameOptions(e) {
|
function removeXFrameOptions(e) {
|
||||||
if (e.type != 'sub_frame') return;
|
if (e.type != "sub_frame") return
|
||||||
let url = new URL(e.url);
|
let url = new URL(e.url)
|
||||||
let protocolHost = utils.protocolHost(url);
|
let protocolHost = utils.protocolHost(url)
|
||||||
if (!all().includes(protocolHost)) return;
|
if (!all().includes(protocolHost)) return
|
||||||
let isChanged = false;
|
let isChanged = false
|
||||||
for (const i in e.responseHeaders) {
|
for (const i in e.responseHeaders) {
|
||||||
if (e.responseHeaders[i].name == 'x-frame-options') {
|
if (e.responseHeaders[i].name == "x-frame-options") {
|
||||||
e.responseHeaders.splice(i, 1);
|
e.responseHeaders.splice(i, 1)
|
||||||
isChanged = true;
|
isChanged = true
|
||||||
}
|
} else if (e.responseHeaders[i].name == "content-security-policy") {
|
||||||
else if (e.responseHeaders[i].name == 'content-security-policy') {
|
e.responseHeaders.splice(i, 1)
|
||||||
e.responseHeaders.splice(i, 1);
|
isChanged = true
|
||||||
isChanged = true;
|
}
|
||||||
}
|
}
|
||||||
}
|
if (isChanged) return { responseHeaders: e.responseHeaders }
|
||||||
if (isChanged) return { responseHeaders: e.responseHeaders };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initNitterCookies(test, from) {
|
function initNitterCookies(test, from) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
const protocolHost = utils.protocolHost(from);
|
const protocolHost = utils.protocolHost(from)
|
||||||
if (!all().includes(protocolHost)
|
if (!all().includes(protocolHost)) {
|
||||||
) { resolve(); return; }
|
resolve()
|
||||||
if (!test) {
|
return
|
||||||
let checkedInstances = [];
|
}
|
||||||
if (protocol == 'loki') checkedInstances = [...nitterI2pCustomRedirects];
|
if (!test) {
|
||||||
else if (protocol == 'i2p') checkedInstances = [...nitterLokiCustomRedirects];
|
let checkedInstances = []
|
||||||
else if (protocol == 'tor') checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects];
|
if (protocol == "loki") checkedInstances = [...nitterI2pCustomRedirects]
|
||||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
else if (protocol == "i2p") checkedInstances = [...nitterLokiCustomRedirects]
|
||||||
checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects];
|
else if (protocol == "tor") checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]
|
||||||
}
|
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'theme');
|
checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'infiniteScroll');
|
}
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'stickyProfile');
|
await utils.copyCookie("nitter", from, checkedInstances, "theme")
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'bidiSupport');
|
await utils.copyCookie("nitter", from, checkedInstances, "infiniteScroll")
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'hideTweetStats');
|
await utils.copyCookie("nitter", from, checkedInstances, "stickyProfile")
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'hideBanner');
|
await utils.copyCookie("nitter", from, checkedInstances, "bidiSupport")
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'hidePins');
|
await utils.copyCookie("nitter", from, checkedInstances, "hideTweetStats")
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'hideReplies');
|
await utils.copyCookie("nitter", from, checkedInstances, "hideBanner")
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'squareAvatars');
|
await utils.copyCookie("nitter", from, checkedInstances, "hidePins")
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'mp4Playback');
|
await utils.copyCookie("nitter", from, checkedInstances, "hideReplies")
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'hlsPlayback');
|
await utils.copyCookie("nitter", from, checkedInstances, "squareAvatars")
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'proxyVideos');
|
await utils.copyCookie("nitter", from, checkedInstances, "mp4Playback")
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'muteVideos');
|
await utils.copyCookie("nitter", from, checkedInstances, "hlsPlayback")
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'autoplayGifs');
|
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, "replaceInstagram")
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'replaceReddit');
|
await utils.copyCookie("nitter", from, checkedInstances, "replaceReddit")
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'replaceTwitter');
|
await utils.copyCookie("nitter", from, checkedInstances, "replaceTwitter")
|
||||||
await utils.copyCookie('nitter', from, checkedInstances, 'replaceYouTube');
|
await utils.copyCookie("nitter", from, checkedInstances, "replaceYouTube")
|
||||||
}
|
}
|
||||||
resolve(true);
|
resolve(true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function pasteNitterCookies() {
|
function pasteNitterCookies() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableTwitter || protocol === undefined) { resolve(); return; }
|
if (disableTwitter || protocol === undefined) {
|
||||||
let checkedInstances = [];
|
resolve()
|
||||||
if (protocol == 'loki') checkedInstances = [...nitterI2pCustomRedirects];
|
return
|
||||||
else if (protocol == 'i2p') checkedInstances = [...nitterLokiCustomRedirects];
|
}
|
||||||
else if (protocol == 'tor') checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects];
|
let checkedInstances = []
|
||||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
if (protocol == "loki") checkedInstances = [...nitterI2pCustomRedirects]
|
||||||
checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects];
|
else if (protocol == "i2p") checkedInstances = [...nitterLokiCustomRedirects]
|
||||||
}
|
else if (protocol == "tor") checkedInstances = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects]
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'theme');
|
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'infiniteScroll');
|
checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects]
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'stickyProfile');
|
}
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'bidiSupport');
|
utils.getCookiesFromStorage("nitter", checkedInstances, "theme")
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'hideTweetStats');
|
utils.getCookiesFromStorage("nitter", checkedInstances, "infiniteScroll")
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'hideBanner');
|
utils.getCookiesFromStorage("nitter", checkedInstances, "stickyProfile")
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'hidePins');
|
utils.getCookiesFromStorage("nitter", checkedInstances, "bidiSupport")
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'hideReplies');
|
utils.getCookiesFromStorage("nitter", checkedInstances, "hideTweetStats")
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'squareAvatars');
|
utils.getCookiesFromStorage("nitter", checkedInstances, "hideBanner")
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'mp4Playback');
|
utils.getCookiesFromStorage("nitter", checkedInstances, "hidePins")
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'hlsPlayback');
|
utils.getCookiesFromStorage("nitter", checkedInstances, "hideReplies")
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'proxyVideos');
|
utils.getCookiesFromStorage("nitter", checkedInstances, "squareAvatars")
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'muteVideos');
|
utils.getCookiesFromStorage("nitter", checkedInstances, "mp4Playback")
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'autoplayGifs');
|
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, "replaceInstagram")
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'replaceReddit');
|
utils.getCookiesFromStorage("nitter", checkedInstances, "replaceReddit")
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'replaceTwitter');
|
utils.getCookiesFromStorage("nitter", checkedInstances, "replaceTwitter")
|
||||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'replaceYouTube');
|
utils.getCookiesFromStorage("nitter", checkedInstances, "replaceYouTube")
|
||||||
resolve();
|
resolve()
|
||||||
}
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaults() {
|
function initDefaults() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
fetch("/instances/data.json")
|
||||||
let dataJson = JSON.parse(data);
|
.then(response => response.text())
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
.then(data => {
|
||||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
let dataJson = JSON.parse(data)
|
||||||
}
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
browser.storage.local.get(['cloudflareBlackList', 'authenticateBlackList'], async r => {
|
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||||
nitterNormalRedirectsChecks = [...redirects.nitter.normal];
|
}
|
||||||
for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList]) {
|
browser.storage.local.get(["cloudflareBlackList", "authenticateBlackList"], async r => {
|
||||||
let i = nitterNormalRedirectsChecks.indexOf(instance);
|
nitterNormalRedirectsChecks = [...redirects.nitter.normal]
|
||||||
if (i > -1) nitterNormalRedirectsChecks.splice(i, 1);
|
for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList]) {
|
||||||
}
|
let i = nitterNormalRedirectsChecks.indexOf(instance)
|
||||||
browser.storage.local.set({
|
if (i > -1) nitterNormalRedirectsChecks.splice(i, 1)
|
||||||
disableTwitter: false,
|
}
|
||||||
twitterRedirects: redirects,
|
browser.storage.local.set(
|
||||||
twitterRedirectType: "both",
|
{
|
||||||
|
disableTwitter: false,
|
||||||
|
twitterRedirects: redirects,
|
||||||
|
twitterRedirectType: "both",
|
||||||
|
|
||||||
nitterNormalRedirectsChecks: nitterNormalRedirectsChecks,
|
nitterNormalRedirectsChecks: nitterNormalRedirectsChecks,
|
||||||
nitterNormalCustomRedirects: [],
|
nitterNormalCustomRedirects: [],
|
||||||
|
|
||||||
nitterTorRedirectsChecks: [...redirects.nitter.tor],
|
nitterTorRedirectsChecks: [...redirects.nitter.tor],
|
||||||
nitterTorCustomRedirects: [],
|
nitterTorCustomRedirects: [],
|
||||||
|
|
||||||
nitterI2pRedirectsChecks: [...redirects.nitter.i2p],
|
nitterI2pRedirectsChecks: [...redirects.nitter.i2p],
|
||||||
nitterI2pCustomRedirects: [],
|
nitterI2pCustomRedirects: [],
|
||||||
|
|
||||||
nitterLokiRedirectsChecks: [...redirects.nitter.loki],
|
nitterLokiRedirectsChecks: [...redirects.nitter.loki],
|
||||||
nitterLokiCustomRedirects: []
|
nitterLokiCustomRedirects: [],
|
||||||
}, () => resolve());
|
},
|
||||||
})
|
() => resolve()
|
||||||
})
|
)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setRedirects,
|
setRedirects,
|
||||||
redirect,
|
redirect,
|
||||||
switchInstance,
|
switchInstance,
|
||||||
reverse,
|
reverse,
|
||||||
removeXFrameOptions,
|
removeXFrameOptions,
|
||||||
initNitterCookies,
|
initNitterCookies,
|
||||||
pasteNitterCookies,
|
pasteNitterCookies,
|
||||||
initDefaults,
|
initDefaults,
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,193 +1,207 @@
|
||||||
window.browser = window.browser || window.chrome;
|
window.browser = window.browser || window.chrome
|
||||||
import twitterHelper from "./twitter.js";
|
import twitterHelper from "./twitter.js"
|
||||||
import youtubeHelper from "./youtube/youtube.js";
|
import youtubeHelper from "./youtube/youtube.js"
|
||||||
import instagramHelper from "./instagram.js";
|
import instagramHelper from "./instagram.js"
|
||||||
import mediumHelper from "./medium.js";
|
import mediumHelper from "./medium.js"
|
||||||
import redditHelper from "./reddit.js";
|
import redditHelper from "./reddit.js"
|
||||||
import searchHelper from "./search.js";
|
import searchHelper from "./search.js"
|
||||||
import translateHelper from "./translate/translate.js";
|
import translateHelper from "./translate/translate.js"
|
||||||
import wikipediaHelper from "./wikipedia.js";
|
import wikipediaHelper from "./wikipedia.js"
|
||||||
import peertubeHelper from "./peertube.js";
|
import peertubeHelper from "./peertube.js"
|
||||||
import lbryHelper from "./lbry.js";
|
import lbryHelper from "./lbry.js"
|
||||||
import sendTargetsHelper from "./sendTargets.js";
|
import sendTargetsHelper from "./sendTargets.js"
|
||||||
import tiktokHelper from "./tiktok.js";
|
import tiktokHelper from "./tiktok.js"
|
||||||
import quoraHelper from "./quora.js"
|
import quoraHelper from "./quora.js"
|
||||||
import libremdbHelper from "./imdb.js";
|
import libremdbHelper from "./imdb.js"
|
||||||
import imgurHelper from "./imgur.js";
|
import imgurHelper from "./imgur.js"
|
||||||
import reutersHelper from './reuters.js';
|
import reutersHelper from "./reuters.js"
|
||||||
import localise from './localise.js'
|
import youtubeMusicHelper from "./youtubeMusic.js"
|
||||||
|
import mapsHelper from "./maps.js"
|
||||||
|
import localise from "./localise.js"
|
||||||
|
|
||||||
function getRandomInstance(instances) {
|
function getRandomInstance(instances) {
|
||||||
return instances[~~(instances.length * Math.random())];
|
return instances[~~(instances.length * Math.random())]
|
||||||
}
|
}
|
||||||
|
|
||||||
let cloudflareBlackList = [];
|
let cloudflareBlackList = []
|
||||||
let authenticateBlackList = [];
|
let authenticateBlackList = []
|
||||||
async function initcloudflareBlackList() {
|
async function initcloudflareBlackList() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
fetch('/instances/blacklist.json').then(response => response.text()).then(data => {
|
fetch("/instances/blacklist.json")
|
||||||
cloudflareBlackList = JSON.parse(data).cloudflare;
|
.then(response => response.text())
|
||||||
authenticateBlackList = JSON.parse(data).authenticate;
|
.then(data => {
|
||||||
resolve();
|
cloudflareBlackList = JSON.parse(data).cloudflare
|
||||||
})
|
authenticateBlackList = JSON.parse(data).authenticate
|
||||||
});
|
resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateInstances() {
|
function updateInstances() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
let http = new XMLHttpRequest();
|
let http = new XMLHttpRequest()
|
||||||
http.open('GET', 'https://raw.githubusercontent.com/libredirect/libredirect/master/src/instances/data.json', false);
|
http.open("GET", "https://raw.githubusercontent.com/libredirect/libredirect/master/src/instances/data.json", false)
|
||||||
http.send(null);
|
http.send(null)
|
||||||
if (http.status === 200) {
|
if (http.status === 200) {
|
||||||
await initcloudflareBlackList();
|
await initcloudflareBlackList()
|
||||||
const instances = JSON.parse(http.responseText);
|
const instances = JSON.parse(http.responseText)
|
||||||
|
|
||||||
youtubeHelper.setRedirects({ 'invidious': instances.invidious, 'piped': instances.piped, 'pipedMaterial': instances.pipedMaterial })
|
youtubeHelper.setRedirects({
|
||||||
twitterHelper.setRedirects(instances.nitter);
|
invidious: instances.invidious,
|
||||||
instagramHelper.setRedirects(instances.bibliogram);
|
piped: instances.piped,
|
||||||
redditHelper.setRedirects({ 'libreddit': instances.libreddit, 'teddit': instances.teddit });
|
pipedMaterial: instances.pipedMaterial,
|
||||||
translateHelper.setRedirects({ "simplyTranslate": instances.simplyTranslate, "lingva": instances.lingva });
|
})
|
||||||
searchHelper.setRedirects({ 'searx': instances.searx, 'searxng': instances.searxng, 'whoogle': instances.whoogle, 'librex': instances.librex });
|
twitterHelper.setRedirects(instances.nitter)
|
||||||
wikipediaHelper.setRedirects(instances.wikiless);
|
instagramHelper.setRedirects(instances.bibliogram)
|
||||||
mediumHelper.setRedirects(instances.scribe);
|
redditHelper.setRedirects({
|
||||||
quoraHelper.setRedirects(instances.quetre);
|
libreddit: instances.libreddit,
|
||||||
libremdbHelper.setRedirects(instances.libremdb);
|
teddit: instances.teddit,
|
||||||
sendTargetsHelper.setRedirects(instances.send);
|
})
|
||||||
tiktokHelper.setRedirects(instances.proxiTok);
|
translateHelper.setRedirects({
|
||||||
lbryHelper.setRedirects(instances.librarian);
|
simplyTranslate: instances.simplyTranslate,
|
||||||
reutersHelper.setRedirects(instances.neuters);
|
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");
|
console.info("Successfully updated Instances")
|
||||||
resolve(true); return;
|
resolve(true)
|
||||||
}
|
return
|
||||||
resolve()
|
}
|
||||||
})
|
resolve()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function protocolHost(url) {
|
function protocolHost(url) {
|
||||||
if (url.username && url.password) return `${url.protocol}//${url.username}:${url.password}@${url.host}`;
|
if (url.username && url.password) return `${url.protocol}//${url.username}:${url.password}@${url.host}`
|
||||||
return `${url.protocol}//${url.host}`;
|
return `${url.protocol}//${url.host}`
|
||||||
}
|
}
|
||||||
|
|
||||||
async function processDefaultCustomInstances(target, name, protocol, document) {
|
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) {
|
let nameCustomInstances = []
|
||||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
let nameCheckListElement = nameProtocolElement.getElementsByClassName("checklist")[0]
|
||||||
}
|
|
||||||
let latencyKey = `${name}Latency`;
|
|
||||||
let instancesLatency;
|
|
||||||
let nameProtocolElement = document.getElementById(name).getElementsByClassName(protocol)[0];
|
|
||||||
|
|
||||||
let nameCustomInstances = [];
|
await initcloudflareBlackList()
|
||||||
let nameCheckListElement = nameProtocolElement.getElementsByClassName('checklist')[0];
|
|
||||||
|
|
||||||
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 redirects
|
||||||
let customRedirects = `${name}${camelCase(protocol)}CustomRedirects`;
|
|
||||||
let redirectsKey = `${target}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() {
|
await getFromStorage()
|
||||||
return new Promise(async resolve =>
|
if (nameCustomInstances === undefined) console.log(customRedirects)
|
||||||
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);
|
|
||||||
|
|
||||||
function calcNameCheckBoxes() {
|
function calcNameCheckBoxes() {
|
||||||
let isTrue = true;
|
let isTrue = true
|
||||||
for (const item of redirects[name][protocol]) {
|
for (const item of redirects[name][protocol]) {
|
||||||
if (!nameDefaultRedirects.includes(item)) {
|
if (nameDefaultRedirects === undefined) console.log(name + protocol + " is undefined")
|
||||||
isTrue = false;
|
if (!nameDefaultRedirects.includes(item)) {
|
||||||
break;
|
isTrue = false
|
||||||
}
|
break
|
||||||
}
|
}
|
||||||
for (const element of nameCheckListElement.getElementsByTagName('input')) {
|
}
|
||||||
element.checked = nameDefaultRedirects.includes(element.className)
|
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;
|
if (nameDefaultRedirects.length == 0) isTrue = false
|
||||||
}
|
nameProtocolElement.getElementsByClassName("toggle-all")[0].checked = isTrue
|
||||||
nameCheckListElement.innerHTML =
|
}
|
||||||
[
|
nameCheckListElement.innerHTML = [
|
||||||
`<div>
|
`<div>
|
||||||
<x data-localise="__MSG_toggleAll__">Toggle All</x>
|
<x data-localise="__MSG_toggleAll__">Toggle All</x>
|
||||||
<input type="checkbox" class="toggle-all"/>
|
<input type="checkbox" class="toggle-all"/>
|
||||||
</div>`,
|
</div>`,
|
||||||
...redirects[name][protocol].map(
|
...redirects[name][protocol].map(x => {
|
||||||
x => {
|
const cloudflare = cloudflareBlackList.includes(x) ? ' <span style="color:red;">cloudflare</span>' : ""
|
||||||
const cloudflare = cloudflareBlackList.includes(x) ? ' <span style="color:red;">cloudflare</span>' : '';
|
const authenticate = authenticateBlackList.includes(x) ? ' <span style="color:orange;">authenticate</span>' : ""
|
||||||
const authenticate = authenticateBlackList.includes(x) ? ' <span style="color:orange;">authenticate</span>' : '';
|
|
||||||
|
|
||||||
let ms = instancesLatency[x];
|
let ms = instancesLatency[x]
|
||||||
let latencyColor = (ms <= 1000 ? "green" : ms <= 2000 ? "orange" : "red");
|
let latencyColor = ms <= 1000 ? "green" : ms <= 2000 ? "orange" : "red"
|
||||||
let latencyLimit;
|
let latencyLimit
|
||||||
if (ms == 5000) latencyLimit = '5000ms+';
|
if (ms == 5000) latencyLimit = "5000ms+"
|
||||||
else if (ms > 5000) latencyLimit = `ERROR: ${ms - 5000}`;
|
else if (ms > 5000) latencyLimit = `ERROR: ${ms - 5000}`
|
||||||
else latencyLimit = ms + 'ms';
|
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(' ');
|
let warnings = [cloudflare, authenticate, latency].join(" ")
|
||||||
return `<div>
|
return `<div>
|
||||||
<x><a href="${x}" target="_blank">${x}</a>${warnings}</x>
|
<x><a href="${x}" target="_blank">${x}</a>${warnings}</x>
|
||||||
<input type="checkbox" class="${x}"/>
|
<input type="checkbox" class="${x}"/>
|
||||||
</div>`;
|
</div>`
|
||||||
}
|
}),
|
||||||
),
|
].join("\n<hr>\n")
|
||||||
].join('\n<hr>\n');
|
|
||||||
|
|
||||||
localise.localisePage();
|
localise.localisePage()
|
||||||
|
|
||||||
calcNameCheckBoxes();
|
calcNameCheckBoxes()
|
||||||
nameProtocolElement.getElementsByClassName('toggle-all')[0].addEventListener("change", async event => {
|
nameProtocolElement.getElementsByClassName("toggle-all")[0].addEventListener("change", async event => {
|
||||||
if (event.target.checked)
|
if (event.target.checked) nameDefaultRedirects = [...redirects[name][protocol]]
|
||||||
nameDefaultRedirects = [...redirects[name][protocol]];
|
else nameDefaultRedirects = []
|
||||||
else
|
|
||||||
nameDefaultRedirects = [];
|
|
||||||
|
|
||||||
browser.storage.local.set({ [redirectsChecks]: nameDefaultRedirects });
|
browser.storage.local.set({ [redirectsChecks]: nameDefaultRedirects })
|
||||||
calcNameCheckBoxes();
|
calcNameCheckBoxes()
|
||||||
});
|
})
|
||||||
|
|
||||||
for (let element of nameCheckListElement.getElementsByTagName('input')) {
|
for (let element of nameCheckListElement.getElementsByTagName("input")) {
|
||||||
if (element.className != 'toggle-all')
|
if (element.className != "toggle-all")
|
||||||
nameProtocolElement.getElementsByClassName(element.className)[0].addEventListener("change", async event => {
|
nameProtocolElement.getElementsByClassName(element.className)[0].addEventListener("change", async event => {
|
||||||
if (event.target.checked)
|
if (event.target.checked) nameDefaultRedirects.push(element.className)
|
||||||
nameDefaultRedirects.push(element.className)
|
else {
|
||||||
else {
|
let index = nameDefaultRedirects.indexOf(element.className)
|
||||||
let index = nameDefaultRedirects.indexOf(element.className);
|
if (index > -1) nameDefaultRedirects.splice(index, 1)
|
||||||
if (index > -1) nameDefaultRedirects.splice(index, 1);
|
}
|
||||||
}
|
browser.storage.local.set({
|
||||||
browser.storage.local.set({ [redirectsChecks]: nameDefaultRedirects });
|
[redirectsChecks]: nameDefaultRedirects,
|
||||||
calcNameCheckBoxes();
|
})
|
||||||
});
|
calcNameCheckBoxes()
|
||||||
}
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function calcNameCustomInstances() {
|
function calcNameCustomInstances() {
|
||||||
nameProtocolElement.getElementsByClassName('custom-checklist')[0].innerHTML =
|
nameProtocolElement.getElementsByClassName("custom-checklist")[0].innerHTML = nameCustomInstances
|
||||||
nameCustomInstances.map(
|
.map(
|
||||||
x => `<div>
|
x => `<div>
|
||||||
${x}
|
${x}
|
||||||
<button class="add clear-${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">
|
<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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<hr>`
|
<hr>`
|
||||||
).join('\n');
|
)
|
||||||
|
.join("\n")
|
||||||
|
|
||||||
for (const item of nameCustomInstances) {
|
for (const item of nameCustomInstances) {
|
||||||
nameProtocolElement.getElementsByClassName(`clear-${item}`)[0].addEventListener("click", async () => {
|
nameProtocolElement.getElementsByClassName(`clear-${item}`)[0].addEventListener("click", async () => {
|
||||||
let index = nameCustomInstances.indexOf(item);
|
let index = nameCustomInstances.indexOf(item)
|
||||||
if (index > -1) nameCustomInstances.splice(index, 1);
|
if (index > -1) nameCustomInstances.splice(index, 1)
|
||||||
browser.storage.local.set({ [customRedirects]: nameCustomInstances });
|
browser.storage.local.set({ [customRedirects]: nameCustomInstances })
|
||||||
calcNameCustomInstances();
|
calcNameCustomInstances()
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
calcNameCustomInstances();
|
calcNameCustomInstances()
|
||||||
nameProtocolElement.getElementsByClassName('custom-instance-form')[0].addEventListener("submit", async event => {
|
nameProtocolElement.getElementsByClassName("custom-instance-form")[0].addEventListener("submit", async event => {
|
||||||
event.preventDefault();
|
event.preventDefault()
|
||||||
let nameCustomInstanceInput = nameProtocolElement.getElementsByClassName('custom-instance')[0];
|
let nameCustomInstanceInput = nameProtocolElement.getElementsByClassName("custom-instance")[0]
|
||||||
let url = new URL(nameCustomInstanceInput.value);
|
let url = new URL(nameCustomInstanceInput.value)
|
||||||
let protocolHostVar = protocolHost(url);
|
let protocolHostVar = protocolHost(url)
|
||||||
if (nameCustomInstanceInput.validity.valid && !redirects[name][protocol].includes(protocolHostVar)) {
|
if (nameCustomInstanceInput.validity.valid && !redirects[name][protocol].includes(protocolHostVar)) {
|
||||||
if (!nameCustomInstances.includes(protocolHostVar)) {
|
if (!nameCustomInstances.includes(protocolHostVar)) {
|
||||||
nameCustomInstances.push(protocolHostVar)
|
nameCustomInstances.push(protocolHostVar)
|
||||||
browser.storage.local.set({ [customRedirects]: nameCustomInstances });
|
browser.storage.local.set({ [customRedirects]: nameCustomInstances })
|
||||||
nameCustomInstanceInput.value = '';
|
nameCustomInstanceInput.value = ""
|
||||||
}
|
}
|
||||||
calcNameCustomInstances();
|
calcNameCustomInstances()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ping(href) {
|
async function ping(href) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
let http = new XMLHttpRequest();
|
let http = new XMLHttpRequest()
|
||||||
http.open("GET", `${href}?_=${new Date().getTime()}`, /*async*/true);
|
http.open("GET", `${href}?_=${new Date().getTime()}`, /*async*/ true)
|
||||||
http.timeout = 5000;
|
http.timeout = 5000
|
||||||
let started = new Date().getTime();
|
let started = new Date().getTime()
|
||||||
http.onreadystatechange = () => {
|
http.onreadystatechange = () => {
|
||||||
if (http.readyState == 2) {
|
if (http.readyState == 2) {
|
||||||
if (http.status == 200) {
|
if (http.status == 200) {
|
||||||
let ended = new Date().getTime();
|
let ended = new Date().getTime()
|
||||||
http.abort();
|
http.abort()
|
||||||
resolve(ended - started);
|
resolve(ended - started)
|
||||||
}
|
} else resolve(5000 + http.status)
|
||||||
else
|
}
|
||||||
resolve(5000 + http.status)
|
}
|
||||||
}
|
http.ontimeout = () => resolve(5000)
|
||||||
};
|
http.onerror = () => resolve()
|
||||||
http.ontimeout = () => resolve(5000)
|
try {
|
||||||
http.onerror = () => resolve()
|
http.send(null)
|
||||||
try {
|
} catch (exception) {
|
||||||
http.send(null);
|
resolve()
|
||||||
} catch (exception) {
|
}
|
||||||
resolve()
|
})
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testLatency(element, instances) {
|
async function testLatency(element, instances) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
let myList = {};
|
let myList = {}
|
||||||
for (const href of instances) await ping(href).then(time => {
|
for (const href of instances)
|
||||||
if (time) {
|
await ping(href).then(time => {
|
||||||
myList[href] = time;
|
if (time) {
|
||||||
let color;
|
myList[href] = time
|
||||||
if (time <= 1000) color = "green"
|
let color
|
||||||
else if (time <= 2000) color = "orange"
|
if (time <= 1000) color = "green"
|
||||||
else color = "red";
|
else if (time <= 2000) color = "orange"
|
||||||
|
else color = "red"
|
||||||
|
|
||||||
let text;
|
let text
|
||||||
if (time == 5000) text = '5000ms+'
|
if (time == 5000) text = "5000ms+"
|
||||||
else if (time > 5000) text = `ERROR: ${time - 5000}`;
|
else if (time > 5000) text = `ERROR: ${time - 5000}`
|
||||||
else text = `${time}ms`;
|
else text = `${time}ms`
|
||||||
element.innerHTML = `${href}: <span style="color:${color};">${text}</span>`;
|
element.innerHTML = `${href}: <span style="color:${color};">${text}</span>`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
resolve(myList);
|
resolve(myList)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyCookie(frontend, targetUrl, urls, name) {
|
function copyCookie(frontend, targetUrl, urls, name) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
browser.storage.local.get('firstPartyIsolate', r => {
|
browser.storage.local.get("firstPartyIsolate", r => {
|
||||||
let query;
|
let query
|
||||||
if (!r.firstPartyIsolate) query = { url: protocolHost(targetUrl), name: name }
|
if (!r.firstPartyIsolate) query = { url: protocolHost(targetUrl), name: name }
|
||||||
else query = { url: protocolHost(targetUrl), name: name, firstPartyDomain: null }
|
else
|
||||||
browser.cookies.getAll(
|
query = {
|
||||||
query,
|
url: protocolHost(targetUrl),
|
||||||
async cookies => {
|
name: name,
|
||||||
for (const cookie of cookies)
|
firstPartyDomain: null,
|
||||||
if (cookie.name == name) {
|
}
|
||||||
for (const url of urls) {
|
browser.cookies.getAll(query, async cookies => {
|
||||||
const setQuery =
|
for (const cookie of cookies)
|
||||||
r.firstPartyIsolate ?
|
if (cookie.name == name) {
|
||||||
{
|
for (const url of urls) {
|
||||||
url: url, name: name, value: cookie.value, secure: true,
|
const setQuery = r.firstPartyIsolate
|
||||||
firstPartyDomain: new URL(url).hostname,
|
? {
|
||||||
}
|
url: url,
|
||||||
:
|
name: name,
|
||||||
{
|
value: cookie.value,
|
||||||
url: url, name: name, value: cookie.value, secure: true,
|
secure: true,
|
||||||
expirationDate: cookie.expirationDate,
|
firstPartyDomain: new URL(url).hostname,
|
||||||
};
|
}
|
||||||
browser.cookies.set(setQuery, () =>
|
: {
|
||||||
browser.storage.local.set({ [`${frontend}_${name}`]: cookie }, () => resolve())
|
url: url,
|
||||||
);
|
name: name,
|
||||||
}
|
value: cookie.value,
|
||||||
break;
|
secure: true,
|
||||||
}
|
expirationDate: cookie.expirationDate,
|
||||||
resolve();
|
}
|
||||||
}
|
browser.cookies.set(setQuery, () => browser.storage.local.set({ [`${frontend}_${name}`]: cookie }, () => resolve()))
|
||||||
);
|
}
|
||||||
})
|
break
|
||||||
})
|
}
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCookiesFromStorage(frontend, urls, name) {
|
function getCookiesFromStorage(frontend, urls, name) {
|
||||||
let key = `${frontend}_${name}`;
|
let key = `${frontend}_${name}`
|
||||||
browser.storage.local.get([key, 'firstPartyIsolate'], r => {
|
browser.storage.local.get([key, "firstPartyIsolate"], r => {
|
||||||
const cookie = r[key];
|
const cookie = r[key]
|
||||||
if (cookie === undefined) return;
|
if (cookie === undefined) return
|
||||||
for (const url of urls) {
|
for (const url of urls) {
|
||||||
let query =
|
let query = r.firstPartyIsolate
|
||||||
r.firstPartyIsolate ?
|
? {
|
||||||
{
|
url: url,
|
||||||
url: url, name: cookie.name, value: cookie.value, secure: true,
|
name: cookie.name,
|
||||||
expirationDate: null,
|
value: cookie.value,
|
||||||
firstPartyDomain: new URL(url).hostname,
|
secure: true,
|
||||||
}
|
expirationDate: null,
|
||||||
:
|
firstPartyDomain: new URL(url).hostname,
|
||||||
{
|
}
|
||||||
url: url, name: cookie.name, value: cookie.value, secure: true,
|
: {
|
||||||
expirationDate: cookie.expirationDate,
|
url: url,
|
||||||
};
|
name: cookie.name,
|
||||||
browser.cookies.set(query)
|
value: cookie.value,
|
||||||
}
|
secure: true,
|
||||||
})
|
expirationDate: cookie.expirationDate,
|
||||||
|
}
|
||||||
|
browser.cookies.set(query)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyRaw(test, copyRawElement) {
|
function copyRaw(test, copyRawElement) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
browser.tabs.query(
|
browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
|
||||||
{ active: true, currentWindow: true }, async tabs => {
|
let currTab = tabs[0]
|
||||||
let currTab = tabs[0];
|
if (currTab) {
|
||||||
if (currTab) {
|
let url
|
||||||
let url;
|
try {
|
||||||
try { url = new URL(currTab.url); }
|
url = new URL(currTab.url)
|
||||||
catch { resolve(); return; }
|
} catch {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let newUrl = await youtubeHelper.reverse(url);
|
let newUrl = await youtubeHelper.reverse(url)
|
||||||
if (!newUrl) newUrl = await twitterHelper.reverse(url);
|
if (!newUrl) newUrl = await twitterHelper.reverse(url)
|
||||||
if (!newUrl) newUrl = await instagramHelper.reverse(url);
|
if (!newUrl) newUrl = await instagramHelper.reverse(url)
|
||||||
if (!newUrl) newUrl = await tiktokHelper.reverse(url);
|
if (!newUrl) newUrl = await tiktokHelper.reverse(url)
|
||||||
if (!newUrl) newUrl = await quoraHelper.reverse(url);
|
if (!newUrl) newUrl = await quoraHelper.reverse(url)
|
||||||
if (!newUrl) newUrl = await libremdbHelper.reverse(url);
|
if (!newUrl) newUrl = await libremdbHelper.reverse(url)
|
||||||
if (!newUrl) newUrl = await imgurHelper.reverse(url);
|
if (!newUrl) newUrl = await imgurHelper.reverse(url)
|
||||||
|
|
||||||
if (newUrl) {
|
if (newUrl) {
|
||||||
resolve(newUrl);
|
resolve(newUrl)
|
||||||
if (test) return;
|
if (test) return
|
||||||
navigator.clipboard.writeText(newUrl);
|
navigator.clipboard.writeText(newUrl)
|
||||||
if (copyRawElement) {
|
if (copyRawElement) {
|
||||||
const textElement = copyRawElement.getElementsByTagName('h4')[0]
|
const textElement = copyRawElement.getElementsByTagName("h4")[0]
|
||||||
const oldHtml = textElement.innerHTML;
|
const oldHtml = textElement.innerHTML
|
||||||
textElement.innerHTML = browser.i18n.getMessage('copied');
|
textElement.innerHTML = browser.i18n.getMessage("copied")
|
||||||
setTimeout(() => textElement.innerHTML = oldHtml, 1000);
|
setTimeout(() => (textElement.innerHTML = oldHtml), 1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolve()
|
resolve()
|
||||||
}
|
})
|
||||||
)
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function unify(test) {
|
function unify(test) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
browser.tabs.query(
|
browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
|
||||||
{ active: true, currentWindow: true },
|
let currTab = tabs[0]
|
||||||
async tabs => {
|
if (currTab) {
|
||||||
let currTab = tabs[0]
|
let url
|
||||||
if (currTab) {
|
try {
|
||||||
let url;
|
url = new URL(currTab.url)
|
||||||
try { url = new URL(currTab.url); }
|
} catch {
|
||||||
catch { resolve(); return; }
|
resolve()
|
||||||
if (currTab.incognito) { resolve(); return; }
|
return
|
||||||
|
}
|
||||||
|
if (currTab.incognito) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let result = await youtubeHelper.copyPasteInvidiousCookies(test, url);
|
let result = await youtubeHelper.copyPasteInvidiousCookies(test, url)
|
||||||
if (!result) result = await youtubeHelper.copyPastePipedLocalStorage(test, url, currTab.id);
|
if (!result) result = await youtubeHelper.copyPastePipedLocalStorage(test, url, currTab.id)
|
||||||
if (!result) result = await youtubeHelper.copyPastePipedMaterialLocalStorage(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);
|
resolve(result)
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchInstance(test) {
|
function switchInstance(test) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
|
browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
|
||||||
let currTab = tabs[0];
|
let currTab = tabs[0]
|
||||||
if (currTab) {
|
if (currTab) {
|
||||||
let url;
|
let url
|
||||||
try { url = new URL(currTab.url); }
|
try {
|
||||||
catch { resolve(); return };
|
url = new URL(currTab.url)
|
||||||
let newUrl = await youtubeHelper.switchInstance(url);
|
} catch {
|
||||||
if (!newUrl) newUrl = await twitterHelper.switchInstance(url);
|
resolve()
|
||||||
if (!newUrl) newUrl = await instagramHelper.switchInstance(url);
|
return
|
||||||
if (!newUrl) newUrl = await redditHelper.switchInstance(url);
|
}
|
||||||
if (!newUrl) newUrl = await searchHelper.switchInstance(url);
|
let newUrl = await youtubeHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await translateHelper.switchInstance(url);
|
if (!newUrl) newUrl = await twitterHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await mediumHelper.switchInstance(url);
|
if (!newUrl) newUrl = await instagramHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await quoraHelper.switchInstance(url);
|
if (!newUrl) newUrl = await redditHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await libremdbHelper.switchInstance(url);
|
if (!newUrl) newUrl = await searchHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await tiktokHelper.switchInstance(url);
|
if (!newUrl) newUrl = await translateHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await sendTargetsHelper.switchInstance(url);
|
if (!newUrl) newUrl = await mediumHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await peertubeHelper.switchInstance(url);
|
if (!newUrl) newUrl = await quoraHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await lbryHelper.switchInstance(url);
|
if (!newUrl) newUrl = await libremdbHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await imgurHelper.switchInstance(url);
|
if (!newUrl) newUrl = await tiktokHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await wikipediaHelper.switchInstance(url);
|
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 (newUrl) {
|
||||||
if (!test)
|
if (!test) browser.tabs.update({ url: newUrl })
|
||||||
browser.tabs.update({ url: newUrl });
|
resolve(true)
|
||||||
resolve(true)
|
} else resolve()
|
||||||
} else resolve()
|
}
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function latency(name, frontend, document, location) {
|
function latency(name, frontend, document, location) {
|
||||||
let latencyElement = document.getElementById(`latency-${frontend}`);
|
let latencyElement = document.getElementById(`latency-${frontend}`)
|
||||||
let latencyLabel = document.getElementById(`latency-${frontend}-label`);
|
let latencyLabel = document.getElementById(`latency-${frontend}-label`)
|
||||||
latencyElement.addEventListener("click",
|
latencyElement.addEventListener("click", async () => {
|
||||||
async () => {
|
let reloadWindow = () => location.reload()
|
||||||
let reloadWindow = () => location.reload();
|
latencyElement.addEventListener("click", reloadWindow)
|
||||||
latencyElement.addEventListener("click", reloadWindow);
|
let key = `${name}Redirects`
|
||||||
let key = `${name}Redirects`
|
browser.storage.local.get(key, r => {
|
||||||
browser.storage.local.get(
|
let redirects = r[key]
|
||||||
key,
|
const oldHtml = latencyLabel.innerHTML
|
||||||
r => {
|
latencyLabel.innerHTML = "..."
|
||||||
let redirects = r[key];
|
testLatency(latencyLabel, redirects[frontend].normal).then(r => {
|
||||||
const oldHtml = latencyLabel.innerHTML;
|
browser.storage.local.set({ [`${frontend}Latency`]: r })
|
||||||
latencyLabel.innerHTML = '...';
|
latencyLabel.innerHTML = oldHtml
|
||||||
testLatency(latencyLabel, redirects[frontend].normal).then(r => {
|
processDefaultCustomInstances(name, frontend, "normal", document)
|
||||||
browser.storage.local.set({ [`${frontend}Latency`]: r });
|
latencyElement.removeEventListener("click", reloadWindow)
|
||||||
latencyLabel.innerHTML = oldHtml;
|
})
|
||||||
processDefaultCustomInstances(name, frontend, 'normal', document);
|
})
|
||||||
latencyElement.removeEventListener("click", reloadWindow)
|
})
|
||||||
});
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getRandomInstance,
|
getRandomInstance,
|
||||||
updateInstances,
|
updateInstances,
|
||||||
protocolHost,
|
protocolHost,
|
||||||
processDefaultCustomInstances,
|
processDefaultCustomInstances,
|
||||||
latency,
|
latency,
|
||||||
copyCookie,
|
copyCookie,
|
||||||
getCookiesFromStorage,
|
getCookiesFromStorage,
|
||||||
switchInstance,
|
switchInstance,
|
||||||
copyRaw,
|
copyRaw,
|
||||||
unify,
|
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 targets = /^https?:\/{2}(([a-z]{1,}\.){0,})wikipedia\.org/
|
||||||
|
|
||||||
const frontends = new Array("wikiless")
|
const frontends = new Array("wikiless")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
let redirects = {};
|
let redirects = {}
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
redirects[frontends[i]] = {}
|
redirects[frontends[i]] = {}
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
redirects[frontends[i]][protocols[x]] = []
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRedirects(val) {
|
function setRedirects(val) {
|
||||||
browser.storage.local.get('cloudflareBlackList', r => {
|
browser.storage.local.get("cloudflareBlackList", r => {
|
||||||
redirects.wikiless = val;
|
redirects.wikiless = val
|
||||||
wikilessNormalRedirectsChecks = [...redirects.wikiless.normal];
|
wikilessNormalRedirectsChecks = [...redirects.wikiless.normal]
|
||||||
for (const instance of r.cloudflareBlackList) {
|
for (const instance of r.cloudflareBlackList) {
|
||||||
const a = wikilessNormalRedirectsChecks.indexOf(instance);
|
const a = wikilessNormalRedirectsChecks.indexOf(instance)
|
||||||
if (a > -1) wikilessNormalRedirectsChecks.splice(a, 1);
|
if (a > -1) wikilessNormalRedirectsChecks.splice(a, 1)
|
||||||
}
|
}
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
wikipediaRedirects: redirects,
|
wikipediaRedirects: redirects,
|
||||||
wikilessNormalRedirectsChecks
|
wikilessNormalRedirectsChecks,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let disableWikipedia,
|
||||||
disableWikipedia,
|
wikipediaRedirects,
|
||||||
wikipediaRedirects,
|
protocol,
|
||||||
protocol,
|
protocolFallback,
|
||||||
protocolFallback,
|
wikilessNormalRedirectsChecks,
|
||||||
wikilessNormalRedirectsChecks,
|
wikilessTorRedirectsChecks,
|
||||||
wikilessTorRedirectsChecks,
|
wikilessI2pRedirectsChecks,
|
||||||
wikilessI2pRedirectsChecks,
|
wikilessNormalCustomRedirects,
|
||||||
wikilessNormalCustomRedirects,
|
wikilessTorCustomRedirects,
|
||||||
wikilessTorCustomRedirects,
|
wikilessI2pCustomRedirects,
|
||||||
wikilessI2pCustomRedirects,
|
wikilessLokiCustomRedirects
|
||||||
wikilessLokiCustomRedirects;
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disableWikipedia",
|
"disableWikipedia",
|
||||||
"wikipediaRedirects",
|
"wikipediaRedirects",
|
||||||
"protocol",
|
"protocol",
|
||||||
"protocolFallback",
|
"protocolFallback",
|
||||||
"wikilessNormalRedirectsChecks",
|
"wikilessNormalRedirectsChecks",
|
||||||
"wikilessTorRedirectsChecks",
|
"wikilessTorRedirectsChecks",
|
||||||
"wikilessI2pRedirectsChecks",
|
"wikilessI2pRedirectsChecks",
|
||||||
"wikilessNormalCustomRedirects",
|
"wikilessNormalCustomRedirects",
|
||||||
"wikilessTorCustomRedirects",
|
"wikilessTorCustomRedirects",
|
||||||
"wikilessI2pCustomRedirects",
|
"wikilessI2pCustomRedirects",
|
||||||
"wikilessLokiCustomRedirects"
|
"wikilessLokiCustomRedirects",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
disableWikipedia = r.disableWikipedia;
|
disableWikipedia = r.disableWikipedia
|
||||||
wikipediaRedirects = r.wikipediaRedirects;
|
wikipediaRedirects = r.wikipediaRedirects
|
||||||
protocol = r.protocol;
|
protocol = r.protocol
|
||||||
protocolFallback = r.protocolFallback;
|
protocolFallback = r.protocolFallback
|
||||||
wikilessNormalRedirectsChecks = r.wikilessNormalRedirectsChecks;
|
wikilessNormalRedirectsChecks = r.wikilessNormalRedirectsChecks
|
||||||
wikilessTorRedirectsChecks = r.wikilessTorRedirectsChecks;
|
wikilessTorRedirectsChecks = r.wikilessTorRedirectsChecks
|
||||||
wikilessI2pRedirectsChecks = r.wikilessI2pRedirectsChecks;
|
wikilessI2pRedirectsChecks = r.wikilessI2pRedirectsChecks
|
||||||
wikilessNormalCustomRedirects = r.wikilessNormalCustomRedirects;
|
wikilessNormalCustomRedirects = r.wikilessNormalCustomRedirects
|
||||||
wikilessTorCustomRedirects = r.wikilessTorCustomRedirects;
|
wikilessTorCustomRedirects = r.wikilessTorCustomRedirects
|
||||||
wikilessI2pCustomRedirects = r.wikilessI2pCustomRedirects;
|
wikilessI2pCustomRedirects = r.wikilessI2pCustomRedirects
|
||||||
wikilessLokiCustomRedirects = r.wikilessLokiCustomRedirects;
|
wikilessLokiCustomRedirects = r.wikilessLokiCustomRedirects
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init()
|
||||||
browser.storage.onChanged.addListener(init)
|
browser.storage.onChanged.addListener(init)
|
||||||
|
|
||||||
function initWikilessCookies(test, from) {
|
function initWikilessCookies(test, from) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
const protocolHost = utils.protocolHost(from);
|
const protocolHost = utils.protocolHost(from)
|
||||||
const all = [
|
const all = [
|
||||||
...wikilessNormalRedirectsChecks,
|
...wikilessNormalRedirectsChecks,
|
||||||
...wikilessNormalCustomRedirects,
|
...wikilessNormalCustomRedirects,
|
||||||
...wikilessTorRedirectsChecks,
|
...wikilessTorRedirectsChecks,
|
||||||
...wikilessTorCustomRedirects,
|
...wikilessTorCustomRedirects,
|
||||||
...wikilessI2pRedirectsChecks,
|
...wikilessI2pRedirectsChecks,
|
||||||
...wikilessI2pCustomRedirects,
|
...wikilessI2pCustomRedirects,
|
||||||
...wikilessLokiCustomRedirects
|
...wikilessLokiCustomRedirects,
|
||||||
];
|
]
|
||||||
if (!all.includes(protocolHost)) { resolve(); return; }
|
if (!all.includes(protocolHost)) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!test) {
|
if (!test) {
|
||||||
let checkedInstances = [];
|
let checkedInstances = []
|
||||||
if (protocol == 'loki') checkedInstances = [...wikilessLokiCustomRedirects];
|
if (protocol == "loki") checkedInstances = [...wikilessLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks];
|
else if (protocol == "i2p") checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]
|
||||||
else if (protocol == 'tor') checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects];
|
else if (protocol == "tor") checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]
|
||||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects];
|
checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
await utils.copyCookie('wikiless', from, checkedInstances, 'theme');
|
await utils.copyCookie("wikiless", from, checkedInstances, "theme")
|
||||||
await utils.copyCookie('wikiless', from, checkedInstances, 'default_lang');
|
await utils.copyCookie("wikiless", from, checkedInstances, "default_lang")
|
||||||
}
|
}
|
||||||
resolve(true);
|
resolve(true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function pasteWikilessCookies() {
|
function pasteWikilessCookies() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableWikipedia || protocol === undefined) { resolve(); return; }
|
if (disableWikipedia || protocol === undefined) {
|
||||||
let checkedInstances = [];
|
resolve()
|
||||||
if (protocol == 'loki') checkedInstances = [...wikilessLokiCustomRedirects];
|
return
|
||||||
else if (protocol == 'i2p') checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks];
|
}
|
||||||
else if (protocol == 'tor') checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects];
|
let checkedInstances = []
|
||||||
if ((checkedInstances.length === 0 && protocolFallback) || protocol == 'normal') {
|
if (protocol == "loki") checkedInstances = [...wikilessLokiCustomRedirects]
|
||||||
checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects];
|
else if (protocol == "i2p") checkedInstances = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]
|
||||||
}
|
else if (protocol == "tor") checkedInstances = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]
|
||||||
utils.getCookiesFromStorage('wikiless', checkedInstances, 'theme');
|
if ((checkedInstances.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
utils.getCookiesFromStorage('wikiless', checkedInstances, 'default_lang');
|
checkedInstances = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]
|
||||||
resolve();
|
}
|
||||||
})
|
utils.getCookiesFromStorage("wikiless", checkedInstances, "theme")
|
||||||
|
utils.getCookiesFromStorage("wikiless", checkedInstances, "default_lang")
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirect(url, disableOverride) {
|
function redirect(url, disableOverride) {
|
||||||
if (disableWikipedia && !disableOverride) return;
|
if (disableWikipedia && !disableOverride) return
|
||||||
if (!targets.test(url.href)) return;
|
if (!targets.test(url.href)) return
|
||||||
|
|
||||||
let GETArguments = [];
|
let GETArguments = []
|
||||||
if (url.search.length > 0) {
|
if (url.search.length > 0) {
|
||||||
let search = url.search.substring(1); //get rid of '?'
|
let search = url.search.substring(1) //get rid of '?'
|
||||||
let argstrings = search.split("&");
|
let argstrings = search.split("&")
|
||||||
for (let i = 0; i < argstrings.length; i++) {
|
for (let i = 0; i < argstrings.length; i++) {
|
||||||
let args = argstrings[i].split("=");
|
let args = argstrings[i].split("=")
|
||||||
GETArguments.push([args[0], args[1]]);
|
GETArguments.push([args[0], args[1]])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...wikilessLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...wikilessLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks];
|
else if (protocol == "i2p") instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]
|
||||||
else if (protocol == 'tor') instancesList = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects];
|
instancesList = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) return;
|
if (instancesList.length === 0) return
|
||||||
const randomInstance = utils.getRandomInstance(instancesList)
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
|
|
||||||
let link = `${randomInstance}${url.pathname}`;
|
let link = `${randomInstance}${url.pathname}`
|
||||||
let urlSplit = url.host.split(".");
|
let urlSplit = url.host.split(".")
|
||||||
if (urlSplit[0] != "wikipedia" && urlSplit[0] != "www") {
|
if (urlSplit[0] != "wikipedia" && urlSplit[0] != "www") {
|
||||||
if (urlSplit[0] == "m")
|
if (urlSplit[0] == "m") GETArguments.push(["mobileaction", "toggle_view_mobile"])
|
||||||
GETArguments.push(["mobileaction", "toggle_view_mobile"]);
|
else GETArguments.push(["lang", urlSplit[0]])
|
||||||
else
|
if (urlSplit[1] == "m") GETArguments.push(["mobileaction", "toggle_view_mobile"])
|
||||||
GETArguments.push(["lang", urlSplit[0]]);
|
// wikiless doesn't have mobile view support yet
|
||||||
if (urlSplit[1] == "m")
|
}
|
||||||
GETArguments.push(["mobileaction", "toggle_view_mobile"]);
|
for (let i = 0; i < GETArguments.length; i++) link += (i == 0 ? "?" : "&") + GETArguments[i][0] + "=" + GETArguments[i][1]
|
||||||
// wikiless doesn't have mobile view support yet
|
return link
|
||||||
}
|
|
||||||
for (let i = 0; i < GETArguments.length; i++)
|
|
||||||
link += (i == 0 ? "?" : "&") + GETArguments[i][0] + "=" + GETArguments[i][1];
|
|
||||||
return link;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchInstance(url, disableOverride) {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
await init();
|
await init()
|
||||||
if (disableWikipedia && !disableOverride) { resolve(); return; }
|
if (disableWikipedia && !disableOverride) {
|
||||||
const protocolHost = utils.protocolHost(url);
|
resolve()
|
||||||
const wikipediaList = [
|
return
|
||||||
...wikipediaRedirects.wikiless.normal,
|
}
|
||||||
...wikipediaRedirects.wikiless.tor,
|
const protocolHost = utils.protocolHost(url)
|
||||||
...wikipediaRedirects.wikiless.i2p,
|
const wikipediaList = [
|
||||||
|
...wikipediaRedirects.wikiless.normal,
|
||||||
|
...wikipediaRedirects.wikiless.tor,
|
||||||
|
...wikipediaRedirects.wikiless.i2p,
|
||||||
|
|
||||||
...wikilessNormalCustomRedirects,
|
...wikilessNormalCustomRedirects,
|
||||||
...wikilessTorCustomRedirects,
|
...wikilessTorCustomRedirects,
|
||||||
...wikilessI2pCustomRedirects,
|
...wikilessI2pCustomRedirects,
|
||||||
...wikilessLokiCustomRedirects
|
...wikilessLokiCustomRedirects,
|
||||||
];
|
]
|
||||||
if (!wikipediaList.includes(protocolHost)) { resolve(); return; }
|
if (!wikipediaList.includes(protocolHost)) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = []
|
||||||
if (protocol == 'loki') instancesList = [...wikilessLokiCustomRedirects];
|
if (protocol == "loki") instancesList = [...wikilessLokiCustomRedirects]
|
||||||
else if (protocol == 'i2p') instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks];
|
else if (protocol == "i2p") instancesList = [...wikilessI2pCustomRedirects, ...wikilessI2pRedirectsChecks]
|
||||||
else if (protocol == 'tor') instancesList = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects];
|
else if (protocol == "tor") instancesList = [...wikilessTorRedirectsChecks, ...wikilessTorCustomRedirects]
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
if ((instancesList.length === 0 && protocolFallback) || protocol == "normal") {
|
||||||
instancesList = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects];
|
instancesList = [...wikilessNormalRedirectsChecks, ...wikilessNormalCustomRedirects]
|
||||||
}
|
}
|
||||||
|
|
||||||
let index = instancesList.indexOf(protocolHost);
|
let index = instancesList.indexOf(protocolHost)
|
||||||
if (index > -1) instancesList.splice(index, 1);
|
if (index > -1) instancesList.splice(index, 1)
|
||||||
if (instancesList.length === 0) { resolve(); return; }
|
if (instancesList.length === 0) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const randomInstance = utils.getRandomInstance(instancesList);
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
resolve(`${randomInstance}${url.pathname}${url.search}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaults() {
|
function initDefaults() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(async data => {
|
fetch("/instances/data.json")
|
||||||
let dataJson = JSON.parse(data);
|
.then(response => response.text())
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
.then(async data => {
|
||||||
redirects[frontends[i]] = dataJson[frontends[i]]
|
let dataJson = JSON.parse(data)
|
||||||
}
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
browser.storage.local.get('cloudflareBlackList', async r => {
|
redirects[frontends[i]] = dataJson[frontends[i]]
|
||||||
wikilessNormalRedirectsChecks = [...redirects.wikiless.normal];
|
}
|
||||||
for (const instance of r.cloudflareBlackList) {
|
browser.storage.local.get("cloudflareBlackList", async r => {
|
||||||
let i = wikilessNormalRedirectsChecks.indexOf(instance);
|
wikilessNormalRedirectsChecks = [...redirects.wikiless.normal]
|
||||||
if (i > -1) wikilessNormalRedirectsChecks.splice(i, 1);
|
for (const instance of r.cloudflareBlackList) {
|
||||||
}
|
let i = wikilessNormalRedirectsChecks.indexOf(instance)
|
||||||
browser.storage.local.set({
|
if (i > -1) wikilessNormalRedirectsChecks.splice(i, 1)
|
||||||
disableWikipedia: true,
|
}
|
||||||
wikipediaRedirects: redirects,
|
browser.storage.local.set(
|
||||||
|
{
|
||||||
wikilessNormalRedirectsChecks: wikilessNormalRedirectsChecks,
|
disableWikipedia: true,
|
||||||
wikilessNormalCustomRedirects: [],
|
wikipediaRedirects: redirects,
|
||||||
|
|
||||||
wikilessTorRedirectsChecks: [...redirects.wikiless.tor],
|
wikilessNormalRedirectsChecks: wikilessNormalRedirectsChecks,
|
||||||
wikilessTorCustomRedirects: [],
|
wikilessNormalCustomRedirects: [],
|
||||||
|
|
||||||
wikilessI2pRedirectsChecks: [...redirects.wikiless.i2p],
|
wikilessTorRedirectsChecks: [...redirects.wikiless.tor],
|
||||||
wikilessI2pCustomRedirects: [],
|
wikilessTorCustomRedirects: [],
|
||||||
|
|
||||||
wikilessLokiRedirectsChecks: [...redirects.wikiless.loki],
|
wikilessI2pRedirectsChecks: [...redirects.wikiless.i2p],
|
||||||
wikilessLokiCustomRedirects: []
|
wikilessI2pCustomRedirects: [],
|
||||||
|
|
||||||
}, () => resolve());
|
wikilessLokiRedirectsChecks: [...redirects.wikiless.loki],
|
||||||
})
|
wikilessLokiCustomRedirects: [],
|
||||||
})
|
},
|
||||||
})
|
() => resolve()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setRedirects,
|
setRedirects,
|
||||||
|
|
||||||
initWikilessCookies,
|
initWikilessCookies,
|
||||||
pasteWikilessCookies,
|
pasteWikilessCookies,
|
||||||
|
|
||||||
redirect,
|
redirect,
|
||||||
initDefaults,
|
initDefaults,
|
||||||
switchInstance,
|
switchInstance,
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
window.browser = window.browser || window.chrome;
|
window.browser = window.browser || window.chrome
|
||||||
|
|
||||||
browser.storage.local.set(
|
browser.storage.local.set({
|
||||||
{
|
pipedMaterial_PREFERENCES: localStorage.getItem("PREFERENCES"),
|
||||||
'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(
|
browser.storage.local.set({
|
||||||
{
|
piped_bufferGoal: localStorage.getItem("bufferGoal"),
|
||||||
'piped_bufferGoal': localStorage.getItem("bufferGoal"),
|
piped_comments: localStorage.getItem("comments"),
|
||||||
'piped_comments': localStorage.getItem("comments"),
|
piped_disableLBRY: localStorage.getItem("disableLBRY"),
|
||||||
'piped_disableLBRY': localStorage.getItem("disableLBRY"),
|
piped_enabledCodecs: localStorage.getItem("enabledCodecs"),
|
||||||
'piped_enabledCodecs': localStorage.getItem("enabledCodecs"),
|
piped_hl: localStorage.getItem("hl"),
|
||||||
'piped_hl': localStorage.getItem("hl"),
|
piped_homepage: localStorage.getItem("homepage"),
|
||||||
'piped_homepage': localStorage.getItem("homepage"),
|
piped_instance: localStorage.getItem("instance"),
|
||||||
'piped_instance': localStorage.getItem("instance"),
|
piped_listen: localStorage.getItem("listen"),
|
||||||
'piped_listen': localStorage.getItem("listen"),
|
piped_minimizeDescription: localStorage.getItem("minimizeDescription"),
|
||||||
'piped_minimizeDescription': localStorage.getItem("minimizeDescription"),
|
piped_playerAutoPlay: localStorage.getItem("playerAutoPlay"),
|
||||||
'piped_playerAutoPlay': localStorage.getItem("playerAutoPlay"),
|
piped_proxyLBRY: localStorage.getItem("proxyLBRY"),
|
||||||
'piped_proxyLBRY': localStorage.getItem("proxyLBRY"),
|
piped_quality: localStorage.getItem("quality"),
|
||||||
'piped_quality': localStorage.getItem("quality"),
|
piped_region: localStorage.getItem("region"),
|
||||||
'piped_region': localStorage.getItem("region"),
|
piped_selectedSkip: localStorage.getItem("selectedSkip"),
|
||||||
'piped_selectedSkip': localStorage.getItem("selectedSkip"),
|
piped_sponsorblock: localStorage.getItem("sponsorblock"),
|
||||||
'piped_sponsorblock': localStorage.getItem("sponsorblock"),
|
piped_theme: localStorage.getItem("theme"),
|
||||||
'piped_theme': localStorage.getItem("theme"),
|
piped_volume: localStorage.getItem("volume"),
|
||||||
'piped_volume': localStorage.getItem("volume"),
|
piped_watchHistory: localStorage.getItem("watchHistory"),
|
||||||
'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(
|
browser.storage.local.get("pipedMaterial_PREFERENCES", r => {
|
||||||
"pipedMaterial_PREFERENCES",
|
if (r.pipedMaterial_PREFERENCES !== undefined) localStorage.setItem("PREFERENCES", r.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(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"piped_bufferGoal",
|
"piped_bufferGoal",
|
||||||
"piped_comments",
|
"piped_comments",
|
||||||
"piped_disableLBRY",
|
"piped_disableLBRY",
|
||||||
"piped_enabledCodecs",
|
"piped_enabledCodecs",
|
||||||
"piped_homepage",
|
"piped_homepage",
|
||||||
"piped_instance",
|
"piped_instance",
|
||||||
"piped_listen",
|
"piped_listen",
|
||||||
"piped_minimizeDescription",
|
"piped_minimizeDescription",
|
||||||
"piped_playerAutoPlay",
|
"piped_playerAutoPlay",
|
||||||
"piped_proxyLBRY",
|
"piped_proxyLBRY",
|
||||||
"piped_quality",
|
"piped_quality",
|
||||||
"piped_region",
|
"piped_region",
|
||||||
"piped_selectedSkip",
|
"piped_selectedSkip",
|
||||||
"piped_sponsorblock",
|
"piped_sponsorblock",
|
||||||
"piped_theme",
|
"piped_theme",
|
||||||
"piped_volume",
|
"piped_volume",
|
||||||
"piped_watchHistory",
|
"piped_watchHistory",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
if (r.piped_bufferGoal !== undefined) localStorage.setItem("bufferGoal", r.piped_bufferGoal);
|
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_comments !== undefined) localStorage.setItem("comments", r.piped_comments)
|
||||||
if (r.piped_disableLBRY !== undefined) localStorage.setItem("disableLBRY", r.piped_disableLBRY);
|
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_hl !== undefined) localStorage.setItem("hl", r.piped_hl)
|
||||||
if (r.piped_enabledCodecs !== undefined) localStorage.setItem("enabledCodecs", r.piped_enabledCodecs);
|
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_homepage !== undefined) localStorage.setItem("homepage", r.piped_homepage)
|
||||||
if (r.piped_instance !== undefined) localStorage.setItem("instance", r.piped_instance);
|
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_listen !== undefined) localStorage.setItem("listen", r.piped_listen)
|
||||||
if (r.piped_minimizeDescription !== undefined) localStorage.setItem("minimizeDescription", r.piped_minimizeDescription);
|
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_playerAutoPlay !== undefined) localStorage.setItem("playerAutoPlay", r.piped_playerAutoPlay)
|
||||||
if (r.piped_proxyLBRY !== undefined) localStorage.setItem("proxyLBRY", r.piped_proxyLBRY);
|
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_quality !== undefined) localStorage.setItem("quality", r.piped_quality)
|
||||||
if (r.piped_region !== undefined) localStorage.setItem("region", r.piped_region);
|
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_selectedSkip !== undefined) localStorage.setItem("selectedSkip", r.piped_selectedSkip)
|
||||||
if (r.piped_sponsorblock !== undefined) localStorage.setItem("sponsorblock", r.piped_sponsorblock);
|
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_theme !== undefined) localStorage.setItem("theme", r.piped_theme)
|
||||||
if (r.piped_volume !== undefined) localStorage.setItem("volume", r.piped_volume);
|
if (r.piped_volume !== undefined) localStorage.setItem("volume", r.piped_volume)
|
||||||
if (r.piped_watchHistory !== undefined) localStorage.setItem("watchHistory", r.piped_watchHistory);
|
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 = [
|
const targets = [/^https?:\/{2}music\.youtube\.com(\/.*|$)/]
|
||||||
/^https?:\/{2}music\.youtube\.com(\/.*|$)/,
|
|
||||||
];
|
|
||||||
let redirects = {
|
|
||||||
"beatbump": {
|
|
||||||
"normal": [
|
|
||||||
"https://beatbump.ml"
|
|
||||||
],
|
|
||||||
"tor": [],
|
|
||||||
"i2p": [],
|
|
||||||
"loki": []
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
let
|
const frontends = new Array("beatbump", "hyperpipe")
|
||||||
disableYoutubeMusic,
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
protocol,
|
|
||||||
protocolFallback,
|
|
||||||
beatbumpNormalRedirectsChecks,
|
|
||||||
beatbumpNormalCustomRedirects,
|
|
||||||
beatbumpTorCustomRedirects,
|
|
||||||
beatbumpI2pCustomRedirects,
|
|
||||||
beatbumpLokiCustomRedirects;
|
|
||||||
|
|
||||||
function init() {
|
let redirects = {}
|
||||||
browser.storage.local.get(
|
|
||||||
[
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
"disableYoutubeMusic",
|
redirects[frontends[i]] = {}
|
||||||
"protocol",
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
"protocolFallback",
|
redirects[frontends[i]][protocols[x]] = []
|
||||||
"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;
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
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
|
Video
|
||||||
https://music.youtube.com/watch?v=_PkGiKBW-DA&list=RDAMVM_PkGiKBW-DA
|
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
|
https://beatbump.ml/search/test?filter=EgWKAQIIAWoKEAMQBBAKEAkQBQ%3D%3D
|
||||||
|
|
||||||
*/
|
*/
|
||||||
function redirect(url, disableOverride) {
|
function redirect(url, type, initiator, disableOverride) {
|
||||||
if (disableYoutubeMusic && !disableOverride) return;
|
if (disableYoutubeMusic && !disableOverride) return
|
||||||
if (!targets.some(rx => rx.test(url.href))) return;
|
if (!targets.some(rx => rx.test(url.href))) return
|
||||||
|
|
||||||
let instancesList = [];
|
let instancesList = getInstanceList()
|
||||||
if (protocol == 'loki') instancesList = [...beatbumpLokiCustomRedirects];
|
|
||||||
else if (protocol == 'i2p') instancesList = [...beatbumpI2pCustomRedirects];
|
if (instancesList.length === 0) return
|
||||||
else if (protocol == 'tor') instancesList = [...beatbumpTorCustomRedirects];
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
if ((instancesList.length === 0 && protocolFallback) || protocol == 'normal') {
|
return getUrl(randomInstance, url)
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function initDefaults() {
|
function switchInstance(url, disableOverride) {
|
||||||
return new Promise(resolve =>
|
return new Promise(async resolve => {
|
||||||
browser.storage.local.set({
|
await init()
|
||||||
disableYoutubeMusic: true,
|
if (disableYoutubeMusic && !disableOverride) {
|
||||||
youtubeMusicRedirects: redirects,
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const protocolHost = utils.protocolHost(url)
|
||||||
|
if (!all().includes(protocolHost)) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
beatbumpNormalRedirectsChecks: [...redirects.beatbump.normal],
|
let instancesList = getInstanceList()
|
||||||
beatbumpNormalCustomRedirects: [],
|
|
||||||
|
|
||||||
beatbumpTorRedirectsChecks: [...redirects.beatbump.tor],
|
const i = instancesList.indexOf(protocolHost)
|
||||||
beatbumpTorCustomRedirects: [],
|
if (i > -1) instancesList.splice(i, 1)
|
||||||
|
if (instancesList.length === 0) {
|
||||||
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
beatbumpI2pRedirectsChecks: [...redirects.beatbump.i2p],
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
beatbumpI2pCustomRedirects: [],
|
return getUrl(randomInstance, url)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
beatbumpLokiRedirectsChecks: [...redirects.beatbump.loki],
|
function initDefaults() {
|
||||||
beatbumpLokiCustomRedirects: []
|
return new Promise(resolve => {
|
||||||
}, () => 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 {
|
export default {
|
||||||
redirect,
|
setRedirects,
|
||||||
initDefaults,
|
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 = {}
|
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):
|
def filterLastSlash(urlList):
|
||||||
tmp = {}
|
tmp = {}
|
||||||
|
@ -65,16 +71,19 @@ def is_cloudflare(url):
|
||||||
instance_bin_masked = instance_bin[:mask]
|
instance_bin_masked = instance_bin[:mask]
|
||||||
|
|
||||||
if cloudflare_bin_masked == instance_bin_masked:
|
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 True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def is_authenticate(url):
|
def is_authenticate(url):
|
||||||
try:
|
try:
|
||||||
|
if re.match(authRegex, url):
|
||||||
|
print(url + ' requires ' + Fore.RED + 'authentication' + Style.RESET_ALL)
|
||||||
|
return True
|
||||||
r = requests.get(url, timeout=5)
|
r = requests.get(url, timeout=5)
|
||||||
if 'www-authenticate' in r.headers:
|
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
|
return True
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
@ -99,9 +108,26 @@ def invidious():
|
||||||
|
|
||||||
|
|
||||||
def piped():
|
def piped():
|
||||||
json_object = json.dumps(mightyList, ensure_ascii=False, indent=2)
|
r = requests.get(
|
||||||
with open('./src/instances/piped.json') as file:
|
'https://raw.githubusercontent.com/wiki/TeamPiped/Piped/Instances.md')
|
||||||
mightyList['piped'] = json.load(file)
|
|
||||||
|
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')
|
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Piped')
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,7 +136,7 @@ def pipedMaterial():
|
||||||
'https://raw.githubusercontent.com/mmjee/Piped-Material/master/README.md')
|
'https://raw.githubusercontent.com/mmjee/Piped-Material/master/README.md')
|
||||||
|
|
||||||
tmp = re.findall(
|
tmp = re.findall(
|
||||||
r"\| (https?:\/{2}(?:.+\.)+[a-zA-Z0-9]*) +\|", r.text)
|
r"\| (https?:\/{2}(?:\S+\.)+[a-zA-Z0-9]*) +\|", r.text)
|
||||||
pipedMaterialList = {}
|
pipedMaterialList = {}
|
||||||
pipedMaterialList['normal'] = []
|
pipedMaterialList['normal'] = []
|
||||||
pipedMaterialList['tor'] = []
|
pipedMaterialList['tor'] = []
|
||||||
|
@ -122,6 +148,13 @@ def pipedMaterial():
|
||||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + '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():
|
def proxitok():
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
'https://raw.githubusercontent.com/wiki/pablouser1/ProxiTok/Public-instances.md')
|
'https://raw.githubusercontent.com/wiki/pablouser1/ProxiTok/Public-instances.md')
|
||||||
|
@ -156,30 +189,29 @@ def send():
|
||||||
|
|
||||||
|
|
||||||
def nitter():
|
def nitter():
|
||||||
r = requests.get('https://github.com/zedeus/nitter/wiki/Instances')
|
r = requests.get('https://raw.githubusercontent.com/wiki/zedeus/nitter/Instances.md')
|
||||||
soup = BeautifulSoup(r.text, 'html.parser')
|
tmp = re.findall(
|
||||||
markdownBody = soup.find(class_='markdown-body')
|
r"(?:(?:\| \[(?:\S+\.)+[a-zA-Z]+\]\((https?:\/{2}(?:\S+\.)+[a-zA-Z]+)\/?\) (?:\((?:\S+ ?\S*)\) )? *\| (?:✅|🇩🇪) +\|(?:(?:\n)|(?: (?:❌)|(?: ✅)|(?: ❓)|(?: \[))))|(?:- \[(?:\S+\.)+(?:(?:i2p)|(?:loki))\]\((https?:\/{2}(?:\S+\.)(?:(?:i2p)|(?:loki)))\/?\)))", r.text)
|
||||||
tables = markdownBody.find_all('table')
|
|
||||||
tables.pop(3)
|
|
||||||
tables.pop(3)
|
|
||||||
nitterList = {}
|
nitterList = {}
|
||||||
nitterList['normal'] = []
|
nitterList['normal'] = []
|
||||||
nitterList['tor'] = []
|
nitterList['tor'] = []
|
||||||
nitterList['i2p'] = []
|
nitterList['i2p'] = []
|
||||||
nitterList['loki'] = []
|
nitterList['loki'] = []
|
||||||
for table in tables:
|
for item in tmp:
|
||||||
tbody = table.find('tbody')
|
for i in item:
|
||||||
trs = tbody.find_all('tr')
|
if i == '':
|
||||||
for tr in trs:
|
continue
|
||||||
td = tr.find('td')
|
|
||||||
a = td.find('a')
|
|
||||||
url = a.contents[0]
|
|
||||||
if url.endswith('.onion'):
|
|
||||||
url = 'http://' + url
|
|
||||||
nitterList['tor'].append(url)
|
|
||||||
else:
|
else:
|
||||||
url = 'https://' + url
|
item = i
|
||||||
nitterList['normal'].append(url)
|
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
|
mightyList['nitter'] = nitterList
|
||||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Nitter')
|
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)
|
r"\| \[.*\]\(([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)\)*\|*[A-Z]{0,}.*\|.*\|", r.text)
|
||||||
|
|
||||||
for item in tmp:
|
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)
|
libredditList['tor'].append(item)
|
||||||
else:
|
else:
|
||||||
libredditList['normal'].append(item)
|
libredditList['normal'].append(item)
|
||||||
|
@ -292,7 +324,7 @@ def quetre():
|
||||||
|
|
||||||
|
|
||||||
for item in tmp:
|
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)
|
_list['tor'].append(item)
|
||||||
else:
|
else:
|
||||||
_list['normal'].append(item)
|
_list['normal'].append(item)
|
||||||
|
@ -316,7 +348,7 @@ def libremdb():
|
||||||
for item in tmp:
|
for item in tmp:
|
||||||
if item.strip() == "":
|
if item.strip() == "":
|
||||||
continue
|
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)
|
_list['tor'].append(item)
|
||||||
else:
|
else:
|
||||||
_list['normal'].append(item)
|
_list['normal'].append(item)
|
||||||
|
@ -324,6 +356,19 @@ def libremdb():
|
||||||
mightyList['libremdb'] = _list
|
mightyList['libremdb'] = _list
|
||||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Libremdb')
|
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():
|
def simplytranslate():
|
||||||
r = requests.get('https://simple-web.org/instances/simplytranslate')
|
r = requests.get('https://simple-web.org/instances/simplytranslate')
|
||||||
|
@ -381,12 +426,12 @@ def searx_searxng():
|
||||||
searxngList['i2p'] = []
|
searxngList['i2p'] = []
|
||||||
searxngList['loki'] = []
|
searxngList['loki'] = []
|
||||||
for item in rJson['instances']:
|
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'):
|
if (rJson['instances'][item].get('generator') == 'searxng'):
|
||||||
searxngList['tor'].append(item[:-1])
|
searxngList['tor'].append(item[:-1])
|
||||||
else:
|
else:
|
||||||
searxList['tor'].append(item[:-1])
|
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'):
|
if (rJson['instances'][item].get('generator') == 'searxng'):
|
||||||
searxngList['i2p'].append(item[:-1])
|
searxngList['i2p'].append(item[:-1])
|
||||||
else:
|
else:
|
||||||
|
@ -412,9 +457,9 @@ def whoogle():
|
||||||
whoogleList['i2p'] = []
|
whoogleList['i2p'] = []
|
||||||
whoogleList['loki'] = []
|
whoogleList['loki'] = []
|
||||||
for item in tmpList:
|
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)
|
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)
|
whoogleList['i2p'].append(item)
|
||||||
else:
|
else:
|
||||||
whoogleList['normal'].append(item)
|
whoogleList['normal'].append(item)
|
||||||
|
@ -437,9 +482,9 @@ def librex():
|
||||||
for item in tmp:
|
for item in tmp:
|
||||||
if item.strip() == "":
|
if item.strip() == "":
|
||||||
continue
|
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)
|
_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)
|
_list['i2p'].append(item)
|
||||||
else:
|
else:
|
||||||
_list['normal'].append(item)
|
_list['normal'].append(item)
|
||||||
|
@ -481,16 +526,64 @@ def librarian():
|
||||||
url = item['url']
|
url = item['url']
|
||||||
if url.strip() == "":
|
if url.strip() == "":
|
||||||
continue
|
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)
|
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)
|
librarianList['i2p'].append(url)
|
||||||
|
elif re.search(lokiRegex, url):
|
||||||
|
librarianList['loki'].append(url)
|
||||||
else:
|
else:
|
||||||
librarianList['normal'].append(url)
|
librarianList['normal'].append(url)
|
||||||
mightyList['librarian'] = librarianList
|
mightyList['librarian'] = librarianList
|
||||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'Librarian')
|
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():
|
def peertube():
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
'https://instances.joinpeertube.org/api/v1/instances?start=0&count=1045&sort=-createdAt')
|
'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()
|
invidious()
|
||||||
piped()
|
piped()
|
||||||
pipedMaterial()
|
pipedMaterial()
|
||||||
|
cloudtube()
|
||||||
proxitok()
|
proxitok()
|
||||||
send()
|
send()
|
||||||
nitter()
|
nitter()
|
||||||
|
@ -532,6 +626,11 @@ whoogle()
|
||||||
librex()
|
librex()
|
||||||
rimgo()
|
rimgo()
|
||||||
librarian()
|
librarian()
|
||||||
|
neuters()
|
||||||
|
beatbump()
|
||||||
|
hyperpipe()
|
||||||
|
facil()
|
||||||
|
simpleertube()
|
||||||
mightyList = filterLastSlash(mightyList)
|
mightyList = filterLastSlash(mightyList)
|
||||||
|
|
||||||
cloudflare = []
|
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__",
|
"name": "__MSG_extensionName__",
|
||||||
"description": "__MSG_extensionDescription__",
|
"description": "__MSG_extensionDescription__",
|
||||||
"version": "2.2.1",
|
"version": "2.2.1",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"browser_specific_settings": {
|
"browser_specific_settings": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
"id": "7esoorv3@alefvanoon.anonaddy.me",
|
"id": "7esoorv3@alefvanoon.anonaddy.me",
|
||||||
"strict_min_version": "67.0"
|
"strict_min_version": "67.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"background": {
|
"background": {
|
||||||
"page": "pages/background/background.html",
|
"page": "pages/background/background.html",
|
||||||
"persistent": true
|
"persistent": true
|
||||||
},
|
},
|
||||||
"icons": {
|
"icons": {
|
||||||
"16": "assets/images/libredirect-16.png",
|
"16": "assets/images/libredirect-16.png",
|
||||||
"32": "assets/images/libredirect-32.png",
|
"32": "assets/images/libredirect-32.png",
|
||||||
"48": "assets/images/libredirect-48.png",
|
"48": "assets/images/libredirect-48.png",
|
||||||
"128": "assets/images/libredirect-128.png"
|
"128": "assets/images/libredirect-128.png"
|
||||||
},
|
},
|
||||||
"permissions": [
|
"permissions": ["webRequest", "webRequestBlocking", "storage", "unlimitedStorage", "cookies", "clipboardWrite", "contextMenus", "<all_urls>"],
|
||||||
"webRequest",
|
"browser_action": {
|
||||||
"webRequestBlocking",
|
"default_title": "__MSG_extensionName__",
|
||||||
"storage",
|
"browser_style": false,
|
||||||
"unlimitedStorage",
|
"default_popup": "pages/popup/popup.html",
|
||||||
"cookies",
|
"default_icon": {
|
||||||
"clipboardWrite",
|
"16": "assets/images/libredirect-16.png",
|
||||||
"contextMenus",
|
"32": "assets/images/libredirect-32.png",
|
||||||
"<all_urls>"
|
"48": "assets/images/libredirect-48.png",
|
||||||
],
|
"128": "assets/images/libredirect-128.png"
|
||||||
"browser_action": {
|
}
|
||||||
"default_title": "__MSG_extensionName__",
|
},
|
||||||
"browser_style": false,
|
"options_ui": {
|
||||||
"default_popup": "pages/popup/popup.html",
|
"page": "pages/options/index.html",
|
||||||
"default_icon": {
|
"browser_style": false,
|
||||||
"16": "assets/images/libredirect-16.png",
|
"open_in_tab": true
|
||||||
"32": "assets/images/libredirect-32.png",
|
},
|
||||||
"48": "assets/images/libredirect-48.png",
|
"chrome_settings_overrides": {
|
||||||
"128": "assets/images/libredirect-128.png"
|
"search_provider": {
|
||||||
}
|
"name": "__MSG_extensionName__",
|
||||||
},
|
"keyword": "libredirect",
|
||||||
"options_ui": {
|
"favicon_url": "https://raw.githubusercontent.com/libredirect/libredirect/master/src/assets/images/libredirect-16.png",
|
||||||
"page": "pages/options/index.html",
|
"search_url": "https://search.libredirect.invalid/?q={searchTerms}",
|
||||||
"browser_style": false,
|
"encoding": "UTF-8",
|
||||||
"open_in_tab": true
|
"is_default": false
|
||||||
},
|
}
|
||||||
"chrome_settings_overrides": {
|
},
|
||||||
"search_provider": {
|
"commands": {
|
||||||
"name": "__MSG_extensionName__",
|
"switchInstance": {
|
||||||
"keyword": "libredirect",
|
"suggested_key": {
|
||||||
"favicon_url": "https://raw.githubusercontent.com/libredirect/libredirect/master/src/assets/images/libredirect-16.png",
|
"default": "Alt+Shift+L"
|
||||||
"search_url": "https://search.libredirect.invalid/?q={searchTerms}",
|
},
|
||||||
"encoding": "UTF-8",
|
"description": "__MSG_switchInstance__"
|
||||||
"is_default": false
|
},
|
||||||
}
|
"copyRaw": {
|
||||||
},
|
"suggested_key": {
|
||||||
"commands": {
|
"default": "Alt+Shift+C"
|
||||||
"switchInstance": {
|
},
|
||||||
"suggested_key": {
|
"description": "Copies the original link. Ex: Copies the original twitter link while in the nitter website"
|
||||||
"default": "Alt+Shift+L"
|
},
|
||||||
},
|
"unify": {
|
||||||
"description": "__MSG_switchInstance__"
|
"suggested_key": {
|
||||||
},
|
"default": "Alt+Shift+U"
|
||||||
"copyRaw": {
|
},
|
||||||
"suggested_key": {
|
"description": "Copies the preferences (cookies, localStorage) from the current opened instance and copy them to all the other selected instances"
|
||||||
"default": "Alt+Shift+C"
|
}
|
||||||
},
|
},
|
||||||
"description": "Copies the original link. Ex: Copies the original twitter link while in the nitter website"
|
"default_locale": "en",
|
||||||
},
|
"update_url": "https://raw.githubusercontent.com/libredirect/libredirect/master/src/updates/updates.xml",
|
||||||
"unify": {
|
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAroWDSoSRZ1scj+eJRrvnhJbrqXTKnhQuxs6+AJg16sqr0bsMdFV+MSY4i4xnK+K5WOYkBliWXgUyk/wzicoAjOnSJddrL/Md4FuWHI2NVIkrlsLOrYkygi5OLqGPajRH/w8Cdmg7KzEpXe/OnYV0/qS8li8huEdTzdeLdhfbiVl1j3DOr4OJALQ7mPeeNFHFo/oVQ+OkSezWLezA5jUGfhtzPYV6u1TXzX7lCi8E/BbDbwkvvXOMcjXCv08kjdLOY2djCA2a6zr0xAb3q8DlexAMZ8vMof7AQRFtBKhLc9n9VFoipMMdBOVQQj/eIcRILBrmkcZNnJxFKiHNJ+NcZQIDAQAB"
|
||||||
"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>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
<head>
|
<meta charset="utf-8" />
|
||||||
<meta charset="utf-8" />
|
<script type="module" src="background.js"></script>
|
||||||
<script type="module" src="background.js"></script>
|
</head>
|
||||||
</head>
|
</html>
|
||||||
|
|
||||||
</html>
|
|
||||||
|
|
|
@ -1,263 +1,252 @@
|
||||||
"use strict";
|
"use strict"
|
||||||
|
|
||||||
import generalHelper from "../../assets/javascripts/general.js";
|
import generalHelper from "../../assets/javascripts/general.js"
|
||||||
import utils from "../../assets/javascripts/utils.js";
|
import utils from "../../assets/javascripts/utils.js"
|
||||||
|
|
||||||
import youtubeHelper from "../../assets/javascripts/youtube/youtube.js";
|
import youtubeHelper from "../../assets/javascripts/youtube/youtube.js"
|
||||||
import youtubeMusicHelper from "../../assets/javascripts/youtubeMusic.js";
|
import youtubeMusicHelper from "../../assets/javascripts/youtubeMusic.js"
|
||||||
import twitterHelper from "../../assets/javascripts/twitter.js";
|
import twitterHelper from "../../assets/javascripts/twitter.js"
|
||||||
import instagramHelper from "../../assets/javascripts/instagram.js";
|
import instagramHelper from "../../assets/javascripts/instagram.js"
|
||||||
import redditHelper from "../../assets/javascripts/reddit.js";
|
import redditHelper from "../../assets/javascripts/reddit.js"
|
||||||
import searchHelper from "../../assets/javascripts/search.js";
|
import searchHelper from "../../assets/javascripts/search.js"
|
||||||
import translateHelper from "../../assets/javascripts/translate/translate.js";
|
import translateHelper from "../../assets/javascripts/translate/translate.js"
|
||||||
import mapsHelper from "../../assets/javascripts/maps.js";
|
import mapsHelper from "../../assets/javascripts/maps.js"
|
||||||
import wikipediaHelper from "../../assets/javascripts/wikipedia.js";
|
import wikipediaHelper from "../../assets/javascripts/wikipedia.js"
|
||||||
import mediumHelper from "../../assets/javascripts/medium.js";
|
import mediumHelper from "../../assets/javascripts/medium.js"
|
||||||
import quoraHelper from "../../assets/javascripts/quora.js";
|
import quoraHelper from "../../assets/javascripts/quora.js"
|
||||||
import libremdbHelper from "../../assets/javascripts/imdb.js";
|
import libremdbHelper from "../../assets/javascripts/imdb.js"
|
||||||
import reutersHelper from "../../assets/javascripts/reuters.js";
|
import reutersHelper from "../../assets/javascripts/reuters.js"
|
||||||
import imgurHelper from "../../assets/javascripts/imgur.js";
|
import imgurHelper from "../../assets/javascripts/imgur.js"
|
||||||
import tiktokHelper from "../../assets/javascripts/tiktok.js";
|
import tiktokHelper from "../../assets/javascripts/tiktok.js"
|
||||||
import sendTargetsHelper from "../../assets/javascripts/sendTargets.js";
|
import sendTargetsHelper from "../../assets/javascripts/sendTargets.js"
|
||||||
import peertubeHelper from "../../assets/javascripts/peertube.js";
|
import peertubeHelper from "../../assets/javascripts/peertube.js"
|
||||||
import lbryHelper from "../../assets/javascripts/lbry.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(
|
// if (details.reason == 'install' || (details.reason == "update" && details.previousVersion != browser.runtime.getManifest().version)) {
|
||||||
details => {
|
// if (details.reason == "update")
|
||||||
function initDefaults() {
|
// browser.storage.local.get(null, r => {
|
||||||
fetch('/instances/blacklist.json').then(response => response.text()).then(async data => {
|
// if (r.theme) {
|
||||||
browser.storage.local.clear(
|
// const old = encodeURIComponent(JSON.stringify(r))
|
||||||
() => {
|
// browser.tabs.create({ url: browser.runtime.getURL(`/pages/background/reset_warning.html?data=${old}`) });
|
||||||
browser.storage.local.set({ cloudflareBlackList: JSON.parse(data).cloudflare },
|
// }
|
||||||
() => {
|
// initDefaults();
|
||||||
browser.storage.local.set({ authenticateBlackList: JSON.parse(data).authenticate },
|
// })
|
||||||
() => {
|
// else initDefaults();
|
||||||
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)) {
|
youtubeHelper.pasteInvidiousCookies()
|
||||||
// if (details.reason == "update")
|
translateHelper.pasteSimplyTranslateCookies()
|
||||||
// browser.storage.local.get(null, r => {
|
twitterHelper.pasteNitterCookies()
|
||||||
// if (r.theme) {
|
wikipediaHelper.pasteWikilessCookies()
|
||||||
// const old = encodeURIComponent(JSON.stringify(r))
|
searchHelper.pasteSearxCookies()
|
||||||
// browser.tabs.create({ url: browser.runtime.getURL(`/pages/background/reset_warning.html?data=${old}`) });
|
searchHelper.pasteSearxngCookies()
|
||||||
// }
|
searchHelper.pasteLibrexCookies()
|
||||||
// initDefaults();
|
redditHelper.pasteLibredditCookies()
|
||||||
// })
|
redditHelper.pasteTedditCookies()
|
||||||
// else initDefaults();
|
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();
|
browser.tabs.onRemoved.addListener(tabId => {
|
||||||
translateHelper.pasteSimplyTranslateCookies();
|
const i = BYPASSTABs.indexOf(tabId)
|
||||||
twitterHelper.pasteNitterCookies();
|
if (i > -1) {
|
||||||
wikipediaHelper.pasteWikilessCookies();
|
BYPASSTABs.splice(i, 1)
|
||||||
searchHelper.pasteSearxCookies();
|
console.log("Removed BYPASSTABs", tabId)
|
||||||
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.webRequest.onHeadersReceived.addListener(
|
browser.webRequest.onHeadersReceived.addListener(
|
||||||
e => {
|
e => {
|
||||||
let response = youtubeHelper.removeXFrameOptions(e);
|
let response = youtubeHelper.removeXFrameOptions(e)
|
||||||
if (!response) response = twitterHelper.removeXFrameOptions(e);
|
if (!response) response = twitterHelper.removeXFrameOptions(e)
|
||||||
return response;
|
return response
|
||||||
},
|
},
|
||||||
{ urls: ["<all_urls>"] },
|
{ urls: ["<all_urls>"] },
|
||||||
["blocking", "responseHeaders"]
|
["blocking", "responseHeaders"]
|
||||||
);
|
)
|
||||||
|
|
||||||
async function redirectOfflineInstance(url, tabId) {
|
async function redirectOfflineInstance(url, tabId) {
|
||||||
let newUrl = await youtubeHelper.switchInstance(url);
|
let newUrl = await youtubeHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await twitterHelper.switchInstance(url);
|
if (!newUrl) newUrl = await twitterHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await instagramHelper.switchInstance(url);
|
if (!newUrl) newUrl = await instagramHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await redditHelper.switchInstance(url);
|
if (!newUrl) newUrl = await redditHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await searchHelper.switchInstance(url);
|
if (!newUrl) newUrl = await searchHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await translateHelper.switchInstance(url);
|
if (!newUrl) newUrl = await translateHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await mediumHelper.switchInstance(url);
|
if (!newUrl) newUrl = await mediumHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await quoraHelper.switchInstance(url);
|
if (!newUrl) newUrl = await quoraHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await libremdbHelper.switchInstance(url);
|
if (!newUrl) newUrl = await libremdbHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await tiktokHelper.switchInstance(url);
|
if (!newUrl) newUrl = await tiktokHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await imgurHelper.switchInstance(url);
|
if (!newUrl) newUrl = await imgurHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await wikipediaHelper.switchInstance(url);
|
if (!newUrl) newUrl = await wikipediaHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await peertubeHelper.switchInstance(url);
|
if (!newUrl) newUrl = await peertubeHelper.switchInstance(url, true)
|
||||||
if (!newUrl) newUrl = await lbryHelper.switchInstance(url);
|
if (!newUrl) newUrl = await lbryHelper.switchInstance(url, true)
|
||||||
|
if (!newUrl) newUrl = await youtubeMusicHelper.switchInstance(url, true)
|
||||||
|
|
||||||
if (newUrl) {
|
if (newUrl) {
|
||||||
if (counter >= 5) {
|
if (counter >= 5) {
|
||||||
browser.tabs.update(tabId, { url: `/pages/errors/instance_offline.html?url=${encodeURIComponent(newUrl)}` });
|
browser.tabs.update(tabId, {
|
||||||
counter = 0;
|
url: `/pages/errors/instance_offline.html?url=${encodeURIComponent(newUrl)}`,
|
||||||
} else {
|
})
|
||||||
browser.tabs.update(tabId, { url: newUrl });
|
counter = 0
|
||||||
counter++;
|
} else {
|
||||||
}
|
browser.tabs.update(tabId, { url: newUrl })
|
||||||
}
|
counter++
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let counter = 0;
|
let counter = 0
|
||||||
|
|
||||||
function isAutoRedirect() {
|
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(
|
browser.webRequest.onResponseStarted.addListener(
|
||||||
async details => {
|
async details => {
|
||||||
if (!await isAutoRedirect()) return null;
|
if (!(await isAutoRedirect())) return null
|
||||||
if (details.type == 'main_frame' && details.statusCode >= 500) redirectOfflineInstance(new URL(details.url), details.tabId);
|
if (details.type == "main_frame" && details.statusCode >= 500) redirectOfflineInstance(new URL(details.url), details.tabId)
|
||||||
},
|
},
|
||||||
{ urls: ["<all_urls>"] }
|
{ urls: ["<all_urls>"] }
|
||||||
)
|
)
|
||||||
|
|
||||||
browser.webRequest.onErrorOccurred.addListener(
|
browser.webRequest.onErrorOccurred.addListener(
|
||||||
async details => {
|
async details => {
|
||||||
if (!await isAutoRedirect()) return;
|
if (!(await isAutoRedirect())) return
|
||||||
if (details.type == 'main_frame') redirectOfflineInstance(new URL(details.url), details.tabId);
|
if (details.type == "main_frame") redirectOfflineInstance(new URL(details.url), details.tabId)
|
||||||
},
|
},
|
||||||
{ urls: ["<all_urls>"] }
|
{ urls: ["<all_urls>"] }
|
||||||
)
|
)
|
||||||
|
|
||||||
browser.commands.onCommand.addListener(
|
browser.commands.onCommand.addListener(command => {
|
||||||
command => {
|
if (command === "switchInstance") utils.switchInstance()
|
||||||
if (command === 'switchInstance') utils.switchInstance();
|
else if (command == "copyRaw") utils.copyRaw()
|
||||||
else if (command == 'copyRaw') utils.copyRaw();
|
else if (command == "unify") utils.unify()
|
||||||
else if (command == 'unify') utils.unify();
|
})
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
browser.contextMenus.create({
|
browser.contextMenus.create({
|
||||||
id: "settings",
|
id: "settings",
|
||||||
title: browser.i18n.getMessage("Settings"),
|
title: browser.i18n.getMessage("Settings"),
|
||||||
contexts: ["browser_action"]
|
contexts: ["browser_action"],
|
||||||
});
|
})
|
||||||
|
|
||||||
browser.contextMenus.create({
|
browser.contextMenus.create({
|
||||||
id: "switchInstance",
|
id: "switchInstance",
|
||||||
title: browser.i18n.getMessage("switchInstance"),
|
title: browser.i18n.getMessage("switchInstance"),
|
||||||
contexts: ["browser_action"]
|
contexts: ["browser_action"],
|
||||||
});
|
})
|
||||||
|
|
||||||
browser.contextMenus.create({
|
browser.contextMenus.create({
|
||||||
id: "copyRaw",
|
id: "copyRaw",
|
||||||
title: browser.i18n.getMessage("copyRaw"),
|
title: browser.i18n.getMessage("copyRaw"),
|
||||||
contexts: ["browser_action"]
|
contexts: ["browser_action"],
|
||||||
});
|
})
|
||||||
|
|
||||||
browser.contextMenus.create({
|
browser.contextMenus.create({
|
||||||
id: "unify",
|
id: "unify",
|
||||||
title: browser.i18n.getMessage("unifySettings"),
|
title: browser.i18n.getMessage("unifySettings"),
|
||||||
contexts: ["browser_action"]
|
contexts: ["browser_action"],
|
||||||
});
|
})
|
||||||
|
|
||||||
|
browser.contextMenus.onClicked.addListener(info => {
|
||||||
browser.contextMenus.onClicked.addListener(
|
if (info.menuItemId == "switchInstance") utils.switchInstance()
|
||||||
(info) => {
|
else if (info.menuItemId == "settings") browser.runtime.openOptionsPage()
|
||||||
if (info.menuItemId == 'switchInstance') utils.switchInstance();
|
else if (info.menuItemId == "copyRaw") utils.copyRaw()
|
||||||
else if (info.menuItemId == 'settings') browser.runtime.openOptionsPage()
|
else if (info.menuItemId == "unify") utils.unify()
|
||||||
else if (info.menuItemId == 'copyRaw') utils.copyRaw();
|
})
|
||||||
else if (info.menuItemId == 'unify') utils.unify();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||||
if (message.function === 'unify') utils.unify(false).then(r => sendResponse({ response: r }))
|
if (message.function === "unify") utils.unify(false).then(r => sendResponse({ response: r }))
|
||||||
return true;
|
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>
|
<!DOCTYPE html>
|
||||||
<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>
|
div {
|
||||||
<meta charset="utf-8" />
|
text-align: center;
|
||||||
<meta charset="UTF-8">
|
}
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
</style>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
</head>
|
||||||
<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 {
|
<body>
|
||||||
text-align: center;
|
<div>
|
||||||
}
|
<p>Initializing Cookies...</p>
|
||||||
</style>
|
</div>
|
||||||
</head>
|
<script type="module" src="incognito.js"></script>
|
||||||
|
</body>
|
||||||
<body>
|
</html>
|
||||||
<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 youtubeHelper from "../../assets/javascripts/youtube/youtube.js"
|
||||||
import twitterHelper from "../../assets/javascripts/twitter.js";
|
import twitterHelper from "../../assets/javascripts/twitter.js"
|
||||||
import redditHelper from "../../assets/javascripts/reddit.js";
|
import redditHelper from "../../assets/javascripts/reddit.js"
|
||||||
import searchHelper from "../../assets/javascripts/search.js";
|
import searchHelper from "../../assets/javascripts/search.js"
|
||||||
import translateHelper from "../../assets/javascripts/translate/translate.js";
|
import translateHelper from "../../assets/javascripts/translate/translate.js"
|
||||||
import wikipediaHelper from "../../assets/javascripts/wikipedia.js";
|
import wikipediaHelper from "../../assets/javascripts/wikipedia.js"
|
||||||
import tiktokHelper from "../../assets/javascripts/tiktok.js";
|
import tiktokHelper from "../../assets/javascripts/tiktok.js"
|
||||||
|
|
||||||
window.browser = window.browser || window.chrome;
|
window.browser = window.browser || window.chrome
|
||||||
|
|
||||||
await youtubeHelper.pasteInvidiousCookies();
|
await youtubeHelper.pasteInvidiousCookies()
|
||||||
await translateHelper.pasteSimplyTranslateCookies();
|
await translateHelper.pasteSimplyTranslateCookies()
|
||||||
await twitterHelper.pasteNitterCookies();
|
await twitterHelper.pasteNitterCookies()
|
||||||
await wikipediaHelper.pasteWikilessCookies();
|
await wikipediaHelper.pasteWikilessCookies()
|
||||||
await searchHelper.pasteSearxCookies();
|
await searchHelper.pasteSearxCookies()
|
||||||
await searchHelper.pasteSearxngCookies();
|
await searchHelper.pasteSearxngCookies()
|
||||||
await searchHelper.pasteLibrexCookies();
|
await searchHelper.pasteLibrexCookies()
|
||||||
await redditHelper.pasteLibredditCookies();
|
await redditHelper.pasteLibredditCookies()
|
||||||
await redditHelper.pasteTedditCookies();
|
await redditHelper.pasteTedditCookies()
|
||||||
await tiktokHelper.pasteProxiTokCookies();
|
await tiktokHelper.pasteProxiTokCookies()
|
||||||
|
|
||||||
window.close()
|
window.close()
|
||||||
|
|
|
@ -1,66 +1,59 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<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>
|
div {
|
||||||
<meta charset="UTF-8">
|
width: 80%;
|
||||||
<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 {
|
div.logo {
|
||||||
width: 80%;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.logo {
|
img {
|
||||||
display: flex;
|
width: 90px;
|
||||||
}
|
height: auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
img {
|
<body>
|
||||||
width: 90px;
|
<div>
|
||||||
height: auto;
|
<div class="logo">
|
||||||
}
|
<img src="/assets/images/libredirect.svg" alt="LibRedirect icon" />
|
||||||
</style>
|
<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>
|
<a id="export-settings" class="button button-inline">
|
||||||
<div>
|
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
||||||
<div class="logo">
|
<path
|
||||||
<img src="/assets/images/libredirect.svg" alt="LibRedirect icon">
|
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"
|
||||||
<h1>LibRedirect</h1>
|
></path>
|
||||||
</div>
|
</svg>
|
||||||
|
|
||||||
<p data-localise="__MSG_instanceOffline__">All settings have been reset as they're incompatible with the
|
<x data-localise="__MSG_exportSettings__">Export Settings</x>
|
||||||
previous version.</p>
|
</a>
|
||||||
<p>Sorry for the inconvenience, but we're going in a fast development process and can't
|
</div>
|
||||||
support nor convert older settings. It will reach a stable plateau though.</p>
|
</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(
|
const resultString = JSON.stringify(JSON.parse(params.get("data")), null, " ")
|
||||||
JSON.parse(params.get('data')),
|
|
||||||
null,
|
|
||||||
' '
|
|
||||||
);
|
|
||||||
|
|
||||||
let exportSettingsElement = document.getElementById("export-settings");
|
let exportSettingsElement = document.getElementById("export-settings")
|
||||||
exportSettingsElement.href = 'data:application/json;base64,' + btoa(resultString);
|
exportSettingsElement.href = "data:application/json;base64," + btoa(resultString)
|
||||||
exportSettingsElement.download = 'libredirect-settings.json';
|
exportSettingsElement.download = "libredirect-settings.json"
|
||||||
|
|
|
@ -1,41 +1,38 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<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>
|
div {
|
||||||
<meta charset="UTF-8">
|
text-align: center;
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
}
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
</style>
|
||||||
<title data-localise="__MSG_instanceIsOff__">Instance is offline</title>
|
</head>
|
||||||
<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 {
|
<body>
|
||||||
text-align: center;
|
<div>
|
||||||
}
|
<p id="message" data-localise="__MSG_instanceOffline__">
|
||||||
</style>
|
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>
|
<script src="instance_offline.js" type="module"></script>
|
||||||
|
</body>
|
||||||
<body>
|
</html>
|
||||||
<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>
|
|
||||||
|
|
|
@ -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), {
|
||||||
const params = new Proxy(
|
get: (searchParams, prop) => searchParams.get(prop),
|
||||||
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');
|
|
||||||
})
|
})
|
||||||
|
|
||||||
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="invidious">Invidious</option>
|
||||||
<option value="piped">Piped</option>
|
<option value="piped">Piped</option>
|
||||||
<option value="pipedMaterial">Piped-Material</option>
|
<option value="pipedMaterial">Piped-Material</option>
|
||||||
|
<option value="cloudtube">CloudTube</option>
|
||||||
<option value="freetube">FreeTube</option>
|
<option value="freetube">FreeTube</option>
|
||||||
<option value="yatte">Yattee</option>
|
<option value="yatte">Yattee</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -296,6 +297,7 @@
|
||||||
<option value="invidious">Invidious</option>
|
<option value="invidious">Invidious</option>
|
||||||
<option value="piped">Piped</option>
|
<option value="piped">Piped</option>
|
||||||
<option value="pipedMaterial">Piped-Material</option>
|
<option value="pipedMaterial">Piped-Material</option>
|
||||||
|
<option value="cloudtube">CloudTube</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -595,6 +597,102 @@
|
||||||
<div class="checklist custom-checklist"></div>
|
<div class="checklist custom-checklist"></div>
|
||||||
</div>
|
</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>
|
<script type="module" src="./widgets/youtube.js"></script>
|
||||||
</section>
|
</section>
|
||||||
<section class="option-block" id="youtubeMusic_page">
|
<section class="option-block" id="youtubeMusic_page">
|
||||||
|
@ -606,6 +704,13 @@
|
||||||
<h4 data-localise="__MSG_enable__">Enable</h4>
|
<h4 data-localise="__MSG_enable__">Enable</h4>
|
||||||
<input id="youtubeMusic-enable" type="checkbox">
|
<input id="youtubeMusic-enable" type="checkbox">
|
||||||
</div>
|
</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">
|
<div id="beatbump">
|
||||||
<hr>
|
<hr>
|
||||||
<div class="normal">
|
<div class="normal">
|
||||||
|
@ -619,7 +724,7 @@
|
||||||
</div>
|
</div>
|
||||||
<form class="custom-instance-form">
|
<form class="custom-instance-form">
|
||||||
<div class="some-block option-block">
|
<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">
|
<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">
|
<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>
|
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path>
|
||||||
|
@ -702,6 +807,102 @@
|
||||||
<div class="checklist custom-checklist"></div>
|
<div class="checklist custom-checklist"></div>
|
||||||
</div>
|
</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>
|
<script type="module" src="./widgets/youtubeMusic.js"></script>
|
||||||
</section>
|
</section>
|
||||||
<section class="option-block" id="twitter_page">
|
<section class="option-block" id="twitter_page">
|
||||||
|
|
|
@ -1,24 +1,23 @@
|
||||||
for (const a of document.getElementById('links').getElementsByTagName('a')) {
|
for (const a of document.getElementById("links").getElementsByTagName("a")) {
|
||||||
a.addEventListener('click', e => {
|
a.addEventListener("click", e => {
|
||||||
const path = a.getAttribute('href').replace('#', '');
|
const path = a.getAttribute("href").replace("#", "")
|
||||||
loadPage(path);
|
loadPage(path)
|
||||||
e.preventDefault();
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadPage(path) {
|
function loadPage(path) {
|
||||||
for (const section of document.getElementById('pages').getElementsByTagName('section'))
|
for (const section of document.getElementById("pages").getElementsByTagName("section")) section.style.display = "none"
|
||||||
section.style.display = 'none';
|
document.getElementById(`${path}_page`).style.display = "block"
|
||||||
document.getElementById(`${path}_page`).style.display = 'block';
|
|
||||||
|
|
||||||
for (const a of document.getElementById('links').getElementsByTagName('a'))
|
for (const a of document.getElementById("links").getElementsByTagName("a"))
|
||||||
if (a.getAttribute('href') == `#${path}`) a.classList.add('selected')
|
if (a.getAttribute("href") == `#${path}`) a.classList.add("selected")
|
||||||
else a.classList.remove('selected')
|
else a.classList.remove("selected")
|
||||||
|
|
||||||
let stateObj = { id: "100" };
|
let stateObj = { id: "100" }
|
||||||
window.history.pushState(stateObj, "Page 2", `/pages/options/index.html#${path}`);
|
window.history.pushState(stateObj, "Page 2", `/pages/options/index.html#${path}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const r = window.location.href.match(/#(.*)/)
|
const r = window.location.href.match(/#(.*)/)
|
||||||
if (r) loadPage(r[1]);
|
if (r) loadPage(r[1])
|
||||||
else loadPage('general');
|
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() {
|
function changeTheme() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get("theme", r => {
|
||||||
"theme",
|
switch (r.theme) {
|
||||||
r => {
|
case "dark":
|
||||||
switch (r.theme) {
|
document.body.classList.add("dark-theme")
|
||||||
case "dark":
|
document.body.classList.remove("light-theme")
|
||||||
document.body.classList.add("dark-theme");
|
break
|
||||||
document.body.classList.remove("light-theme");
|
case "light":
|
||||||
break;
|
document.body.classList.add("light-theme")
|
||||||
case "light":
|
document.body.classList.remove("dark-theme")
|
||||||
document.body.classList.add("light-theme");
|
break
|
||||||
document.body.classList.remove("dark-theme");
|
default:
|
||||||
break;
|
if (matchMedia("(prefers-color-scheme: light)").matches) {
|
||||||
default:
|
document.body.classList.add("light-theme")
|
||||||
if (matchMedia("(prefers-color-scheme: light)").matches) {
|
document.body.classList.remove("dark-theme")
|
||||||
document.body.classList.add("light-theme");
|
} else {
|
||||||
document.body.classList.remove("dark-theme");
|
document.body.classList.add("dark-theme")
|
||||||
} else {
|
document.body.classList.remove("light-theme")
|
||||||
document.body.classList.add("dark-theme");
|
}
|
||||||
document.body.classList.remove("light-theme");
|
}
|
||||||
}
|
resolve()
|
||||||
}
|
})
|
||||||
resolve();
|
})
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
changeTheme();
|
changeTheme()
|
||||||
if (["ar", "iw", "ku", "fa", "ur"].includes(browser.i18n.getUILanguage())) document.getElementsByTagName("body")[0].classList.add("rtl");
|
if (["ar", "iw", "ku", "fa", "ur"].includes(browser.i18n.getUILanguage())) document.getElementsByTagName("body")[0].classList.add("rtl")
|
||||||
localise.localisePage();
|
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";
|
"use strict"
|
||||||
window.browser = window.browser || window.chrome;
|
window.browser = window.browser || window.chrome
|
||||||
|
|
||||||
import utils from "../../../assets/javascripts/utils.js";
|
import utils from "../../../assets/javascripts/utils.js"
|
||||||
import generalHelper from "../../../assets/javascripts/general.js";
|
import generalHelper from "../../../assets/javascripts/general.js"
|
||||||
|
|
||||||
import youtubeHelper from "../../../assets/javascripts/youtube/youtube.js";
|
import youtubeHelper from "../../../assets/javascripts/youtube/youtube.js"
|
||||||
import youtubeMusicHelper from "../../../assets/javascripts/youtubeMusic.js";
|
import youtubeMusicHelper from "../../../assets/javascripts/youtubeMusic.js"
|
||||||
import twitterHelper from "../../../assets/javascripts/twitter.js";
|
import twitterHelper from "../../../assets/javascripts/twitter.js"
|
||||||
import instagramHelper from "../../../assets/javascripts/instagram.js";
|
import instagramHelper from "../../../assets/javascripts/instagram.js"
|
||||||
import redditHelper from "../../../assets/javascripts/reddit.js";
|
import redditHelper from "../../../assets/javascripts/reddit.js"
|
||||||
import searchHelper from "../../../assets/javascripts/search.js";
|
import searchHelper from "../../../assets/javascripts/search.js"
|
||||||
import translateHelper from "../../../assets/javascripts/translate/translate.js";
|
import translateHelper from "../../../assets/javascripts/translate/translate.js"
|
||||||
import mapsHelper from "../../../assets/javascripts/maps.js";
|
import mapsHelper from "../../../assets/javascripts/maps.js"
|
||||||
import wikipediaHelper from "../../../assets/javascripts/wikipedia.js";
|
import wikipediaHelper from "../../../assets/javascripts/wikipedia.js"
|
||||||
import mediumHelper from "../../../assets/javascripts/medium.js";
|
import mediumHelper from "../../../assets/javascripts/medium.js"
|
||||||
import quoraHelper from "../../../assets/javascripts/quora.js";
|
import quoraHelper from "../../../assets/javascripts/quora.js"
|
||||||
import libremdbHelper from "../../../assets/javascripts/imdb.js";
|
import libremdbHelper from "../../../assets/javascripts/imdb.js"
|
||||||
import reutersHelper from "../../../assets/javascripts/reuters.js";
|
import reutersHelper from "../../../assets/javascripts/reuters.js"
|
||||||
import imgurHelper from "../../../assets/javascripts/imgur.js";
|
import imgurHelper from "../../../assets/javascripts/imgur.js"
|
||||||
import tiktokHelper from "../../../assets/javascripts/tiktok.js";
|
import tiktokHelper from "../../../assets/javascripts/tiktok.js"
|
||||||
import sendTargetsHelper from "../../../assets/javascripts/sendTargets.js";
|
import sendTargetsHelper from "../../../assets/javascripts/sendTargets.js"
|
||||||
import peertubeHelper from "../../../assets/javascripts/peertube.js";
|
import peertubeHelper from "../../../assets/javascripts/peertube.js"
|
||||||
import lbryHelper from "../../../assets/javascripts/lbry.js";
|
import lbryHelper from "../../../assets/javascripts/lbry.js"
|
||||||
|
|
||||||
let updateInstancesElement = document.getElementById("update-instances");
|
let updateInstancesElement = document.getElementById("update-instances")
|
||||||
updateInstancesElement.addEventListener("click", async () => {
|
updateInstancesElement.addEventListener("click", async () => {
|
||||||
let oldHtml = updateInstancesElement.innerHTML
|
let oldHtml = updateInstancesElement.innerHTML
|
||||||
updateInstancesElement.innerHTML = '...';
|
updateInstancesElement.innerHTML = "..."
|
||||||
if (await utils.updateInstances()) {
|
if (await utils.updateInstances()) {
|
||||||
updateInstancesElement.innerHTML = oldHtml;
|
updateInstancesElement.innerHTML = oldHtml
|
||||||
location.reload();
|
location.reload()
|
||||||
}
|
} else updateInstancesElement.innerHTML = "Failed Miserabely"
|
||||||
else
|
})
|
||||||
updateInstancesElement.innerHTML = 'Failed Miserabely';
|
|
||||||
});
|
|
||||||
|
|
||||||
let exportSettingsElement = document.getElementById("export-settings");
|
let exportSettingsElement = document.getElementById("export-settings")
|
||||||
|
|
||||||
function exportSettings() {
|
function exportSettings() {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(null, result => {
|
||||||
null,
|
let resultString = JSON.stringify(result, null, " ")
|
||||||
result => {
|
exportSettingsElement.href = "data:application/json;base64," + btoa(encodeURI(resultString))
|
||||||
let resultString = JSON.stringify(result, null, ' ');
|
exportSettingsElement.download = "libredirect-settings.json"
|
||||||
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 importSettingsElement = document.getElementById("import-settings")
|
||||||
let importSettingsElementText = document.getElementById('import_settings_text');
|
let importSettingsElementText = document.getElementById("import_settings_text")
|
||||||
importSettingsElement.addEventListener("change",
|
importSettingsElement.addEventListener("change", () => {
|
||||||
() => {
|
importSettingsElementText.innerHTML = "..."
|
||||||
importSettingsElementText.innerHTML = '...';
|
let file = importSettingsElement.files[0]
|
||||||
let file = importSettingsElement.files[0];
|
const reader = new FileReader()
|
||||||
const reader = new FileReader();
|
reader.readAsText(file)
|
||||||
reader.readAsText(file);
|
reader.onload = async () => {
|
||||||
reader.onload = async () => {
|
const data = JSON.parse(reader.result)
|
||||||
const data = JSON.parse(reader.result)
|
if ("theme" in data && "disableImgur" in data && "imgurRedirects" in data) {
|
||||||
if (
|
browser.storage.local.clear(() => {
|
||||||
"theme" in data &&
|
browser.storage.local.set({ ...data }, async () => {
|
||||||
"disableImgur" in data &&
|
await youtubeHelper.pasteInvidiousCookies()
|
||||||
"imgurRedirects" in data
|
await youtubeHelper.pastePipedLocalStorage()
|
||||||
) {
|
await youtubeHelper.pastePipedMaterialLocalStorage()
|
||||||
browser.storage.local.clear(
|
|
||||||
() => {
|
|
||||||
browser.storage.local.set({ ...data },
|
|
||||||
async () => {
|
|
||||||
await youtubeHelper.pasteInvidiousCookies();
|
|
||||||
await youtubeHelper.pastePipedLocalStorage();
|
|
||||||
await youtubeHelper.pastePipedMaterialLocalStorage();
|
|
||||||
|
|
||||||
await translateHelper.pasteSimplyTranslateCookies();
|
await translateHelper.pasteSimplyTranslateCookies()
|
||||||
await translateHelper.pasteLingvaLocalStorage();
|
await translateHelper.pasteLingvaLocalStorage()
|
||||||
|
|
||||||
await twitterHelper.pasteNitterCookies();
|
await twitterHelper.pasteNitterCookies()
|
||||||
|
|
||||||
await wikipediaHelper.pasteWikilessCookies();
|
await wikipediaHelper.pasteWikilessCookies()
|
||||||
|
|
||||||
await searchHelper.pasteSearxCookies();
|
await searchHelper.pasteSearxCookies()
|
||||||
await searchHelper.pasteSearxngCookies();
|
await searchHelper.pasteSearxngCookies()
|
||||||
await searchHelper.pasteLibrexCookies();
|
await searchHelper.pasteLibrexCookies()
|
||||||
|
|
||||||
await redditHelper.pasteLibredditCookies();
|
await redditHelper.pasteLibredditCookies()
|
||||||
await redditHelper.pasteTedditCookies();
|
await redditHelper.pasteTedditCookies()
|
||||||
|
|
||||||
await tiktokHelper.pasteProxiTokCookies();
|
await tiktokHelper.pasteProxiTokCookies()
|
||||||
|
|
||||||
location.reload();
|
location.reload()
|
||||||
})
|
})
|
||||||
|
})
|
||||||
});
|
} else {
|
||||||
} else {
|
console.log("incompatible settings")
|
||||||
console.log('incompatible settings');
|
importError()
|
||||||
importError()
|
}
|
||||||
}
|
}
|
||||||
}
|
reader.onerror = error => {
|
||||||
reader.onerror = error => {
|
console.log("error", error)
|
||||||
console.log('error', error);
|
importError()
|
||||||
importError()
|
}
|
||||||
};
|
})
|
||||||
}
|
|
||||||
);
|
|
||||||
function importError() {
|
function importError() {
|
||||||
const oldHTML = importSettingsElementText.innerHTML;
|
const oldHTML = importSettingsElementText.innerHTML
|
||||||
importSettingsElementText.innerHTML = '<span style="color:red;">Error!</span>';
|
importSettingsElementText.innerHTML = '<span style="color:red;">Error!</span>'
|
||||||
setTimeout(() => importSettingsElementText.innerHTML = oldHTML, 1000);
|
setTimeout(() => (importSettingsElementText.innerHTML = oldHTML), 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
const resetSettings = document.getElementById("reset-settings");
|
const resetSettings = document.getElementById("reset-settings")
|
||||||
resetSettings.addEventListener("click",
|
resetSettings.addEventListener("click", async () => {
|
||||||
async () => {
|
resetSettings.innerHTML = "..."
|
||||||
resetSettings.innerHTML = '...'
|
browser.storage.local.clear(() => {
|
||||||
browser.storage.local.clear(
|
fetch("/instances/blacklist.json")
|
||||||
() => {
|
.then(response => response.text())
|
||||||
fetch('/instances/blacklist.json').then(response => response.text()).then(async data => {
|
.then(async data => {
|
||||||
browser.storage.local.set({ cloudflareBlackList: JSON.parse(data).cloudflare },
|
browser.storage.local.set({ cloudflareBlackList: JSON.parse(data).cloudflare }, () => {
|
||||||
() => {
|
browser.storage.local.set({ authenticateBlackList: JSON.parse(data).authenticate }, async () => {
|
||||||
browser.storage.local.set({ authenticateBlackList: JSON.parse(data).authenticate },
|
await generalHelper.initDefaults()
|
||||||
async () => {
|
await youtubeHelper.initDefaults()
|
||||||
await generalHelper.initDefaults();
|
await youtubeMusicHelper.initDefaults()
|
||||||
await youtubeHelper.initDefaults();
|
await twitterHelper.initDefaults()
|
||||||
await youtubeMusicHelper.initDefaults();
|
await instagramHelper.initDefaults()
|
||||||
await twitterHelper.initDefaults();
|
await mapsHelper.initDefaults()
|
||||||
await instagramHelper.initDefaults();
|
await searchHelper.initDefaults()
|
||||||
await mapsHelper.initDefaults();
|
await translateHelper.initDefaults()
|
||||||
await searchHelper.initDefaults();
|
await mediumHelper.initDefaults()
|
||||||
await translateHelper.initDefaults();
|
await quoraHelper.initDefaults()
|
||||||
await mediumHelper.initDefaults();
|
await libremdbHelper.initDefaults()
|
||||||
await quoraHelper.initDefaults();
|
await reutersHelper.initDefaults()
|
||||||
await libremdbHelper.initDefaults();
|
await redditHelper.initDefaults()
|
||||||
await reutersHelper.initDefaults();
|
await wikipediaHelper.initDefaults()
|
||||||
await redditHelper.initDefaults();
|
await imgurHelper.initDefaults()
|
||||||
await wikipediaHelper.initDefaults();
|
await tiktokHelper.initDefaults()
|
||||||
await imgurHelper.initDefaults();
|
await sendTargetsHelper.initDefaults()
|
||||||
await tiktokHelper.initDefaults();
|
await peertubeHelper.initDefaults()
|
||||||
await sendTargetsHelper.initDefaults();
|
await lbryHelper.initDefaults()
|
||||||
await peertubeHelper.initDefaults();
|
location.reload()
|
||||||
await lbryHelper.initDefaults();
|
})
|
||||||
location.reload();
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
let autoRedirectElement = document.getElementById("auto-redirect")
|
let autoRedirectElement = document.getElementById("auto-redirect")
|
||||||
autoRedirectElement.addEventListener("change", event => {
|
autoRedirectElement.addEventListener("change", event => {
|
||||||
browser.storage.local.set({ autoRedirect: event.target.checked })
|
browser.storage.local.set({ autoRedirect: event.target.checked })
|
||||||
});
|
|
||||||
|
|
||||||
let themeElement = document.getElementById("theme");
|
|
||||||
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");
|
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 => {
|
protocolElement.addEventListener("change", event => {
|
||||||
const value = event.target.options[protocol.selectedIndex].value;
|
const value = event.target.options[protocol.selectedIndex].value
|
||||||
browser.storage.local.set({ protocol: value });
|
browser.storage.local.set({ protocol: value })
|
||||||
location.reload();
|
location.reload()
|
||||||
})
|
})
|
||||||
|
|
||||||
let protocolFallbackCheckbox = document.getElementById("protocol-fallback-checkbox")
|
let protocolFallbackCheckbox = document.getElementById("protocol-fallback-checkbox")
|
||||||
protocolFallbackCheckbox.addEventListener("change", event => {
|
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 nameCustomInstanceInput = document.getElementById("exceptions-custom-instance")
|
||||||
let instanceTypeElement = document.getElementById("exceptions-custom-instance-type");
|
let instanceTypeElement = document.getElementById("exceptions-custom-instance-type")
|
||||||
let instanceType = "url"
|
let instanceType = "url"
|
||||||
|
|
||||||
let popupFrontends;
|
let popupFrontends
|
||||||
for (const frontend of generalHelper.allPopupFrontends)
|
for (const frontend of generalHelper.allPopupFrontends)
|
||||||
document.getElementById(frontend).addEventListener("change",
|
document.getElementById(frontend).addEventListener("change", event => {
|
||||||
event => {
|
if (event.target.checked && !popupFrontends.includes(frontend)) popupFrontends.push(frontend)
|
||||||
if (event.target.checked && !popupFrontends.includes(frontend))
|
else if (popupFrontends.includes(frontend)) {
|
||||||
popupFrontends.push(frontend)
|
var index = popupFrontends.indexOf(frontend)
|
||||||
else if (popupFrontends.includes(frontend)) {
|
if (index !== -1) popupFrontends.splice(index, 1)
|
||||||
var index = popupFrontends.indexOf(frontend);
|
}
|
||||||
if (index !== -1) popupFrontends.splice(index, 1);
|
browser.storage.local.set({ popupFrontends })
|
||||||
}
|
})
|
||||||
browser.storage.local.set({ popupFrontends })
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// const firstPartyIsolate = document.getElementById('firstPartyIsolate');
|
// const firstPartyIsolate = document.getElementById('firstPartyIsolate');
|
||||||
// firstPartyIsolate.addEventListener("change", () => browser.storage.local.set({ firstPartyIsolate: firstPartyIsolate.checked }))
|
// firstPartyIsolate.addEventListener("change", () => browser.storage.local.set({ firstPartyIsolate: firstPartyIsolate.checked }))
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
'theme',
|
"theme",
|
||||||
'autoRedirect',
|
"autoRedirect",
|
||||||
'exceptions',
|
"exceptions",
|
||||||
'protocol',
|
"protocol",
|
||||||
'protocolFallback'
|
"protocolFallback",
|
||||||
// 'firstPartyIsolate'
|
// 'firstPartyIsolate'
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
autoRedirectElement.checked = r.autoRedirect;
|
autoRedirectElement.checked = r.autoRedirect
|
||||||
themeElement.value = r.theme;
|
themeElement.value = r.theme
|
||||||
protocolElement.value = r.protocol;
|
protocolElement.value = r.protocol
|
||||||
protocolFallbackCheckbox.checked = r.protocolFallback;
|
protocolFallbackCheckbox.checked = r.protocolFallback
|
||||||
// firstPartyIsolate.checked = r.firstPartyIsolate;
|
// firstPartyIsolate.checked = r.firstPartyIsolate;
|
||||||
|
|
||||||
let protocolFallbackElement = document.getElementById('protocol-fallback')
|
let protocolFallbackElement = document.getElementById("protocol-fallback")
|
||||||
if (protocolElement.value == "normal") {
|
if (protocolElement.value == "normal") {
|
||||||
protocolFallbackElement.style.display = 'none';
|
protocolFallbackElement.style.display = "none"
|
||||||
} else {
|
} else {
|
||||||
protocolFallbackElement.style.display = 'block';
|
protocolFallbackElement.style.display = "block"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
instanceTypeElement.addEventListener("change", event => {
|
||||||
instanceTypeElement.addEventListener("change",
|
instanceType = event.target.options[instanceTypeElement.selectedIndex].value
|
||||||
event => {
|
if (instanceType == "url") {
|
||||||
instanceType = event.target.options[instanceTypeElement.selectedIndex].value
|
nameCustomInstanceInput.setAttribute("type", "url")
|
||||||
if (instanceType == 'url') {
|
nameCustomInstanceInput.setAttribute("placeholder", "https://www.google.com")
|
||||||
nameCustomInstanceInput.setAttribute("type", "url");
|
} else if (instanceType == "regex") {
|
||||||
nameCustomInstanceInput.setAttribute("placeholder", "https://www.google.com");
|
nameCustomInstanceInput.setAttribute("type", "text")
|
||||||
}
|
nameCustomInstanceInput.setAttribute("placeholder", "https?://(www.|)youtube.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(
|
||||||
let exceptionsCustomInstances = r.exceptions;
|
x => `<div>
|
||||||
function calcExceptionsCustomInstances() {
|
|
||||||
document.getElementById("exceptions-custom-checklist").innerHTML =
|
|
||||||
[...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex].map(
|
|
||||||
(x) => `<div>
|
|
||||||
${x}
|
${x}
|
||||||
<button class="add" id="clear-${x}">
|
<button class="add" id="clear-${x}">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
|
<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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<hr>`
|
<hr>`
|
||||||
).join('\n');
|
)
|
||||||
|
.join("\n")
|
||||||
|
|
||||||
for (const x of [...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex]) {
|
for (const x of [...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex]) {
|
||||||
document.getElementById(`clear-${x}`).addEventListener("click",
|
document.getElementById(`clear-${x}`).addEventListener("click", () => {
|
||||||
() => {
|
console.log(x)
|
||||||
console.log(x);
|
let index
|
||||||
let index;
|
index = exceptionsCustomInstances.url.indexOf(x)
|
||||||
index = exceptionsCustomInstances.url.indexOf(x);
|
if (index > -1) exceptionsCustomInstances.url.splice(index, 1)
|
||||||
if (index > -1)
|
else {
|
||||||
exceptionsCustomInstances.url.splice(index, 1);
|
index = exceptionsCustomInstances.regex.indexOf(x)
|
||||||
else {
|
if (index > -1) exceptionsCustomInstances.regex.splice(index, 1)
|
||||||
index = exceptionsCustomInstances.regex.indexOf(x);
|
}
|
||||||
if (index > -1)
|
browser.storage.local.set({ exceptions: exceptionsCustomInstances })
|
||||||
exceptionsCustomInstances.regex.splice(index, 1);
|
calcExceptionsCustomInstances()
|
||||||
}
|
})
|
||||||
browser.storage.local.set({ exceptions: exceptionsCustomInstances })
|
}
|
||||||
calcExceptionsCustomInstances();
|
}
|
||||||
});
|
calcExceptionsCustomInstances()
|
||||||
}
|
document.getElementById("custom-exceptions-instance-form").addEventListener("submit", event => {
|
||||||
}
|
event.preventDefault()
|
||||||
calcExceptionsCustomInstances();
|
|
||||||
document.getElementById("custom-exceptions-instance-form").addEventListener("submit", (event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
let val
|
let val
|
||||||
if (instanceType == 'url') {
|
if (instanceType == "url") {
|
||||||
if (nameCustomInstanceInput.validity.valid) {
|
if (nameCustomInstanceInput.validity.valid) {
|
||||||
let url = new URL(nameCustomInstanceInput.value);
|
let url = new URL(nameCustomInstanceInput.value)
|
||||||
val = `${url.protocol}//${url.host}`
|
val = `${url.protocol}//${url.host}`
|
||||||
if (!exceptionsCustomInstances.url.includes(val)) exceptionsCustomInstances.url.push(val)
|
if (!exceptionsCustomInstances.url.includes(val)) exceptionsCustomInstances.url.push(val)
|
||||||
}
|
}
|
||||||
} else if (instanceType == 'regex') {
|
} else if (instanceType == "regex") {
|
||||||
val = nameCustomInstanceInput.value
|
val = nameCustomInstanceInput.value
|
||||||
if (val.trim() != '' && !exceptionsCustomInstances.regex.includes(val)) exceptionsCustomInstances.regex.push(val)
|
if (val.trim() != "" && !exceptionsCustomInstances.regex.includes(val)) exceptionsCustomInstances.regex.push(val)
|
||||||
}
|
}
|
||||||
if (val) {
|
if (val) {
|
||||||
browser.storage.local.set({ exceptions: exceptionsCustomInstances })
|
browser.storage.local.set({ exceptions: exceptionsCustomInstances })
|
||||||
nameCustomInstanceInput.value = '';
|
nameCustomInstanceInput.value = ""
|
||||||
}
|
}
|
||||||
calcExceptionsCustomInstances();
|
calcExceptionsCustomInstances()
|
||||||
})
|
})
|
||||||
|
|
||||||
browser.storage.local.get('popupFrontends',
|
browser.storage.local.get("popupFrontends", r => {
|
||||||
r => {
|
popupFrontends = r.popupFrontends
|
||||||
popupFrontends = r.popupFrontends;
|
for (const frontend of generalHelper.allPopupFrontends) document.getElementById(frontend).checked = popupFrontends.includes(frontend)
|
||||||
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
|
// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST
|
||||||
|
|
||||||
const frontends = new Array("libremdb")
|
const frontends = new Array("libremdb")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("imdb-enable");
|
const enable = document.getElementById("imdb-enable")
|
||||||
const imdb = document.getElementById('imdb_page');
|
const imdb = document.getElementById("imdb_page")
|
||||||
//const frontend = document.getElementById("imdb-frontend");
|
//const frontend = document.getElementById("imdb-frontend");
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
|
@ -24,38 +24,32 @@ function changeFrontendsSettings() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableImdb", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.disableImdb
|
||||||
"disableImdb",
|
protocol = r.protocol
|
||||||
"protocol"
|
changeProtocolSettings()
|
||||||
],
|
})
|
||||||
r => {
|
|
||||||
enable.checked = !r.disableImdb;
|
|
||||||
protocol = r.protocol;
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
imdb.addEventListener("change", () => {
|
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 i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++){
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('imdb', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("imdb", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('imdb', frontends[i], document, location)
|
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
|
// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST
|
||||||
|
|
||||||
const frontends = new Array("rimgo")
|
const frontends = new Array("rimgo")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("imgur-enable");
|
const enable = document.getElementById("imgur-enable")
|
||||||
const imgur = document.getElementById('imgur_page');
|
const imgur = document.getElementById("imgur_page")
|
||||||
//const frontend = document.getElementById("imgur-frontend");
|
//const frontend = document.getElementById("imgur-frontend");
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
|
@ -24,38 +24,32 @@ function changeFrontendsSettings() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableImgur", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.disableImgur
|
||||||
"disableImgur",
|
protocol = r.protocol
|
||||||
"protocol"
|
changeProtocolSettings()
|
||||||
],
|
})
|
||||||
r => {
|
|
||||||
enable.checked = !r.disableImgur;
|
|
||||||
protocol = r.protocol;
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
imgur.addEventListener("change", () => {
|
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 i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++){
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('imgur', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("imgur", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('imgur', frontends[i], document, location)
|
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
|
// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST
|
||||||
|
|
||||||
const frontends = new Array("bibliogram")
|
const frontends = new Array("bibliogram")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("instagram-enable");
|
const enable = document.getElementById("instagram-enable")
|
||||||
const instagram = document.getElementById('instagram_page')
|
const instagram = document.getElementById("instagram_page")
|
||||||
//const frontend = document.getElementById("instagram-frontend");
|
//const frontend = document.getElementById("instagram-frontend");
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
|
@ -24,38 +24,32 @@ function changeFrontendsSettings() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableInstagram", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.disableInstagram
|
||||||
"disableInstagram",
|
protocol = r.protocol
|
||||||
"protocol"
|
changeProtocolSettings()
|
||||||
],
|
})
|
||||||
r => {
|
|
||||||
enable.checked = !r.disableInstagram;
|
|
||||||
protocol = r.protocol;
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
instagram.addEventListener("change", () => {
|
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 i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++){
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('instagram', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("instagram", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('instagram', frontends[i], document, location)
|
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
|
// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST
|
||||||
|
|
||||||
const frontends = new Array("librarian")
|
const frontends = new Array("librarian")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("lbry-enable");
|
const enable = document.getElementById("lbry-enable")
|
||||||
const lbry = document.getElementById('lbry_page');
|
const lbry = document.getElementById("lbry_page")
|
||||||
//const frontend = document.getElementById("lbry-frontend");
|
//const frontend = document.getElementById("lbry-frontend");
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
|
@ -24,38 +24,32 @@ function changeFrontendsSettings() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableLbryTargets", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.disableLbryTargets
|
||||||
"disableLbryTargets",
|
protocol = r.protocol
|
||||||
"protocol"
|
changeProtocolSettings()
|
||||||
],
|
})
|
||||||
r => {
|
|
||||||
enable.checked = !r.disableLbryTargets;
|
|
||||||
protocol = r.protocol;
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
lbry.addEventListener("change", () => {
|
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 i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++){
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('lbryTargets', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("lbryTargets", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('lbryTargets', frontends[i], document, location)
|
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 frontends = new Array("facil")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("maps-enable");
|
const enable = document.getElementById("maps-enable")
|
||||||
const maps = document.getElementById('maps_page');
|
const maps = document.getElementById("maps_page")
|
||||||
const frontend = document.getElementById("maps-frontend");
|
const frontend = document.getElementById("maps-frontend")
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeFrontendsSettings() {
|
function changeFrontendsSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
if (frontends[i] == frontend.value) {
|
if (frontends[i] == frontend.value) {
|
||||||
frontendDiv.style.display = 'block'
|
frontendDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
frontendDiv.style.display = 'none'
|
frontendDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableMaps", "protocol", "mapsFrontend"], r => {
|
||||||
[
|
enable.checked = !r.disableMaps
|
||||||
"disableMaps",
|
protocol = r.protocol
|
||||||
"protocol",
|
frontend.value = r.mapsFrontend
|
||||||
"mapsFrontend"
|
changeFrontendsSettings()
|
||||||
],
|
changeProtocolSettings()
|
||||||
r => {
|
})
|
||||||
enable.checked = !r.disableMaps;
|
|
||||||
protocol = r.protocol;
|
|
||||||
frontend.value = r.mapsFrontend;
|
|
||||||
changeFrontendsSettings();
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
maps.addEventListener("change", () => {
|
maps.addEventListener("change", () => {
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
disableMaps: !enable.checked,
|
disableMaps: !enable.checked,
|
||||||
mapsFrontend: frontend.value
|
mapsFrontend: frontend.value,
|
||||||
});
|
})
|
||||||
changeFrontendsSettings();
|
changeFrontendsSettings()
|
||||||
})
|
})
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('maps', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("maps", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('maps', frontends[i], document, location)
|
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
|
// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST
|
||||||
|
|
||||||
const frontends = new Array("scribe")
|
const frontends = new Array("scribe")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("medium-enable");
|
const enable = document.getElementById("medium-enable")
|
||||||
const medium = document.getElementById('medium_page');
|
const medium = document.getElementById("medium_page")
|
||||||
//const frontend = document.getElementById("medium-frontend");
|
//const frontend = document.getElementById("medium-frontend");
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
|
@ -24,38 +24,32 @@ function changeFrontendsSettings() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableMedium", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.disableMedium
|
||||||
"disableMedium",
|
protocol = r.protocol
|
||||||
"protocol"
|
changeProtocolSettings()
|
||||||
],
|
})
|
||||||
r => {
|
|
||||||
enable.checked = !r.disableMedium;
|
|
||||||
protocol = r.protocol;
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
medium.addEventListener("change", () => {
|
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 i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++){
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('medium', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("medium", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('medium', frontends[i], document, location)
|
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
|
// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST
|
||||||
|
|
||||||
const frontends = new Array("simpleertube")
|
const frontends = new Array("simpleertube")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("peertube-enable");
|
const enable = document.getElementById("peertube-enable")
|
||||||
const peertube = document.getElementById('peertube_page');
|
const peertube = document.getElementById("peertube_page")
|
||||||
//const frontend = document.getElementById("peertube-frontend");
|
//const frontend = document.getElementById("peertube-frontend");
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
|
@ -24,38 +24,32 @@ function changeFrontendsSettings() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disablePeertubeTargets", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.disablePeertubeTargets
|
||||||
"disablePeertubeTargets",
|
protocol = r.protocol
|
||||||
"protocol"
|
changeProtocolSettings()
|
||||||
],
|
})
|
||||||
r => {
|
|
||||||
enable.checked = !r.disablePeertubeTargets;
|
|
||||||
protocol = r.protocol;
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
peertube.addEventListener("change", () => {
|
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 i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++){
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('peertube', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("peertube", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('peertube', frontends[i], document, location)
|
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
|
// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST
|
||||||
|
|
||||||
const frontends = new Array("quetre")
|
const frontends = new Array("quetre")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("quora-enable");
|
const enable = document.getElementById("quora-enable")
|
||||||
const quora = document.getElementById('quora_page');
|
const quora = document.getElementById("quora_page")
|
||||||
//const frontend = document.getElementById("quora-frontend");
|
//const frontend = document.getElementById("quora-frontend");
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
|
@ -24,38 +24,32 @@ function changeFrontendsSettings() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableQuora", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.disableQuora
|
||||||
"disableQuora",
|
protocol = r.protocol
|
||||||
"protocol"
|
changeProtocolSettings()
|
||||||
],
|
})
|
||||||
r => {
|
|
||||||
enable.checked = !r.disableQuora;
|
|
||||||
protocol = r.protocol;
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
quora.addEventListener("change", () => {
|
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 i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++){
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('quora', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("quora", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('quora', frontends[i], document, location)
|
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 frontends = new Array("libreddit", "teddit")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("reddit-enable");
|
const enable = document.getElementById("reddit-enable")
|
||||||
const reddit = document.getElementById('reddit_page');
|
const reddit = document.getElementById("reddit_page")
|
||||||
const frontend = document.getElementById("reddit-frontend");
|
const frontend = document.getElementById("reddit-frontend")
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
function changeFrontendsSettings() {
|
function changeFrontendsSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
if (frontends[i] == frontend.value) {
|
if (frontends[i] == frontend.value) {
|
||||||
frontendDiv.style.display = 'block'
|
frontendDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
frontendDiv.style.display = 'none'
|
frontendDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableReddit", "protocol", "redditFrontend"], r => {
|
||||||
[
|
enable.checked = !r.disableReddit
|
||||||
"disableReddit",
|
protocol = r.protocol
|
||||||
"protocol",
|
frontend.value = r.redditFrontend
|
||||||
"redditFrontend",
|
changeFrontendsSettings()
|
||||||
],
|
changeProtocolSettings()
|
||||||
r => {
|
})
|
||||||
enable.checked = !r.disableReddit
|
|
||||||
protocol = r.protocol
|
|
||||||
frontend.value = r.redditFrontend
|
|
||||||
changeFrontendsSettings();
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
reddit.addEventListener("change", () => {
|
reddit.addEventListener("change", () => {
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
disableReddit: !enable.checked,
|
disableReddit: !enable.checked,
|
||||||
redditFrontend: frontend.value
|
redditFrontend: frontend.value,
|
||||||
});
|
})
|
||||||
changeFrontendsSettings();
|
changeFrontendsSettings()
|
||||||
})
|
})
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++){
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('reddit', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("reddit", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('reddit', frontends[i], document, location)
|
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
|
// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST
|
||||||
|
|
||||||
const frontends = new Array("neuters")
|
const frontends = new Array("neuters")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("reuters-enable");
|
const enable = document.getElementById("reuters-enable")
|
||||||
const reuters = document.getElementById('reuters_page');
|
const reuters = document.getElementById("reuters_page")
|
||||||
//const frontend = document.getElementById("reuters-frontend");
|
//const frontend = document.getElementById("reuters-frontend");
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
|
@ -24,38 +24,32 @@ function changeFrontendsSettings() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableReuters", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.disableReuters
|
||||||
"disableReuters",
|
protocol = r.protocol
|
||||||
"protocol"
|
changeProtocolSettings()
|
||||||
],
|
})
|
||||||
r => {
|
|
||||||
enable.checked = !r.disableReuters;
|
|
||||||
protocol = r.protocol;
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
reuters.addEventListener("change", () => {
|
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 i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++){
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('reuters', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("reuters", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('reuters', frontends[i], document, location)
|
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.
|
// 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.
|
// 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)
|
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.searxDiv = searxDiv.getElementsByClassName(protocol)[0];
|
||||||
this.searxngDiv = searxngDiv.getElementsByClassName(protocol)[0];
|
this.searxngDiv = searxngDiv.getElementsByClassName(protocol)[0];
|
||||||
this.librexDiv = librexDiv.getElementsByClassName(protocol)[0];
|
this.librexDiv = librexDiv.getElementsByClassName(protocol)[0];
|
||||||
|
@ -35,23 +35,22 @@ const searxngDiv = document.getElementById("searxng");
|
||||||
const whoogleDiv = document.getElementById("whoogle");
|
const whoogleDiv = document.getElementById("whoogle");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const enable = document.getElementById("search-enable");
|
const enable = document.getElementById("search-enable")
|
||||||
const search = document.getElementById('search_page');
|
const search = document.getElementById("search_page")
|
||||||
const frontend = document.getElementById("search-frontend");
|
const frontend = document.getElementById("search-frontend")
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
function changeFrontendsSettings() {
|
function changeFrontendsSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
if (frontends[i] == frontend.value) {
|
if (frontends[i] == frontend.value) {
|
||||||
frontendDiv.style.display = 'block'
|
frontendDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
frontendDiv.style.display = 'none'
|
frontendDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
/*
|
|
||||||
if (frontend.value == 'searx') {
|
if (frontend.value == 'searx') {
|
||||||
searxDiv.style.display = 'block';
|
searxDiv.style.display = 'block';
|
||||||
searxngDiv.style.display = 'none';
|
searxngDiv.style.display = 'none';
|
||||||
|
@ -79,32 +78,27 @@ function changeFrontendsSettings() {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let i = 0; i < frontends.length; 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.
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
//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.
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
if (protocols[x] == protocol) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
//if the frontend value equals the selected one, it will show. Otherwise, it will be hidden
|
||||||
if (protocols[x] == protocol) { //if the frontend value equals the selected one, it will show. Otherwise, it will be hidden
|
protocolDiv.style.display = "block"
|
||||||
protocolDiv.style.display = 'block'
|
} else {
|
||||||
} else {
|
protocolDiv.style.display = "none"
|
||||||
protocolDiv.style.display = 'none'
|
}
|
||||||
}
|
}
|
||||||
}
|
/*
|
||||||
/*
|
|
||||||
} else {
|
} else {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
/*
|
|
||||||
* "Legacy" code
|
* "Legacy" code
|
||||||
const normalsearxDiv = searxDiv.getElementsByClassName("normal")[0];
|
const normalsearxDiv = searxDiv.getElementsByClassName("normal")[0];
|
||||||
const torsearxDiv = searxDiv.getElementsByClassName("tor")[0];
|
const torsearxDiv = searxDiv.getElementsByClassName("tor")[0];
|
||||||
|
@ -168,35 +162,28 @@ function changeProtocolSettings() {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableSearch", "searchFrontend", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.disableSearch
|
||||||
"disableSearch",
|
frontend.value = r.searchFrontend
|
||||||
"searchFrontend",
|
protocol = r.protocol
|
||||||
"protocol",
|
|
||||||
],
|
|
||||||
r => {
|
|
||||||
enable.checked = !r.disableSearch;
|
|
||||||
frontend.value = r.searchFrontend;
|
|
||||||
protocol = r.protocol;
|
|
||||||
|
|
||||||
changeFrontendsSettings();
|
changeFrontendsSettings()
|
||||||
changeProtocolSettings();
|
changeProtocolSettings()
|
||||||
}
|
})
|
||||||
);
|
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++){
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('search', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("search", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('search', frontends[i], document, location)
|
utils.latency("search", frontends[i], document, location)
|
||||||
}
|
}
|
||||||
|
|
||||||
search.addEventListener("change", () => {
|
search.addEventListener("change", () => {
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
disableSearch: !enable.checked,
|
disableSearch: !enable.checked,
|
||||||
searchFrontend: frontend.value,
|
searchFrontend: frontend.value,
|
||||||
});
|
})
|
||||||
changeFrontendsSettings();
|
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
|
// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST
|
||||||
|
|
||||||
const frontends = new Array("send")
|
const frontends = new Array("send")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("sendTargets-enable");
|
const enable = document.getElementById("sendTargets-enable")
|
||||||
const sendTargets = document.getElementById('sendTargets_page');
|
const sendTargets = document.getElementById("sendTargets_page")
|
||||||
//const frontend = document.getElementById("sendTargets-frontend");
|
//const frontend = document.getElementById("sendTargets-frontend");
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
|
@ -24,38 +24,32 @@ function changeFrontendsSettings() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableSendTarget", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.disableSendTarget
|
||||||
"disableSendTarget",
|
protocol = r.protocol
|
||||||
"protocol"
|
changeProtocolSettings()
|
||||||
],
|
})
|
||||||
r => {
|
|
||||||
enable.checked = !r.disableSendTarget;
|
|
||||||
protocol = r.protocol;
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
sendTargets.addEventListener("change", () => {
|
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 i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++){
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('sendTargets', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("sendTargets", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('sendTargets', frontends[i], document, location)
|
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
|
// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST
|
||||||
|
|
||||||
const frontends = new Array("proxiTok")
|
const frontends = new Array("proxiTok")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("tiktok-enable");
|
const enable = document.getElementById("tiktok-enable")
|
||||||
const tiktok = document.getElementById('tiktok_page');
|
const tiktok = document.getElementById("tiktok_page")
|
||||||
//const frontend = document.getElementById("tiktok-frontend");
|
//const frontend = document.getElementById("tiktok-frontend");
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
|
@ -24,38 +24,32 @@ function changeFrontendsSettings() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableTiktok", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.disableTiktok
|
||||||
"disableTiktok",
|
protocol = r.protocol
|
||||||
"protocol"
|
changeProtocolSettings()
|
||||||
],
|
})
|
||||||
r => {
|
|
||||||
enable.checked = !r.disableTiktok;
|
|
||||||
protocol = r.protocol;
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
tiktok.addEventListener("change", () => {
|
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 i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++){
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('tiktok', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("tiktok", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('tiktok', frontends[i], document, location)
|
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 frontends = new Array("simplyTranslate", "lingva")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("translate-enable");
|
const enable = document.getElementById("translate-enable")
|
||||||
const translate = document.getElementById('translate_page');
|
const translate = document.getElementById("translate_page")
|
||||||
const frontend = document.getElementById("translate-frontend");
|
const frontend = document.getElementById("translate-frontend")
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
function changeFrontendsSettings() {
|
function changeFrontendsSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
if (frontends[i] == frontend.value) {
|
if (frontends[i] == frontend.value) {
|
||||||
frontendDiv.style.display = 'block'
|
frontendDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
frontendDiv.style.display = 'none'
|
frontendDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["translateDisable", "translateFrontend", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.translateDisable
|
||||||
"translateDisable",
|
frontend.value = r.translateFrontend
|
||||||
"translateFrontend",
|
protocol = r.protocol
|
||||||
"protocol"
|
changeFrontendsSettings()
|
||||||
],
|
changeProtocolSettings()
|
||||||
r => {
|
})
|
||||||
enable.checked = !r.translateDisable;
|
|
||||||
frontend.value = r.translateFrontend;
|
|
||||||
protocol = r.protocol;
|
|
||||||
changeFrontendsSettings();
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
translate.addEventListener("change", () => {
|
translate.addEventListener("change", () => {
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
translateDisable: !enable.checked,
|
translateDisable: !enable.checked,
|
||||||
translateFrontend: frontend.value,
|
translateFrontend: frontend.value,
|
||||||
})
|
})
|
||||||
changeFrontendsSettings();
|
changeFrontendsSettings()
|
||||||
})
|
})
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++){
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('translate', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("translate", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('translate', frontends[i], document, location)
|
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
|
// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST
|
||||||
|
|
||||||
const frontends = new Array("nitter")
|
const frontends = new Array("nitter")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("twitter-enable");
|
const enable = document.getElementById("twitter-enable")
|
||||||
const twitter = document.getElementById('twitter_page');
|
const twitter = document.getElementById("twitter_page")
|
||||||
const redirectType = document.getElementById("twitter-redirect_type");
|
const redirectType = document.getElementById("twitter-redirect_type")
|
||||||
//const frontend = document.getElementById("twitter-frontend");
|
//const frontend = document.getElementById("twitter-frontend");
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
|
@ -25,43 +25,36 @@ function changeFrontendsSettings() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableTwitter", "protocol", "twitterRedirectType"], r => {
|
||||||
[
|
enable.checked = !r.disableTwitter
|
||||||
"disableTwitter",
|
protocol = r.protocol
|
||||||
"protocol",
|
redirectType.value = r.twitterRedirectType
|
||||||
"twitterRedirectType"
|
changeProtocolSettings()
|
||||||
],
|
})
|
||||||
r => {
|
|
||||||
enable.checked = !r.disableTwitter;
|
|
||||||
protocol = r.protocol;
|
|
||||||
redirectType.value = r.twitterRedirectType;
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
twitter.addEventListener("change", () => {
|
twitter.addEventListener("change", () => {
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
disableTwitter: !enable.checked,
|
disableTwitter: !enable.checked,
|
||||||
twitterRedirectType: redirectType.value,
|
twitterRedirectType: redirectType.value,
|
||||||
});
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++){
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('twitter', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("twitter", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('twitter', frontends[i], document, location)
|
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
|
// UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST
|
||||||
|
|
||||||
const frontends = new Array("wikiless")
|
const frontends = new Array("wikiless")
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
const enable = document.getElementById("wikipedia-enable");
|
const enable = document.getElementById("wikipedia-enable")
|
||||||
const wikipedia = document.getElementById('wikipedia_page');
|
const wikipedia = document.getElementById("wikipedia_page")
|
||||||
//const frontend = document.getElementById("wikipedia-frontend");
|
//const frontend = document.getElementById("wikipedia-frontend");
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
|
@ -24,38 +24,32 @@ function changeFrontendsSettings() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableWikipedia", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.disableWikipedia
|
||||||
"disableWikipedia",
|
protocol = r.protocol
|
||||||
"protocol"
|
changeProtocolSettings()
|
||||||
],
|
})
|
||||||
r => {
|
|
||||||
enable.checked = !r.disableWikipedia;
|
|
||||||
protocol = r.protocol;
|
|
||||||
changeProtocolSettings();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
wikipedia.addEventListener("change", () => {
|
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 i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('wikipedia', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("wikipedia", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('wikipedia', frontends[i], document, location)
|
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 protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
const singleInstanceFrontends = new Array("freetube", "yatte")
|
const singleInstanceFrontends = new Array("freetube", "yatte")
|
||||||
|
|
||||||
const enable = document.getElementById("youtube-enable");
|
const enable = document.getElementById("youtube-enable")
|
||||||
const youtube = document.getElementById('youtube_page');
|
const youtube = document.getElementById("youtube_page")
|
||||||
const youtubeEmbedFrontend = document.getElementById("youtube-embed_frontend");
|
const youtubeEmbedFrontend = document.getElementById("youtube-embed_frontend")
|
||||||
const onlyEmbeddedVideo = document.getElementById("youtube-redirect_type");
|
const onlyEmbeddedVideo = document.getElementById("youtube-redirect_type")
|
||||||
const embeddedFrontendDiv = document.getElementById("youtube-embedded_frontend");
|
const embeddedFrontendDiv = document.getElementById("youtube-embedded_frontend")
|
||||||
const frontend = document.getElementById("youtube-frontend");
|
const frontend = document.getElementById("youtube-frontend")
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeEmbedFrontendsSettings() {
|
function changeEmbedFrontendsSettings() {
|
||||||
if (embeddedFrontendDiv.style.display == 'block') {
|
if (embeddedFrontendDiv.style.display == "block") {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const embeddedFrontendDiv = document.getElementById(frontends[i])
|
const embeddedFrontendDiv = document.getElementById(frontends[i])
|
||||||
if (frontends[i] == youtubeEmbedFrontend.value) {
|
if (frontends[i] == youtubeEmbedFrontend.value) {
|
||||||
embeddedFrontendDiv.style.display = 'block'
|
embeddedFrontendDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
embeddedFrontendDiv.style.display = 'none'
|
embeddedFrontendDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeFrontendsSettings() {
|
function changeFrontendsSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
if (frontends[i] == frontend.value) {
|
if (frontends[i] == frontend.value) {
|
||||||
frontendDiv.style.display = 'block'
|
frontendDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
frontendDiv.style.display = 'none'
|
frontendDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let singleInstanceFrontend = false
|
let singleInstanceFrontend = false
|
||||||
for (let i = 0; i < singleInstanceFrontends.length; i++) {
|
for (let i = 0; i < singleInstanceFrontends.length; i++) {
|
||||||
if (singleInstanceFrontends[i] == frontend.value) {
|
if (singleInstanceFrontends[i] == frontend.value) {
|
||||||
singleInstanceFrontend = true
|
singleInstanceFrontend = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (singleInstanceFrontend == true) {
|
if (singleInstanceFrontend == true) {
|
||||||
embeddedFrontendDiv.style.display = 'block'
|
embeddedFrontendDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
embeddedFrontendDiv.style.display = 'none'
|
embeddedFrontendDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableYoutube", "onlyEmbeddedVideo", "youtubeRedirects", "youtubeFrontend", "youtubeEmbedFrontend", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.disableYoutube
|
||||||
"disableYoutube",
|
onlyEmbeddedVideo.value = r.onlyEmbeddedVideo
|
||||||
"onlyEmbeddedVideo",
|
youtubeEmbedFrontend.value = r.youtubeEmbedFrontend
|
||||||
"youtubeRedirects",
|
frontend.value = r.youtubeFrontend
|
||||||
"youtubeFrontend",
|
protocol = r.protocol
|
||||||
|
|
||||||
"youtubeEmbedFrontend",
|
changeFrontendsSettings()
|
||||||
"protocol"
|
changeProtocolSettings()
|
||||||
],
|
changeEmbedFrontendsSettings()
|
||||||
r => {
|
})
|
||||||
enable.checked = !r.disableYoutube;
|
|
||||||
onlyEmbeddedVideo.value = r.onlyEmbeddedVideo;
|
|
||||||
youtubeEmbedFrontend.value = r.youtubeEmbedFrontend;
|
|
||||||
frontend.value = r.youtubeFrontend;
|
|
||||||
protocol = r.protocol;
|
|
||||||
|
|
||||||
changeFrontendsSettings();
|
|
||||||
changeProtocolSettings();
|
|
||||||
changeEmbedFrontendsSettings();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
youtube.addEventListener("change", () => {
|
youtube.addEventListener("change", () => {
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
disableYoutube: !enable.checked,
|
disableYoutube: !enable.checked,
|
||||||
youtubeEmbedFrontend: youtubeEmbedFrontend.value,
|
youtubeEmbedFrontend: youtubeEmbedFrontend.value,
|
||||||
youtubeFrontend: frontend.value,
|
youtubeFrontend: frontend.value,
|
||||||
onlyEmbeddedVideo: onlyEmbeddedVideo.value
|
onlyEmbeddedVideo: onlyEmbeddedVideo.value,
|
||||||
})
|
})
|
||||||
changeFrontendsSettings();
|
changeFrontendsSettings()
|
||||||
changeEmbedFrontendsSettings();
|
changeEmbedFrontendsSettings()
|
||||||
})
|
})
|
||||||
|
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('youtube', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("youtube", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('youtube', frontends[i], document, location)
|
utils.latency("youtube", frontends[i], document, location)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ section#youtube_page.option-block
|
||||||
option(value="invidious") Invidious
|
option(value="invidious") Invidious
|
||||||
option(value="piped") Piped
|
option(value="piped") Piped
|
||||||
option(value="pipedMaterial") Piped-Material
|
option(value="pipedMaterial") Piped-Material
|
||||||
|
option(value="cloudtube") CloudTube
|
||||||
option(value="freetube") FreeTube
|
option(value="freetube") FreeTube
|
||||||
option(value="yatte") Yattee
|
option(value="yatte") Yattee
|
||||||
|
|
||||||
|
@ -22,6 +23,7 @@ section#youtube_page.option-block
|
||||||
option(value="invidious") Invidious
|
option(value="invidious") Invidious
|
||||||
option(value="piped") Piped
|
option(value="piped") Piped
|
||||||
option(value="pipedMaterial") Piped-Material
|
option(value="pipedMaterial") Piped-Material
|
||||||
|
option(value="cloudtube") CloudTube
|
||||||
|
|
||||||
.some-block.option-block
|
.some-block.option-block
|
||||||
h4(data-localise="__MSG_redirectType__") Redirect Type
|
h4(data-localise="__MSG_redirectType__") Redirect Type
|
||||||
|
@ -81,4 +83,21 @@ section#youtube_page.option-block
|
||||||
include ../../widgets/instances.pug
|
include ../../widgets/instances.pug
|
||||||
+instances('http://piped-material.loki')
|
+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")
|
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", "hyperpipe")
|
||||||
|
|
||||||
const frontends = new Array("beatbump")
|
|
||||||
const protocols = new Array("normal", "tor", "i2p", "loki")
|
const protocols = new Array("normal", "tor", "i2p", "loki")
|
||||||
|
|
||||||
let enable = document.getElementById("youtubeMusic-enable");
|
let enable = document.getElementById("youtubeMusic-enable")
|
||||||
const youtubeMusic = document.getElementById('youtubeMusic_page');
|
const youtubeMusic = document.getElementById("youtubeMusic_page")
|
||||||
//const frontend = document.getElementById("youtubeMusic-frontend");
|
const frontend = document.getElementById("youtubeMusic-frontend")
|
||||||
let protocol
|
let protocol
|
||||||
|
|
||||||
/*
|
|
||||||
function changeFrontendsSettings() {
|
function changeFrontendsSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
if (frontends[i] == frontend.value) {
|
if (frontends[i] == frontend.value) {
|
||||||
frontendDiv.style.display = 'block'
|
frontendDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
frontendDiv.style.display = 'none'
|
frontendDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
function changeProtocolSettings() {
|
function changeProtocolSettings() {
|
||||||
for (let i = 0; i < frontends.length; i++) {
|
for (let i = 0; i < frontends.length; i++) {
|
||||||
const frontendDiv = document.getElementById(frontends[i])
|
const frontendDiv = document.getElementById(frontends[i])
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
const protocolDiv = frontendDiv.getElementsByClassName(protocols[x])[0]
|
||||||
if (protocols[x] == protocol) {
|
if (protocols[x] == protocol) {
|
||||||
protocolDiv.style.display = 'block'
|
protocolDiv.style.display = "block"
|
||||||
} else {
|
} else {
|
||||||
protocolDiv.style.display = 'none'
|
protocolDiv.style.display = "none"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(["disableYoutubeMusic", "youtubeMusicFrontend", "protocol"], r => {
|
||||||
[
|
enable.checked = !r.disableYoutubeMusic
|
||||||
"disableYoutubeMusic",
|
frontend.value = r.youtubeMusicFrontend
|
||||||
"protocol"
|
protocol = r.protocol
|
||||||
],
|
changeFrontendsSettings()
|
||||||
r => {
|
changeProtocolSettings()
|
||||||
enable.checked = !r.disableYoutubeMusic
|
})
|
||||||
protocol = r.protocol
|
|
||||||
changeProtocolSettings()
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
youtubeMusic.addEventListener("change", () => {
|
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 i = 0; i < frontends.length; i++) {
|
||||||
for (let x = 0; x < protocols.length; x++) {
|
for (let x = 0; x < protocols.length; x++) {
|
||||||
utils.processDefaultCustomInstances('youtubeMusic', frontends[i], protocols[x], document)
|
utils.processDefaultCustomInstances("youtubeMusic", frontends[i], protocols[x], document)
|
||||||
}
|
}
|
||||||
utils.latency('youtubeMusic', frontends[i], document, location)
|
utils.latency("youtubeMusic", frontends[i], document, location)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,17 @@ section#youtubeMusic_page.option-block
|
||||||
h4(data-localise="__MSG_enable__") Enable
|
h4(data-localise="__MSG_enable__") Enable
|
||||||
input#youtubeMusic-enable(type="checkbox")
|
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
|
#beatbump
|
||||||
hr
|
hr
|
||||||
.normal
|
.normal
|
||||||
include ../../widgets/instances.pug
|
include ../../widgets/instances.pug
|
||||||
+instances('https://beatbump.wewe')
|
+instances('https://beatbump.org')
|
||||||
include ../../widgets/latency.pug
|
include ../../widgets/latency.pug
|
||||||
+latency('beatbump')
|
+latency('beatbump')
|
||||||
.tor
|
.tor
|
||||||
|
@ -23,4 +29,21 @@ section#youtubeMusic_page.option-block
|
||||||
include ../../widgets/instances.pug
|
include ../../widgets/instances.pug
|
||||||
+instances('http://beatbump.loki')
|
+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")
|
script(type="module" src="./widgets/youtubeMusic.js")
|
||||||
|
|
|
@ -1,337 +1,445 @@
|
||||||
"use strict";
|
"use strict"
|
||||||
window.browser = window.browser || window.chrome;
|
window.browser = window.browser || window.chrome
|
||||||
|
|
||||||
import utils from "../../assets/javascripts/utils.js";
|
import utils from "../../assets/javascripts/utils.js"
|
||||||
import generalHelper from "../../assets/javascripts/general.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"
|
||||||
|
|
||||||
utils.unify(true).then(r => {
|
utils.unify(true).then(r => {
|
||||||
if (!r) document.getElementById('unify_div').style.display = 'none';
|
if (!r) document.getElementById("unify_div").style.display = "none"
|
||||||
else {
|
else {
|
||||||
const unify = document.getElementById('unify');
|
const unify = document.getElementById("unify")
|
||||||
const textElement = document.getElementById('unify').getElementsByTagName('h4')[0]
|
const textElement = document.getElementById("unify").getElementsByTagName("h4")[0]
|
||||||
unify.addEventListener("click", () => {
|
unify.addEventListener("click", () => {
|
||||||
const oldHtml = textElement.innerHTML;
|
const oldHtml = textElement.innerHTML
|
||||||
textElement.innerHTML = '...';
|
textElement.innerHTML = "..."
|
||||||
browser.runtime.sendMessage({ function: 'unify' },
|
browser.runtime.sendMessage({ function: "unify" }, response => {
|
||||||
response => { if (response && response.response) textElement.innerHTML = oldHtml })
|
if (response && response.response) textElement.innerHTML = oldHtml
|
||||||
}
|
})
|
||||||
);
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
utils.switchInstance(true).then(r => {
|
utils.switchInstance(true).then(r => {
|
||||||
if (!r) document.getElementById("change_instance_div").style.display = 'none';
|
if (!r) document.getElementById("change_instance_div").style.display = "none"
|
||||||
else document.getElementById("change_instance").addEventListener("click", () => utils.switchInstance(false));
|
else document.getElementById("change_instance").addEventListener("click", () => utils.switchInstance(false))
|
||||||
});
|
})
|
||||||
|
|
||||||
utils.copyRaw(true).then(r => {
|
utils.copyRaw(true).then(r => {
|
||||||
if (!r) document.getElementById('copy_raw_div').style.display = 'none';
|
if (!r) document.getElementById("copy_raw_div").style.display = "none"
|
||||||
else {
|
else {
|
||||||
const copy_raw = document.getElementById('copy_raw');
|
const copy_raw = document.getElementById("copy_raw")
|
||||||
copy_raw.addEventListener("click", () => utils.copyRaw(false, 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 allSites = document.getElementsByClassName("all_sites")[0]
|
||||||
const currSite = document.getElementsByClassName('current_site')[0];
|
const currSite = document.getElementsByClassName("current_site")[0]
|
||||||
|
|
||||||
const disableTwitterCurrentSite = currSite.getElementsByClassName("disable-nitter")[0];
|
const disableTwitterCurrentSite = currSite.getElementsByClassName("disable-nitter")[0]
|
||||||
const disableTwitterAllSites = allSites.getElementsByClassName("disable-nitter")[0];
|
const disableTwitterAllSites = allSites.getElementsByClassName("disable-nitter")[0]
|
||||||
|
|
||||||
const disableYoutubeCurrentSite = currSite.getElementsByClassName("disable-youtube")[0];
|
const disableYoutubeCurrentSite = currSite.getElementsByClassName("disable-youtube")[0]
|
||||||
const disableYoutubeAllSites = allSites.getElementsByClassName("disable-youtube")[0];
|
const disableYoutubeAllSites = allSites.getElementsByClassName("disable-youtube")[0]
|
||||||
|
|
||||||
const disableYoutubeMusicCurrentSite = currSite.getElementsByClassName("disable-youtubeMusic")[0];
|
const disableYoutubeMusicCurrentSite = currSite.getElementsByClassName("disable-youtubeMusic")[0]
|
||||||
const disableYoutubeMusicAllSites = allSites.getElementsByClassName("disable-youtubeMusic")[0];
|
const disableYoutubeMusicAllSites = allSites.getElementsByClassName("disable-youtubeMusic")[0]
|
||||||
|
|
||||||
const disableInstagramCurrentSite = currSite.getElementsByClassName("disable-bibliogram")[0];
|
const disableInstagramCurrentSite = currSite.getElementsByClassName("disable-bibliogram")[0]
|
||||||
const disableInstagramAllSites = allSites.getElementsByClassName("disable-bibliogram")[0];
|
const disableInstagramAllSites = allSites.getElementsByClassName("disable-bibliogram")[0]
|
||||||
|
|
||||||
const disableMapsCurrentSite = currSite.getElementsByClassName("disable-osm")[0];
|
const disableMapsCurrentSite = currSite.getElementsByClassName("disable-osm")[0]
|
||||||
const disableMapsAllSites = allSites.getElementsByClassName("disable-osm")[0];
|
const disableMapsAllSites = allSites.getElementsByClassName("disable-osm")[0]
|
||||||
|
|
||||||
const disableRedditCurrentSite = currSite.getElementsByClassName("disable-reddit")[0];
|
const disableRedditCurrentSite = currSite.getElementsByClassName("disable-reddit")[0]
|
||||||
const disableRedditAllSites = allSites.getElementsByClassName("disable-reddit")[0];
|
const disableRedditAllSites = allSites.getElementsByClassName("disable-reddit")[0]
|
||||||
|
|
||||||
const disableSearchCurrentSite = currSite.getElementsByClassName("disable-search")[0];
|
const disableSearchCurrentSite = currSite.getElementsByClassName("disable-search")[0]
|
||||||
const disableSearchAllSites = allSites.getElementsByClassName("disable-search")[0];
|
const disableSearchAllSites = allSites.getElementsByClassName("disable-search")[0]
|
||||||
|
|
||||||
const disableTranslateCurrentSite = currSite.getElementsByClassName("disable-translate")[0];
|
const disableTranslateCurrentSite = currSite.getElementsByClassName("disable-translate")[0]
|
||||||
const disableTranslateAllSites = allSites.getElementsByClassName("disable-translate")[0];
|
const disableTranslateAllSites = allSites.getElementsByClassName("disable-translate")[0]
|
||||||
|
|
||||||
const disableWikipediaCurrentSite = currSite.getElementsByClassName("disable-wikipedia")[0];
|
const disableWikipediaCurrentSite = currSite.getElementsByClassName("disable-wikipedia")[0]
|
||||||
const disableWikipediaAllSites = allSites.getElementsByClassName("disable-wikipedia")[0];
|
const disableWikipediaAllSites = allSites.getElementsByClassName("disable-wikipedia")[0]
|
||||||
|
|
||||||
const disableMediumCurrentSite = currSite.getElementsByClassName("disable-medium")[0];
|
const disableMediumCurrentSite = currSite.getElementsByClassName("disable-medium")[0]
|
||||||
const disableMediumAllSites = allSites.getElementsByClassName("disable-medium")[0];
|
const disableMediumAllSites = allSites.getElementsByClassName("disable-medium")[0]
|
||||||
|
|
||||||
const disableQuoraCurrentSite = currSite.getElementsByClassName("disable-quora")[0];
|
const disableQuoraCurrentSite = currSite.getElementsByClassName("disable-quora")[0]
|
||||||
const disableQuoraAllSites = allSites.getElementsByClassName("disable-quora")[0];
|
const disableQuoraAllSites = allSites.getElementsByClassName("disable-quora")[0]
|
||||||
|
|
||||||
const disableImdbCurrentSite = currSite.getElementsByClassName("disable-imdb")[0];
|
const disableImdbCurrentSite = currSite.getElementsByClassName("disable-imdb")[0]
|
||||||
const disableImdbAllSites = allSites.getElementsByClassName("disable-imdb")[0];
|
const disableImdbAllSites = allSites.getElementsByClassName("disable-imdb")[0]
|
||||||
|
|
||||||
const disableReutersCurrentSite = currSite.getElementsByClassName("disable-reuters")[0];
|
const disableReutersCurrentSite = currSite.getElementsByClassName("disable-reuters")[0]
|
||||||
const disableReutersAllSites = allSites.getElementsByClassName("disable-reuters")[0];
|
const disableReutersAllSites = allSites.getElementsByClassName("disable-reuters")[0]
|
||||||
|
|
||||||
const disablePeertubeTargetsCurrentSite = currSite.getElementsByClassName("disable-peertube")[0];
|
const disablePeertubeTargetsCurrentSite = currSite.getElementsByClassName("disable-peertube")[0]
|
||||||
const disablePeertubeTargetsAllSites = allSites.getElementsByClassName("disable-peertube")[0];
|
const disablePeertubeTargetsAllSites = allSites.getElementsByClassName("disable-peertube")[0]
|
||||||
|
|
||||||
const disableLbryTargetsCurrentSite = currSite.getElementsByClassName("disable-lbry")[0];
|
const disableLbryTargetsCurrentSite = currSite.getElementsByClassName("disable-lbry")[0]
|
||||||
const disableLbryTargetsAllSites = allSites.getElementsByClassName("disable-lbry")[0];
|
const disableLbryTargetsAllSites = allSites.getElementsByClassName("disable-lbry")[0]
|
||||||
|
|
||||||
const disableSendTargetsCurrentSite = currSite.getElementsByClassName("disable-sendTargets")[0];
|
const disableSendTargetsCurrentSite = currSite.getElementsByClassName("disable-sendTargets")[0]
|
||||||
const disableSendTargetsAllSites = allSites.getElementsByClassName("disable-sendTargets")[0];
|
const disableSendTargetsAllSites = allSites.getElementsByClassName("disable-sendTargets")[0]
|
||||||
|
|
||||||
const disableImgurCurrentSite = currSite.getElementsByClassName("disable-imgur")[0];
|
const disableImgurCurrentSite = currSite.getElementsByClassName("disable-imgur")[0]
|
||||||
const disableImgurAllSites = allSites.getElementsByClassName("disable-imgur")[0];
|
const disableImgurAllSites = allSites.getElementsByClassName("disable-imgur")[0]
|
||||||
|
|
||||||
const disableTiktokCurrentSite = currSite.getElementsByClassName("disable-tiktok")[0];
|
const disableTiktokCurrentSite = currSite.getElementsByClassName("disable-tiktok")[0]
|
||||||
const disableTiktokAllSites = allSites.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(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disableTwitter",
|
"disableTwitter",
|
||||||
"disableYoutube",
|
"disableYoutube",
|
||||||
"disableYoutubeMusic",
|
"disableYoutubeMusic",
|
||||||
"disableInstagram",
|
"disableInstagram",
|
||||||
"disableMaps",
|
"disableMaps",
|
||||||
"disableReddit",
|
"disableReddit",
|
||||||
"disableSearch",
|
"disableSearch",
|
||||||
"translateDisable",
|
"translateDisable",
|
||||||
"disableWikipedia",
|
"disableWikipedia",
|
||||||
"disableImgur",
|
"disableImgur",
|
||||||
"disableTiktok",
|
"disableTiktok",
|
||||||
"disableMedium",
|
"disableMedium",
|
||||||
"disableQuora",
|
"disableQuora",
|
||||||
"disableImdb",
|
"disableImdb",
|
||||||
"disableReuters",
|
"disableReuters",
|
||||||
"disablePeertubeTargets",
|
"disablePeertubeTargets",
|
||||||
"disableLbryTargets",
|
"disableLbryTargets",
|
||||||
"disableSendTarget",
|
"disableSendTarget",
|
||||||
"popupFrontends",
|
"popupFrontends",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
disableTwitterCurrentSite.checked = !r.disableTwitter; disableTwitterAllSites.checked = !r.disableTwitter;
|
disableTwitterCurrentSite.checked = !r.disableTwitter
|
||||||
disableYoutubeCurrentSite.checked = !r.disableYoutube; disableYoutubeAllSites.checked = !r.disableYoutube;
|
disableTwitterAllSites.checked = !r.disableTwitter
|
||||||
disableYoutubeMusicCurrentSite.checked = !r.disableYoutubeMusic; disableYoutubeMusicAllSites.checked = !r.disableYoutubeMusic;
|
disableYoutubeCurrentSite.checked = !r.disableYoutube
|
||||||
disableInstagramCurrentSite.checked = !r.disableInstagram; disableInstagramAllSites.checked = !r.disableInstagram;
|
disableYoutubeAllSites.checked = !r.disableYoutube
|
||||||
disableMapsCurrentSite.checked = !r.disableMaps; disableMapsAllSites.checked = !r.disableMaps;
|
disableYoutubeMusicCurrentSite.checked = !r.disableYoutubeMusic
|
||||||
disableRedditCurrentSite.checked = !r.disableReddit; disableRedditAllSites.checked = !r.disableReddit;
|
disableYoutubeMusicAllSites.checked = !r.disableYoutubeMusic
|
||||||
disableSearchCurrentSite.checked = !r.disableSearch; disableSearchAllSites.checked = !r.disableSearch;
|
disableInstagramCurrentSite.checked = !r.disableInstagram
|
||||||
disableTranslateCurrentSite.checked = !r.translateDisable; disableTranslateAllSites.checked = !r.translateDisable;
|
disableInstagramAllSites.checked = !r.disableInstagram
|
||||||
disableWikipediaCurrentSite.checked = !r.disableWikipedia; disableWikipediaAllSites.checked = !r.disableWikipedia;
|
disableMapsCurrentSite.checked = !r.disableMaps
|
||||||
disableImgurCurrentSite.checked = !r.disableImgur; disableImgurAllSites.checked = !r.disableImgur;
|
disableMapsAllSites.checked = !r.disableMaps
|
||||||
disableTiktokCurrentSite.checked = !r.disableTiktok; disableTiktokAllSites.checked = !r.disableTiktok;
|
disableRedditCurrentSite.checked = !r.disableReddit
|
||||||
disableMediumCurrentSite.checked = !r.disableMedium; disableMediumAllSites.checked = !r.disableMedium;
|
disableRedditAllSites.checked = !r.disableReddit
|
||||||
disableQuoraCurrentSite.checked = !r.disableQuora; disableQuoraAllSites.checked = !r.disableQuora;
|
disableSearchCurrentSite.checked = !r.disableSearch
|
||||||
disableImdbCurrentSite.checked = !r.disableImdb; disableImdbAllSites.checked = !r.disableImdb;
|
disableSearchAllSites.checked = !r.disableSearch
|
||||||
disableReutersCurrentSite.checked = !r.disableReuters; disableReutersAllSites.checked = !r.disableReuters;
|
disableTranslateCurrentSite.checked = !r.translateDisable
|
||||||
disablePeertubeTargetsCurrentSite.checked = !r.disablePeertubeTargets; disablePeertubeTargetsAllSites.checked = !r.disablePeertubeTargets;
|
disableTranslateAllSites.checked = !r.translateDisable
|
||||||
disableLbryTargetsCurrentSite.checked = !r.disableLbryTargets; disableLbryTargetsAllSites.checked = !r.disableLbryTargets;
|
disableWikipediaCurrentSite.checked = !r.disableWikipedia
|
||||||
disableSendTargetsCurrentSite.checked = !r.disableSendTarget; disableSendTargetsAllSites.checked = !r.disableSendTarget;
|
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 => {
|
browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
|
||||||
for (const frontend of generalHelper.allPopupFrontends) {
|
for (const frontend of generalHelper.allPopupFrontends) {
|
||||||
if (!r.popupFrontends.includes(frontend))
|
if (!r.popupFrontends.includes(frontend)) allSites.getElementsByClassName(frontend)[0].classList.add("hide")
|
||||||
allSites.getElementsByClassName(frontend)[0].classList.add("hide")
|
else allSites.getElementsByClassName(frontend)[0].classList.remove("hide")
|
||||||
else
|
currSite.getElementsByClassName(frontend)[0].classList.add("hide")
|
||||||
allSites.getElementsByClassName(frontend)[0].classList.remove("hide")
|
}
|
||||||
currSite.getElementsByClassName(frontend)[0].classList.add("hide")
|
|
||||||
}
|
|
||||||
|
|
||||||
let url;
|
let url
|
||||||
try { url = new URL(tabs[0].url); }
|
try {
|
||||||
catch {
|
url = new URL(tabs[0].url)
|
||||||
currentSiteIsFrontend.classList.add("hide")
|
} catch {
|
||||||
return;
|
currentSiteIsFrontend.classList.add("hide")
|
||||||
}
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (youtubeHelper.redirect(url, 'main_frame', false, true) || await youtubeHelper.switchInstance(url, 'main_frame', false, true)) {
|
if (youtubeMusicHelper.redirect(url, "main_frame", false, true) || (await youtubeMusicHelper.switchInstance(url, true))) {
|
||||||
currSite.getElementsByClassName('youtube')[0].classList.remove("hide");
|
currSite.getElementsByClassName("youtubeMusic")[0].classList.remove("hide")
|
||||||
allSites.getElementsByClassName('youtube')[0].classList.add("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))) {
|
||||||
else if (twitterHelper.redirect(url, 'main_frame', false, true) || await twitterHelper.switchInstance(url, 'main_frame', false, true)) {
|
currSite.getElementsByClassName("twitter")[0].classList.remove("hide")
|
||||||
currSite.getElementsByClassName('twitter')[0].classList.remove("hide");
|
allSites.getElementsByClassName("twitter")[0].classList.add("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")
|
||||||
else if (instagramHelper.redirect(url, 'main_frame', false, true) || await instagramHelper.switchInstance(url, 'main_frame', false, true)) {
|
allSites.getElementsByClassName("instagram")[0].classList.add("hide")
|
||||||
currSite.getElementsByClassName('instagram')[0].classList.remove("hide");
|
} else if (mapsHelper.redirect(url, false)) {
|
||||||
allSites.getElementsByClassName('instagram')[0].classList.add("hide");
|
currSite.getElementsByClassName("maps")[0].classList.remove("hide")
|
||||||
}
|
allSites.getElementsByClassName("maps")[0].classList.add("hide")
|
||||||
else if (mapsHelper.redirect(url, false)) {
|
} else if (redditHelper.redirect(url, "main_frame", false, true) || (await redditHelper.switchInstance(url, "main_frame", false, true))) {
|
||||||
currSite.getElementsByClassName('maps')[0].classList.remove("hide");
|
currSite.getElementsByClassName("reddit")[0].classList.remove("hide")
|
||||||
allSites.getElementsByClassName('maps')[0].classList.add("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))) {
|
||||||
else if (redditHelper.redirect(url, 'main_frame', false, true) || await redditHelper.switchInstance(url, 'main_frame', false, true)) {
|
currSite.getElementsByClassName("medium")[0].classList.remove("hide")
|
||||||
currSite.getElementsByClassName('reddit')[0].classList.remove("hide");
|
allSites.getElementsByClassName("medium")[0].classList.add("hide")
|
||||||
allSites.getElementsByClassName('reddit')[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")
|
||||||
else if (mediumHelper.redirect(url, 'main_frame', false, true) || await mediumHelper.switchInstance(url, 'main_frame', false, true)) {
|
allSites.getElementsByClassName("quora")[0].classList.add("hide")
|
||||||
currSite.getElementsByClassName('medium')[0].classList.remove("hide");
|
} else if (libremdbHelper.redirect(url, "main_frame", false, true) || (await libremdbHelper.switchInstance(url, "main_frame", false, true))) {
|
||||||
allSites.getElementsByClassName('medium')[0].classList.add("hide");
|
currSite.getElementsByClassName("imdb")[0].classList.remove("hide")
|
||||||
}
|
allSites.getElementsByClassName("imdb")[0].classList.add("hide")
|
||||||
else if (quoraHelper.redirect(url, 'main_frame', false, true) || await quoraHelper.switchInstance(url, 'main_frame', false, true)) {
|
} else if (reutersHelper.redirect(url, "main_frame", false, true)) {
|
||||||
currSite.getElementsByClassName('quora')[0].classList.remove("hide");
|
currSite.getElementsByClassName("reuters")[0].classList.remove("hide")
|
||||||
allSites.getElementsByClassName('quora')[0].classList.add("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))) {
|
||||||
else if (libremdbHelper.redirect(url, 'main_frame', false, true) || await libremdbHelper.switchInstance(url, 'main_frame', false, true)) {
|
currSite.getElementsByClassName("imgur")[0].classList.remove("hide")
|
||||||
currSite.getElementsByClassName('imdb')[0].classList.remove("hide");
|
allSites.getElementsByClassName("imgur")[0].classList.add("hide")
|
||||||
allSites.getElementsByClassName('imdb')[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")
|
||||||
else if (reutersHelper.redirect(url, 'main_frame', false, true)) {
|
allSites.getElementsByClassName("tiktok")[0].classList.add("hide")
|
||||||
currSite.getElementsByClassName('reuters')[0].classList.remove("hide");
|
} else if (sendTargetsHelper.redirect(url, "main_frame", false, true) || (await sendTargetsHelper.switchInstance(url, "main_frame", false, true))) {
|
||||||
allSites.getElementsByClassName('reuters')[0].classList.add("hide");
|
currSite.getElementsByClassName("sendTargets")[0].classList.remove("hide")
|
||||||
}
|
allSites.getElementsByClassName("sendTargets")[0].classList.add("hide")
|
||||||
else if (imgurHelper.redirect(url, 'main_frame', false, true) || await imgurHelper.switchInstance(url, 'main_frame', false, true)) {
|
} else if (peertubeHelper.redirect(url, "main_frame", false, true) || (await peertubeHelper.switchInstance(url, true))) {
|
||||||
currSite.getElementsByClassName('imgur')[0].classList.remove("hide");
|
currSite.getElementsByClassName("peertube")[0].classList.remove("hide")
|
||||||
allSites.getElementsByClassName('imgur')[0].classList.add("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))) {
|
||||||
else if (tiktokHelper.redirect(url, 'main_frame', false, true) || await tiktokHelper.switchInstance(url, 'main_frame', false, true)) {
|
currSite.getElementsByClassName("lbry")[0].classList.remove("hide")
|
||||||
currSite.getElementsByClassName('tiktok')[0].classList.remove("hide");
|
allSites.getElementsByClassName("lbry")[0].classList.add("hide")
|
||||||
allSites.getElementsByClassName('tiktok')[0].classList.add("hide");
|
} else if (translateHelper.redirect(url, true) || (await translateHelper.switchInstance(url, true))) {
|
||||||
}
|
currSite.getElementsByClassName("translate")[0].classList.remove("hide")
|
||||||
else if (sendTargetsHelper.redirect(url, 'main_frame', false, true) || await sendTargetsHelper.switchInstance(url, 'main_frame', false, true)) {
|
allSites.getElementsByClassName("translate")[0].classList.add("hide")
|
||||||
currSite.getElementsByClassName('sendTargets')[0].classList.remove("hide");
|
} else if (searchHelper.redirect(url, true) || (await searchHelper.switchInstance(url, true))) {
|
||||||
allSites.getElementsByClassName('sendTargets')[0].classList.add("hide");
|
currSite.getElementsByClassName("search")[0].classList.remove("hide")
|
||||||
}
|
allSites.getElementsByClassName("search")[0].classList.add("hide")
|
||||||
else if (peertubeHelper.redirect(url, 'main_frame', false, true) || await peertubeHelper.switchInstance(url, 'main_frame', false, true)) {
|
} else if (wikipediaHelper.redirect(url, true) || (await wikipediaHelper.switchInstance(url, true))) {
|
||||||
currSite.getElementsByClassName('peertube')[0].classList.remove("hide");
|
currSite.getElementsByClassName("wikipedia")[0].classList.remove("hide")
|
||||||
allSites.getElementsByClassName('peertube')[0].classList.add("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))) {
|
||||||
else if (lbryHelper.redirect(url, 'main_frame', false, true) || await lbryHelper.switchInstance(url, 'main_frame', false, true)) {
|
currSite.getElementsByClassName("youtube")[0].classList.remove("hide")
|
||||||
currSite.getElementsByClassName('lbry')[0].classList.remove("hide");
|
allSites.getElementsByClassName("youtube")[0].classList.add("hide")
|
||||||
allSites.getElementsByClassName('lbry')[0].classList.add("hide");
|
} else {
|
||||||
}
|
currentSiteIsFrontend.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")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
document.addEventListener("change", () => {
|
document.addEventListener("change", () => {
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
[
|
[
|
||||||
"disableTwitter",
|
"disableTwitter",
|
||||||
"disableYoutube",
|
"disableYoutube",
|
||||||
"disableYoutubeMusic",
|
"disableYoutubeMusic",
|
||||||
"disableInstagram",
|
"disableInstagram",
|
||||||
"disableMaps",
|
"disableMaps",
|
||||||
"disableReddit",
|
"disableReddit",
|
||||||
"disableSearch",
|
"disableSearch",
|
||||||
"translateDisable",
|
"translateDisable",
|
||||||
"disableWikipedia",
|
"disableWikipedia",
|
||||||
"disableImgur",
|
"disableImgur",
|
||||||
"disableTiktok",
|
"disableTiktok",
|
||||||
"disableMedium",
|
"disableMedium",
|
||||||
"disableQuora",
|
"disableQuora",
|
||||||
"disableImdb",
|
"disableImdb",
|
||||||
"disableReuters",
|
"disableReuters",
|
||||||
"disablePeertubeTargets",
|
"disablePeertubeTargets",
|
||||||
"disableLbryTargets",
|
"disableLbryTargets",
|
||||||
"disableSendTarget",
|
"disableSendTarget",
|
||||||
],
|
],
|
||||||
r => {
|
r => {
|
||||||
if (!r.disableTwitter != disableTwitterCurrentSite.checked) browser.storage.local.set({ disableTwitter: !disableTwitterCurrentSite.checked })
|
if (!r.disableTwitter != disableTwitterCurrentSite.checked)
|
||||||
else if (!r.disableTwitter != disableTwitterAllSites.checked) browser.storage.local.set({ disableTwitter: !disableTwitterAllSites.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 })
|
if (!r.disableYoutube != disableYoutubeCurrentSite.checked)
|
||||||
else if (!r.disableYoutube != disableYoutubeAllSites.checked) browser.storage.local.set({ disableYoutube: !disableYoutubeAllSites.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 })
|
if (!r.disableYoutubeMusic != disableYoutubeMusicCurrentSite.checked)
|
||||||
else if (!r.disableYoutubeMusic != disableYoutubeMusicAllSites.checked) browser.storage.local.set({ disableYoutubeMusic: !disableYoutubeMusicAllSites.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 })
|
if (!r.disableInstagram != disableInstagramCurrentSite.checked)
|
||||||
else if (!r.disableInstagram != disableInstagramAllSites.checked) browser.storage.local.set({ disableInstagram: !disableInstagramAllSites.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 })
|
if (!r.disableMaps != disableMapsCurrentSite.checked)
|
||||||
else if (!r.disableMaps != disableMapsAllSites.checked) browser.storage.local.set({ disableMaps: !disableMapsAllSites.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 })
|
if (!r.disableReddit != disableRedditCurrentSite.checked)
|
||||||
else if (!r.disableReddit != disableRedditAllSites.checked) browser.storage.local.set({ disableReddit: !disableRedditAllSites.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 })
|
if (!r.disableSearch != disableSearchCurrentSite.checked)
|
||||||
else if (!r.disableSearch != disableSearchAllSites.checked) browser.storage.local.set({ disableSearch: !disableSearchAllSites.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 })
|
if (!r.translateDisable != disableTranslateCurrentSite.checked)
|
||||||
else if (!r.translateDisable != disableTranslateAllSites.checked) browser.storage.local.set({ translateDisable: !disableTranslateAllSites.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 })
|
if (!r.disableWikipedia != disableWikipediaCurrentSite.checked)
|
||||||
else if (!r.disableWikipedia != disableWikipediaAllSites.checked) browser.storage.local.set({ disableWikipedia: !disableWikipediaAllSites.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 })
|
if (!r.disableImgur != disableImgurCurrentSite.checked)
|
||||||
else if (!r.disableImgur != disableImgurAllSites.checked) browser.storage.local.set({ disableImgur: !disableImgurAllSites.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 })
|
if (!r.disableTiktok != disableTiktokCurrentSite.checked)
|
||||||
else if (!r.disableTiktok != disableTiktokAllSites.checked) browser.storage.local.set({ disableTiktok: !disableTiktokAllSites.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 })
|
if (!r.disableMedium != disableMediumCurrentSite.checked)
|
||||||
else if (!r.disableMedium != disableMediumAllSites.checked) browser.storage.local.set({ disableMedium: !disableMediumAllSites.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 })
|
if (!r.disableQuora != disableQuoraCurrentSite.checked)
|
||||||
else if (!r.disableQuora != disableQuoraAllSites.checked) browser.storage.local.set({ disableQuora: !disableQuoraAllSites.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 })
|
if (!r.disableImdb != disableImdbCurrentSite.checked)
|
||||||
else if (!r.disableImdb != disableImdbAllSites.checked) browser.storage.local.set({ disableImdb: !disableImdbAllSites.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 })
|
if (!r.disableReuters != disableReutersCurrentSite.checked)
|
||||||
else if (!r.disableReuters != disableReutersAllSites.checked) browser.storage.local.set({ disableReuters: !disableReutersAllSites.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 })
|
if (!r.disablePeertubeTargets != disablePeertubeTargetsCurrentSite.checked)
|
||||||
else if (!r.disablePeertubeTargets != disablePeertubeTargetsAllSites.checked) browser.storage.local.set({ disablePeertubeTargets: !disablePeertubeTargetsAllSites.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 })
|
if (!r.disableLbryTargets != disableLbryTargetsCurrentSite.checked)
|
||||||
else if (!r.disableLbryTargets != disableLbryTargetsAllSites.checked) browser.storage.local.set({ disableLbryTargets: !disableLbryTargetsAllSites.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 })
|
if (!r.disableSendTarget != disableSendTargetsCurrentSite.checked)
|
||||||
else if (!r.disableSendTarget != disableSendTargetsAllSites.checked) browser.storage.local.set({ disableSendTarget: !disableSendTargetsAllSites.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')) {
|
for (const a of document.getElementsByTagName("a")) {
|
||||||
a.addEventListener('click', e => {
|
a.addEventListener("click", e => {
|
||||||
if (!a.classList.contains('prevent')) {
|
if (!a.classList.contains("prevent")) {
|
||||||
browser.tabs.create({ url: a.getAttribute('href') });
|
browser.tabs.create({ url: a.getAttribute("href") })
|
||||||
e.preventDefault();
|
e.preventDefault()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,24 @@
|
||||||
body {
|
body {
|
||||||
width: 230px;
|
width: 230px;
|
||||||
min-height: auto;
|
min-height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
html, body {
|
html,
|
||||||
margin: 0;
|
body {
|
||||||
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hide {
|
.hide {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.space {
|
.space {
|
||||||
height: 10px;
|
height: 10px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,465 +1,466 @@
|
||||||
body {
|
body {
|
||||||
--text: #fff;
|
--text: #fff;
|
||||||
--bg-main: #121212;
|
--bg-main: #121212;
|
||||||
--bg-secondary: #202020;
|
--bg-secondary: #202020;
|
||||||
--active: #fbc117;
|
--active: #fbc117;
|
||||||
--space: 5px;
|
--space: 5px;
|
||||||
--danger: #f04141;
|
--danger: #f04141;
|
||||||
--danger-light: #f9d0d5;
|
--danger-light: #f9d0d5;
|
||||||
--dark-grey: #767676;
|
--dark-grey: #767676;
|
||||||
--light-grey: #c3c3c3;
|
--light-grey: #c3c3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'Inter';
|
font-family: "Inter";
|
||||||
src: url('Inter-VariableFont_slnt,wght.ttf');
|
src: url("Inter-VariableFont_slnt,wght.ttf");
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'Vazirmatn';
|
font-family: "Vazirmatn";
|
||||||
src: url('Vazirmatn-VariableFont_wght.ttf');
|
src: url("Vazirmatn-VariableFont_wght.ttf");
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: auto;
|
margin: auto;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
font-family: 'Inter';
|
font-family: "Inter";
|
||||||
background-color: var(--bg-main);
|
background-color: var(--bg-main);
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
overflow-x: hidden
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.rtl {
|
body.rtl {
|
||||||
font-family: 'Vazirmatn';
|
font-family: "Vazirmatn";
|
||||||
/* line-height: 1; */
|
/* line-height: 1; */
|
||||||
}
|
}
|
||||||
|
|
||||||
div.some-block input[type="checkbox"] {
|
div.some-block input[type="checkbox"] {
|
||||||
appearance: none;
|
appearance: none;
|
||||||
-moz-appearance: none;
|
-moz-appearance: none;
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
img, svg {
|
img,
|
||||||
margin-right: 10px;
|
svg {
|
||||||
height: 26px;
|
margin-right: 10px;
|
||||||
width: 26px;
|
height: 26px;
|
||||||
color: var(--text);
|
width: 26px;
|
||||||
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
body.rtl img, body.rtl svg {
|
body.rtl img,
|
||||||
margin-right: 0px;
|
body.rtl svg {
|
||||||
margin-left: 10px;
|
margin-right: 0px;
|
||||||
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="url"],
|
input[type="url"],
|
||||||
input[type="text"],
|
input[type="text"],
|
||||||
select {
|
select {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-color: #767676;
|
border-color: #767676;
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
background-color: var(--bg-secondary);
|
background-color: var(--bg-secondary);
|
||||||
border: none;
|
border: none;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
max-width: 500px;
|
max-width: 500px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="url"],
|
input[type="url"],
|
||||||
input[type="text"] {
|
input[type="text"] {
|
||||||
width: 400px;
|
width: 400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input:invalid {
|
input:invalid {
|
||||||
color: var(--danger);
|
color: var(--danger);
|
||||||
border-color: var(--danger);
|
border-color: var(--danger);
|
||||||
}
|
}
|
||||||
|
|
||||||
.button svg {
|
.button svg {
|
||||||
height: 18px;
|
height: 18px;
|
||||||
width: 18px;
|
width: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
section.option-block {
|
section.option-block {
|
||||||
width: 750px;
|
width: 750px;
|
||||||
margin: 0 50px;
|
margin: 0 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
section.option-block h2 {
|
section.option-block h2 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.option {
|
body.option {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 40px;
|
padding: 40px;
|
||||||
width: 900px;
|
width: 900px;
|
||||||
}
|
}
|
||||||
|
|
||||||
section.links div {
|
section.links div {
|
||||||
margin: 20px 0;
|
margin: 20px 0;
|
||||||
width: max-content;
|
width: max-content;
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: var(--active);
|
color: var(--active);
|
||||||
}
|
}
|
||||||
|
|
||||||
section.links a {
|
section.links a {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: white;
|
color: white;
|
||||||
transition: 0.1s;
|
transition: 0.1s;
|
||||||
}
|
}
|
||||||
|
|
||||||
section.links a:hover,
|
section.links a:hover,
|
||||||
section.links a.selected {
|
section.links a.selected {
|
||||||
color: var(--active);
|
color: var(--active);
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="range"] {
|
input[type="range"] {
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
width: 350px;
|
width: 350px;
|
||||||
height: 7px;
|
height: 7px;
|
||||||
border-radius: 50px;
|
border-radius: 50px;
|
||||||
background: var(--text);
|
background: var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="range"]:hover {
|
input[type="range"]:hover {
|
||||||
background: var(--light-grey);
|
background: var(--light-grey);
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="range"]::-webkit-slider-thumb {
|
input[type="range"]::-webkit-slider-thumb {
|
||||||
appearance: none;
|
appearance: none;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: var(--active);
|
background: var(--active);
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="range"]::-moz-range-thumb {
|
input[type="range"]::-moz-range-thumb {
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: var(--active);
|
background: var(--active);
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
::placeholder {
|
::placeholder {
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
#volume-value {
|
#volume-value {
|
||||||
color: var(--active);
|
color: var(--active);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* \25BE */
|
/* \25BE */
|
||||||
|
|
||||||
hr {
|
hr {
|
||||||
height: 2px;
|
height: 2px;
|
||||||
margin: 0 15px;
|
margin: 0 15px;
|
||||||
background-color: rgb(77, 77, 77);
|
background-color: rgb(77, 77, 77);
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.some-block {
|
div.some-block {
|
||||||
padding: 0 15px;
|
padding: 0 15px;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.option-block {
|
div.option-block {
|
||||||
margin: 30px 0;
|
margin: 30px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
h4 {
|
h4 {
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.some-block h4 {
|
div.some-block h4 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.option-block h4 {
|
div.option-block h4 {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
width: 80%;
|
width: 80%;
|
||||||
min-width: 150px;
|
min-width: 150px;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.option-block h1 {
|
div.option-block h1 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
div.option-block div {
|
div.option-block div {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.some-block input[type="checkbox"] {
|
div.some-block input[type="checkbox"] {
|
||||||
width: 46px;
|
width: 46px;
|
||||||
height: 23px;
|
height: 23px;
|
||||||
background-color: var(--light-grey);
|
background-color: var(--light-grey);
|
||||||
border-radius: 50px;
|
border-radius: 50px;
|
||||||
transition: .4s;
|
transition: 0.4s;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.some-block input[type="checkbox"]:checked {
|
div.some-block input[type="checkbox"]:checked {
|
||||||
background-color: var(--active);
|
background-color: var(--active);
|
||||||
}
|
}
|
||||||
|
|
||||||
div.some-block input[type="checkbox"]::before {
|
div.some-block input[type="checkbox"]::before {
|
||||||
content: "";
|
content: "";
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 18px;
|
width: 18px;
|
||||||
height: 18px;
|
height: 18px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 2.5px;
|
top: 2.5px;
|
||||||
left: 3.5px;
|
left: 3.5px;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
transition: .3s;
|
transition: 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.rtl div.some-block input[type="checkbox"]::before {
|
body.rtl div.some-block input[type="checkbox"]::before {
|
||||||
left: auto;
|
left: auto;
|
||||||
right: 4px;
|
right: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.some-block input[type="checkbox"]:checked::before {
|
div.some-block input[type="checkbox"]:checked::before {
|
||||||
left: 24px;
|
left: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.rtl div.some-block input[type="checkbox"]:checked::before {
|
body.rtl div.some-block input[type="checkbox"]:checked::before {
|
||||||
left: auto;
|
left: auto;
|
||||||
right: 24px;
|
right: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.buttons {
|
div.buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin: 0 15px;
|
margin: 0 15px;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.buttons-popup {
|
div.buttons-popup {
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
margin: 0 10px 7px 10px;
|
margin: 0 10px 7px 10px;
|
||||||
justify-content: start;
|
justify-content: start;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition-duration: 0.1s;
|
transition-duration: 0.1s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button:hover {
|
.button:hover {
|
||||||
color: var(--active);
|
color: var(--active);
|
||||||
}
|
}
|
||||||
|
|
||||||
.button svg {
|
.button svg {
|
||||||
width: auto;
|
width: auto;
|
||||||
height: auto;
|
height: auto;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button:hover svg {
|
.button:hover svg {
|
||||||
color: var(--active);
|
color: var(--active);
|
||||||
}
|
}
|
||||||
|
|
||||||
div.buttons-inline {
|
div.buttons-inline {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: start;
|
justify-content: start;
|
||||||
/* padding: 0 15px; */
|
/* padding: 0 15px; */
|
||||||
}
|
}
|
||||||
|
|
||||||
.button-inline {
|
.button-inline {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin: 7.5px 0;
|
margin: 7.5px 0;
|
||||||
background-color: var(--bg-secondary);
|
background-color: var(--bg-secondary);
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button:active {
|
.button:active {
|
||||||
transform: translateY(1px);
|
transform: translateY(1px);
|
||||||
}
|
}
|
||||||
|
|
||||||
button.default {
|
button.default {
|
||||||
margin-left: 30px;
|
margin-left: 30px;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
color: white;
|
color: white;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
width: 34px;
|
width: 34px;
|
||||||
height: 34px;
|
height: 34px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
margin: 4px 2px;
|
margin: 4px 2px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
button svg {
|
button svg {
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
div.checklist{
|
div.checklist {
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.checklist div {
|
div.checklist div {
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin: 5px 15px;
|
margin: 5px 15px;
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
div.checklist a {
|
div.checklist a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
div.checklist a:hover {
|
div.checklist a:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.checklist-popup div {
|
div.checklist-popup div {
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin: 5px 15px;
|
margin: 5px 15px;
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
max-width: 200px;
|
max-width: 200px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.checklist-popup div div {
|
div.checklist-popup div div {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
button.add {
|
button.add {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.disabled {
|
div.disabled {
|
||||||
background-color: rgb(39, 39, 39);
|
background-color: rgb(39, 39, 39);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.light-theme.popup,
|
.light-theme.popup,
|
||||||
.light-theme .popup {
|
.light-theme .popup {
|
||||||
background-color: var(--bg-secondary);
|
background-color: var(--bg-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
body.light-theme {
|
body.light-theme {
|
||||||
--text: black;
|
--text: black;
|
||||||
--bg-main: white;
|
--bg-main: white;
|
||||||
--bg-secondary: #fff;
|
--bg-secondary: #fff;
|
||||||
--active: #fb9817;
|
--active: #fb9817;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.light-theme select {
|
body.light-theme select {
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.light-theme textarea {
|
body.light-theme textarea {
|
||||||
color: black;
|
color: black;
|
||||||
border: 1px solid #767676;
|
border: 1px solid #767676;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.light-theme textarea:focus {
|
body.light-theme textarea:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.light-theme a {
|
body.light-theme a {
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
section.general {
|
section.general {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
section.general div {
|
section.general div {
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#customize-popup {
|
#customize-popup {
|
||||||
width: 250px;
|
width: 250px;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
background-color:transparent;
|
background-color: transparent;
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
border: none;
|
border: none;
|
||||||
padding: 10px 5px;
|
padding: 10px 5px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
body div section {
|
body div section {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.about > div{
|
div.about > div {
|
||||||
justify-content: start;
|
justify-content: start;
|
||||||
width: 520px;
|
width: 520px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.about h4 {
|
div.about h4 {
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
ignoreFiles: [
|
ignoreFiles: ["instances/get_instances.py"],
|
||||||
"instances/get_instances.py"
|
}
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in New Issue