Add Wikipedia redirection

This commit is contained in:
Ahmet Arda Kavakci 2022-04-23 00:01:44 +03:00
parent 3fe35a2f2f
commit b8dfe25ee0
No known key found for this signature in database
GPG key ID: 80860C9FC6584220
2 changed files with 35 additions and 1 deletions

View file

@ -21,7 +21,7 @@ __Why Bibliogram doesn't load the full profile?__
> [Future of Bibliogram by Cadence Ember](https://proxy.vulpes.one/gemini/cadence.moe/gemlog/2020-12-17-future-of-bibliogram.bliz)
## To-do
- [ ] Add [Wikiless](https://codeberg.org/orenom/wikiless) with multiple instances (NSA here, NSA there)
- [x] Add [Wikiless](https://codeberg.org/orenom/wikiless) with multiple instances (NSA here, NSA there)
- [x] Redirect Medium user pages to Medium itself without giving an error
- [x] Delete `?hl=<langcode>` query when redirecting to Lingva.
- [x] Use random instances for Nitter, Reddit, Invidious, Rimgo and Lingva

View file

@ -26,6 +26,7 @@
// @match *://translate.google.com/*
// @match *://news.ycombinator.com/*
// @match *://*.reuters.com/*
// @match *://*.wikipedia.org/*
// ==/UserScript==
/*
@ -48,6 +49,7 @@ var redirect_medium = true;
var redirect_hackernews = true;
var redirect_gtranslate = true;
var redirect_reuters = true;
var redirect_wikipedia = true;
// // // // // // // // // // // // //
@ -292,6 +294,36 @@ function redirectReuters() {
location.hostname = "neuters.de";
}
function redirectWikipedia() {
if (redirect_wikipedia == false) {
return;
}
let wikilessInstances = [
'wikiless.org',
'wikiless.alefvanoon.xyz',
'wikiless.sethforprivacy.com',
'wiki.604kph.xyz',
'wiki.froth.zone'
];
let randomInstance = Math.floor(Math.random()*wikilessInstances.length);
let hostnameVar = window.location.hostname
let langCodeIndex = hostnameVar.search(/^[a-z][a-z]\./)
let langCode = hostnameVar[langCodeIndex] + hostnameVar[langCodeIndex + 1];
window.stop();
if (langCodeIndex != -1) {
let newURL = window.location.protocol + "//" + wikilessInstances[randomInstance] + window.location.pathname + "?lang=" + langCode + window.location.hash;
window.location.replace(newURL);
} else {
let newURL = window.location.protocol + "//" + wikilessInstances[randomInstance] + window.location.pathname + "?lang=en" + window.location.hash;
window.location.replace(newURL);
}
}
var urlHostname = window.location.hostname;
switch (urlHostname) {
@ -340,4 +372,6 @@ if (urlHostname.includes("medium.com")) {
redirectMedium();
} else if (urlHostname.includes("imgur.com")) {
redirectImgur();
} else if (urlHostname.includes("wikipedia.org")) {
redirectWikipedia();
}