Added rimgo will improve on it #24
This commit is contained in:
parent
f99b6e3538
commit
6fb346569f
|
@ -0,0 +1,114 @@
|
|||
import commonHelper from './common.js'
|
||||
|
||||
const targets = [
|
||||
/^https?:\/\/(i|).?imgur.com/
|
||||
];
|
||||
|
||||
let redirects = {
|
||||
"rimgo": {
|
||||
"normal": [
|
||||
"https://i.bcow.xyz",
|
||||
"https://rimgo.bcow.xyz",
|
||||
"https://rimgo.pussthecat.org",
|
||||
"https://img.riverside.rocks",
|
||||
"https://rimgo.totaldarkness.net",
|
||||
"https://rimgo.bus-hit.me"
|
||||
],
|
||||
"onion": [
|
||||
"http://l4d4owboqr6xcmd6lf64gbegel62kbudu3x3jnldz2mx6mhn3bsv3zyd.onion",
|
||||
"http://jx3dpcwedpzu2mh54obk5gvl64i2ln7pt5mrzd75s4jnndkqwzaim7ad.onion"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
const getRedirects = () => redirects;
|
||||
function setRedirects(val) {
|
||||
redirects.rimgo = val;
|
||||
browser.storage.sync.set({ imgurRedirects: redirects })
|
||||
console.log("imgurRedirects: ", val)
|
||||
for (const item of rimgoRedirectsChecks)
|
||||
if (!redirects.rimgo.normal.includes(item)) {
|
||||
var index = rimgoRedirectsChecks.indexOf(item);
|
||||
if (index !== -1) rimgoRedirectsChecks.splice(index, 1);
|
||||
}
|
||||
setRimgoRedirectsChecks(rimgoRedirectsChecks);
|
||||
}
|
||||
|
||||
let rimgoRedirectsChecks;
|
||||
const getRimgoRedirectsChecks = () => rimgoRedirectsChecks;
|
||||
function setRimgoRedirectsChecks(val) {
|
||||
rimgoRedirectsChecks = val;
|
||||
browser.storage.sync.set({ rimgoRedirectsChecks })
|
||||
console.log("rimgoRedirectsChecks: ", val)
|
||||
}
|
||||
|
||||
let rimgoCustomRedirects = [];
|
||||
const getRimgoCustomRedirects = () => rimgoCustomRedirects;
|
||||
function setRimgoCustomRedirects(val) {
|
||||
rimgoCustomRedirects = val;
|
||||
browser.storage.sync.set({ rimgoCustomRedirects })
|
||||
console.log("rimgoCustomRedirects: ", val)
|
||||
}
|
||||
|
||||
let disableImgur;
|
||||
const getDisableImgur = () => disableImgur;
|
||||
function setDisableImgur(val) {
|
||||
disableImgur = val;
|
||||
browser.storage.sync.set({ disableImgur })
|
||||
}
|
||||
|
||||
function redirect(url, initiator, type) {
|
||||
|
||||
if (disableImgur) return null;
|
||||
|
||||
if (url.pathname == "/") return null;
|
||||
|
||||
if (type != "main_frame" && "sub_frame" && "xmlhttprequest" && "other") return null;
|
||||
|
||||
let instancesList = [...rimgoRedirectsChecks, ...rimgoCustomRedirects];
|
||||
if (instancesList.length === 0) return null;
|
||||
let randomInstance = commonHelper.getRandomInstance(instancesList)
|
||||
|
||||
if (initiator && (instancesList.includes(initiator.origin) || targets.includes(initiator.host))) return null;
|
||||
|
||||
return `${randomInstance}${url.pathname}${url.search}`;
|
||||
}
|
||||
|
||||
function isImgur(url) {
|
||||
return targets.some((rx) => rx.test(url.href));
|
||||
}
|
||||
|
||||
async function init() {
|
||||
let result = await browser.storage.sync.get([
|
||||
"disableImgur",
|
||||
"imgurRedirects",
|
||||
"rimgoRedirectsChecks",
|
||||
"rimgoCustomRedirects",
|
||||
])
|
||||
disableImgur = result.disableImgur ?? false;
|
||||
if (result.imgurRedirects)
|
||||
redirects = result.imgurRedirects;
|
||||
|
||||
rimgoRedirectsChecks = result.rimgoRedirectsChecks ?? [...redirects.rimgo.normal];
|
||||
rimgoCustomRedirects = result.rimgoCustomRedirects ?? [];
|
||||
}
|
||||
|
||||
export default {
|
||||
targets,
|
||||
|
||||
getRedirects,
|
||||
setRedirects,
|
||||
|
||||
getDisableImgur,
|
||||
setDisableImgur,
|
||||
|
||||
getRimgoRedirectsChecks,
|
||||
setRimgoRedirectsChecks,
|
||||
|
||||
getRimgoCustomRedirects,
|
||||
setRimgoCustomRedirects,
|
||||
|
||||
redirect,
|
||||
isImgur,
|
||||
init,
|
||||
};
|
|
@ -89,7 +89,7 @@ function redirect(url, initiator, type) {
|
|||
}
|
||||
|
||||
function isMedium(url) {
|
||||
return targets.some((rx) => rx.test(url.href));
|
||||
return targets.some((rx) => rx.test(url.host));
|
||||
}
|
||||
|
||||
async function init() {
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
let redirects = {
|
||||
"normal": [
|
||||
"https://i.bcow.xyz",
|
||||
"https://rimgo.bcow.xyz",
|
||||
"https://rimgo.pussthecat.org",
|
||||
"https://img.riverside.rocks",
|
||||
"https://rimgo.totaldarkness.net",
|
||||
"https://rimgo.bus-hit.me"
|
||||
],
|
||||
"onion": [
|
||||
"http://l4d4owboqr6xcmd6lf64gbegel62kbudu3x3jnldz2mx6mhn3bsv3zyd.onion",
|
||||
"http://jx3dpcwedpzu2mh54obk5gvl64i2ln7pt5mrzd75s4jnndkqwzaim7ad.onion"
|
||||
]
|
||||
}
|
|
@ -9,6 +9,7 @@ import translateHelper from "../../assets/javascripts/helpers/translate.js";
|
|||
import mapsHelper from "../../assets/javascripts/helpers/maps.js";
|
||||
import wikipediaHelper from "../../assets/javascripts/helpers/wikipedia.js";
|
||||
import mediumHelper from "../../assets/javascripts/helpers/medium.js";
|
||||
import imgurHelper from "../../assets/javascripts/helpers/imgur.js";
|
||||
|
||||
window.browser = window.browser || window.chrome;
|
||||
|
||||
|
@ -22,6 +23,7 @@ function wholeInit() {
|
|||
twitterHelper.init()
|
||||
wikipediaHelper.init()
|
||||
youtubeHelper.init()
|
||||
imgurHelper.init()
|
||||
}
|
||||
|
||||
wholeInit();
|
||||
|
@ -51,6 +53,8 @@ browser.webRequest.onBeforeRequest.addListener(
|
|||
|
||||
else if (mediumHelper.isMedium(url)) newUrl = mediumHelper.redirect(url, initiator, details.type);
|
||||
|
||||
else if (imgurHelper.isImgur(url)) newUrl = imgurHelper.redirect(url, initiator, details.type);
|
||||
|
||||
else if (translateHelper.isTranslate(url)) newUrl = translateHelper.redirect(url, initiator);
|
||||
|
||||
else if (searchHelper.isSearch(url)) newUrl = searchHelper.redirect(url, initiator)
|
||||
|
@ -92,24 +96,25 @@ browser.tabs.onUpdated.addListener((tabId, changeInfo, _) => {
|
|||
mightyList.push(
|
||||
...youtubeHelper.getRedirects().invidious.normal,
|
||||
...youtubeHelper.getRedirects().piped.normal,
|
||||
|
||||
|
||||
...twitterHelper.getRedirects().nitter.normal,
|
||||
|
||||
...instagramHelper.getRedirects().bibliogram.normal,
|
||||
|
||||
|
||||
...redditHelper.getRedirects().libreddit.normal,
|
||||
...redditHelper.getRedirects().teddit.normal,
|
||||
redditHelper.getRedirects().desktop,
|
||||
redditHelper.getRedirects().mobile,
|
||||
|
||||
|
||||
...searchHelper.getRedirects().searx.normal,
|
||||
...searchHelper.getRedirects().whoogle.normal,
|
||||
|
||||
|
||||
...translateHelper.getRedirects().simplyTranslate.normal,
|
||||
...translateHelper.getRedirects().lingva.normal,
|
||||
|
||||
|
||||
...mediumHelper.getRedirects().scribe.normal,
|
||||
|
||||
...imgurHelper.getRedirects().rimgo.normal,
|
||||
|
||||
...wikipediaHelper.getRedirects().wikiless.normal
|
||||
);
|
||||
|
||||
|
@ -128,9 +133,9 @@ browser.pageAction.onClicked.addListener((tab) => {
|
|||
)
|
||||
newUrl = 'https://youtube.com';
|
||||
|
||||
if (twitterHelper.getRedirects().normal.includes(protocolHost)) newUrl = 'https://twitter.com';
|
||||
if (twitterHelper.getRedirects().nitter.normal.includes(protocolHost)) newUrl = 'https://twitter.com';
|
||||
|
||||
if (instagramHelper.getRedirects().normal.includes(protocolHost)) newUrl = 'https://instagram.com';
|
||||
if (instagramHelper.getRedirects().bibliogram.normal.includes(protocolHost)) newUrl = 'https://instagram.com';
|
||||
|
||||
if (redditHelper.getRedirects().libreddit.normal.includes(protocolHost) || redditHelper.getRedirects().teddit.normal.includes(protocolHost)) {
|
||||
if (tabUrl.pathname.startsWith('/img')) {
|
||||
|
@ -151,9 +156,11 @@ browser.pageAction.onClicked.addListener((tab) => {
|
|||
translateHelper.getRedirects().lingva.normal.includes(protocolHost)
|
||||
) newUrl = 'https://translate.google.com';
|
||||
|
||||
if (mediumHelper.getRedirects().normal.includes(protocolHost)) newUrl = 'https://medium.com';
|
||||
if (mediumHelper.getRedirects().scribe.normal.includes(protocolHost)) newUrl = 'https://medium.com';
|
||||
|
||||
if (wikipediaHelper.getRedirects().normal.includes(protocolHost)) newUrl = 'https://wikipedia.com';
|
||||
if (imgurHelper.getRedirects().rimgo.normal.includes(protocolHost)) newUrl = 'https://imgur.com';
|
||||
|
||||
if (wikipediaHelper.getRedirects().wikiless.normal.includes(protocolHost)) newUrl = 'https://wikipedia.com';
|
||||
|
||||
if (newUrl) browser.tabs.update({ url: tabUrl.href.replace(protocolHost, newUrl) });
|
||||
});
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<a href="../translate/translate.html">Translate</a>
|
||||
<a href="../maps/maps.html">Maps</a>
|
||||
<a href="../wikipedia/wikipedia.html">Wikipedia</a>
|
||||
<a href="../imgur/imgur.html">Imgur</a>
|
||||
<a href="../medium/medium.html">Medium</a>
|
||||
</section>
|
||||
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/x-icon" href="../../../assets/images/libredirect.svg" />
|
||||
<link href="../../stylesheets/styles.css" rel="stylesheet" />
|
||||
<title>LibRedirect options: Twitter</title>
|
||||
</head>
|
||||
|
||||
<body class="option">
|
||||
<section class="links">
|
||||
<a href="../general/general.html">General</a>
|
||||
<a href="../youtube/youtube.html">Youtube</a>
|
||||
<a href="../twitter/twitter.html">Twitter</a>
|
||||
<a href="../instagram/instagram.html">Instagram</a>
|
||||
<a href="../reddit/reddit.html">Reddit</a>
|
||||
<a href="../search/search.html">Search</a>
|
||||
<a href="../translate/translate.html">Translate</a>
|
||||
<a href="../maps/maps.html">Maps</a>
|
||||
<a href="../wikipedia/wikipedia.html">Wikipedia</a>
|
||||
<a href="../imgur/imgur.html" class="selected">Imgur</a>
|
||||
<a href="medium.html">Medium</a>
|
||||
</section>
|
||||
|
||||
<section class="option-block">
|
||||
<div class="some-block option-block">
|
||||
<h4>Enable</h4>
|
||||
<input id="disable-imgur" type="checkbox" checked />
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="some-block option-block">
|
||||
<h4>Default Instances</h4>
|
||||
</div>
|
||||
<div class="checklist" id="rimgo-checklist"></div>
|
||||
<hr>
|
||||
<div class="some-block option-block">
|
||||
<h4>Custom Instances</h4>
|
||||
</div>
|
||||
<form id="custom-rimgo-instance-form">
|
||||
<div class="some-block option-block">
|
||||
<input id="rimgo-custom-instance" placeholder="https://rimgo.com" type="url" />
|
||||
<button type="submit" class="add" id="rimgo-add-instance">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px"
|
||||
fill="currentColor">
|
||||
<path d="M0 0h24v24H0V0z" fill="none" />
|
||||
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="checklist" id="rimgo-custom-checklist"></div>
|
||||
</section>
|
||||
|
||||
|
||||
<script type="module" src="../init.js"></script>
|
||||
<script type="module" src="./imgur.js"></script>
|
||||
<!-- <script src="../../assets/javascripts/localise.js"></script> -->
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,21 @@
|
|||
import imgurHelper from "../../../assets/javascripts/helpers/imgur.js";
|
||||
import commonHelper from "../../../assets/javascripts/helpers/common.js";
|
||||
|
||||
let disableImgurElement = document.getElementById("disable-imgur");
|
||||
disableImgurElement.addEventListener("change",
|
||||
(event) => imgurHelper.setDisableImgur(!event.target.checked)
|
||||
);
|
||||
|
||||
imgurHelper.init().then(() => {
|
||||
disableImgurElement.checked = !imgurHelper.getDisableImgur();
|
||||
|
||||
commonHelper.processDefaultCustomInstances(
|
||||
'rimgo',
|
||||
imgurHelper,
|
||||
document,
|
||||
imgurHelper.getRimgoRedirectsChecks,
|
||||
imgurHelper.setRimgoRedirectsChecks,
|
||||
imgurHelper.getRimgoCustomRedirects,
|
||||
imgurHelper.setRimgoCustomRedirects
|
||||
)
|
||||
})
|
|
@ -21,6 +21,7 @@
|
|||
<a href="../translate/translate.html">Translate</a>
|
||||
<a href="../maps/maps.html">Maps</a>
|
||||
<a href="../wikipedia/wikipedia.html">Wikipedia</a>
|
||||
<a href="../imgur/imgur.html">Imgur</a>
|
||||
<a href="../medium/medium.html">Medium</a>
|
||||
</section>
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
<a href="../translate/translate.html">Translate</a>
|
||||
<a href="maps.html" class="selected">Maps</a>
|
||||
<a href="../wikipedia/wikipedia.html">Wikipedia</a>
|
||||
<a href="../imgur/imgur.html">Imgur</a>
|
||||
<a href="../medium/medium.html">Medium</a>
|
||||
</section>
|
||||
|
||||
|
|
|
@ -21,13 +21,14 @@
|
|||
<a href="../translate/translate.html">Translate</a>
|
||||
<a href="../maps/maps.html">Maps</a>
|
||||
<a href="../wikipedia/wikipedia.html">Wikipedia</a>
|
||||
<a href="../imgur/imgur.html">Imgur</a>
|
||||
<a href="medium.html" class="selected">Medium</a>
|
||||
</section>
|
||||
|
||||
<section class="option-block">
|
||||
<div class="some-block option-block">
|
||||
<h4>Enable</h4>
|
||||
<input id="disable-scribe" type="checkbox" checked />
|
||||
<input id="disable-medium" type="checkbox" checked />
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import mediumHelper from "../../../assets/javascripts/helpers/medium.js";
|
||||
import commonHelper from "../../../assets/javascripts/helpers/common.js";
|
||||
|
||||
let disableMediumElement = document.getElementById("disable-scribe");
|
||||
let disableMediumElement = document.getElementById("disable-medium");
|
||||
disableMediumElement.addEventListener("change",
|
||||
(event) => mediumHelper.setDisableMedium(!event.target.checked)
|
||||
);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<a href="../translate/translate.html">Translate</a>
|
||||
<a href="../maps/maps.html">Maps</a>
|
||||
<a href="../wikipedia/wikipedia.html">Wikipedia</a>
|
||||
<a href="../imgur/imgur.html">Imgur</a>
|
||||
<a href="../medium/medium.html">Medium</a>
|
||||
</section>
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<a href="../translate/translate.html">Translate</a>
|
||||
<a href="../maps/maps.html">Maps</a>
|
||||
<a href="../wikipedia/wikipedia.html">Wikipedia</a>
|
||||
<a href="../imgur/imgur.html">Imgur</a>
|
||||
<a href="../medium/medium.html">Medium</a>
|
||||
</section>
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<a href="translate.html" class="selected">Translate</a>
|
||||
<a href="../maps/maps.html">Maps</a>
|
||||
<a href="../wikipedia/wikipedia.html">Wikipedia</a>
|
||||
<a href="../imgur/imgur.html">Imgur</a>
|
||||
<a href="../medium/medium.html">Medium</a>
|
||||
</section>
|
||||
<section class="option-block">
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
<a href="../translate/translate.html">Translate</a>
|
||||
<a href="../maps/maps.html">Maps</a>
|
||||
<a href="../wikipedia/wikipedia.html">Wikipedia</a>
|
||||
<a href="../imgur/imgur.html">Imgur</a>
|
||||
<a href="../medium/medium.html">Medium</a>
|
||||
</section>
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<a href="../translate/translate.html">Translate</a>
|
||||
<a href="../maps/maps.html">Maps</a>
|
||||
<a href="../wikipedia/wikipedia.html" class="selected">Wikipedia</a>
|
||||
<a href="../imgur/imgur.html">Imgur</a>
|
||||
<a href="../medium/medium.html">Medium</a>
|
||||
</section>
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
<a href="../translate/translate.html">Translate</a>
|
||||
<a href="../maps/maps.html">Maps</a>
|
||||
<a href="../wikipedia/wikipedia.html">Wikipedia</a>
|
||||
<a href="../imgur/imgur.html">Imgur</a>
|
||||
<a href="../medium/medium.html">Medium</a>
|
||||
</section>
|
||||
|
||||
|
|
|
@ -49,9 +49,14 @@
|
|||
<input id="disable-wikipedia" type="checkbox" checked />
|
||||
</div>
|
||||
|
||||
<div class="some-block">
|
||||
<h4>Imgur</h4>
|
||||
<input id="disable-imgur" type="checkbox" checked />
|
||||
</div>
|
||||
|
||||
<div class="some-block">
|
||||
<h4>Medium</h4>
|
||||
<input id="disable-scribe" type="checkbox" checked />
|
||||
<input id="disable-medium" type="checkbox" checked />
|
||||
</div>
|
||||
|
||||
<div class="buttons">
|
||||
|
|
|
@ -11,6 +11,7 @@ import searchHelper from "../../assets/javascripts/helpers/search.js";
|
|||
import translateHelper from "../../assets/javascripts/helpers/translate.js";
|
||||
import wikipediaHelper from "../../assets/javascripts/helpers/wikipedia.js";
|
||||
import mediumHelper from "../../assets/javascripts/helpers/medium.js";
|
||||
import imgurHelper from "../../assets/javascripts/helpers/imgur.js";
|
||||
|
||||
let disableTwitterElement = document.querySelector("#disable-nitter");
|
||||
let disableYoutubeElement = document.querySelector("#disable-invidious");
|
||||
|
@ -20,7 +21,8 @@ let disableRedditElement = document.querySelector("#disable-reddit");
|
|||
let disableSearchElement = document.querySelector("#disable-search");
|
||||
let disableTranslateElement = document.querySelector("#disable-simplyTranslate");
|
||||
let disableWikipediaElement = document.querySelector("#disable-wikipedia");
|
||||
let disableMediumElement = document.querySelector("#disable-scribe");
|
||||
let disableMediumElement = document.querySelector("#disable-medium");
|
||||
let disableImgurElement = document.querySelector("#disable-imgur");
|
||||
|
||||
window.browser = window.browser || window.chrome;
|
||||
|
||||
|
@ -33,6 +35,7 @@ async function wholeInit() {
|
|||
await searchHelper.init();
|
||||
await translateHelper.init();
|
||||
await wikipediaHelper.init();
|
||||
await imgurHelper.init();
|
||||
await mediumHelper.init();
|
||||
};
|
||||
|
||||
|
@ -46,6 +49,7 @@ wholeInit().then(() => {
|
|||
disableSearchElement.checked = !searchHelper.getDisableSearch();
|
||||
disableTranslateElement.checked = !translateHelper.getDisableTranslate();
|
||||
disableWikipediaElement.checked = !wikipediaHelper.getDisableWikipedia();
|
||||
disableImgurElement.checked = !imgurHelper.getDisableImgur();
|
||||
disableMediumElement.checked = !mediumHelper.getDisableMedium();
|
||||
})
|
||||
|
||||
|
@ -81,6 +85,10 @@ disableWikipediaElement.addEventListener("change",
|
|||
(event) => wikipediaHelper.setDisableWikipedia(!event.target.checked)
|
||||
);
|
||||
|
||||
disableImgurElement.addEventListener("change",
|
||||
(event) => imgurHelper.setDisableImgur(!event.target.checked)
|
||||
);
|
||||
|
||||
disableMediumElement.addEventListener("change",
|
||||
(event) => mediumHelper.setDisableMedium(!event.target.checked)
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue