Add Wikipedia redirection
This commit is contained in:
parent
3fe35a2f2f
commit
b8dfe25ee0
2 changed files with 35 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue