user.js
50 lines · 1603 bytes
1// ==UserScript==
2// @name Redirect to Privacy-Friendly Frontends
3// @version 1.3
4// @description Redirect supported websites to alternative frontend instances
5// @match *://*.reddit.com/*
6// @match *://*.youtube.com/*
7// @match *://*.imgur.com/*
8// @match *://*.pinterest.com/*
9// @match *://*.instagram.com/*
10// @match *://*.wikipedia.org/*
11// @match *://*.medium.com/*
12// @match *://*.gelbooru.com/*
13// @match *://*.github.com/*
14// @run-at document-start
15// @grant none
16// ==/UserScript==
17
18(() => {
19 'use strict';
20
21 const redirects = {
22 'reddit.com': 'redlib.thepixora.com',
23 'youtube.com': 'inv.miningtcup.me',
24 'imgur.com': 'rimgo.nadeko.net',
25 'pinterest.com': 'binternet.nadeko.net',
26 'instagram.com': 'kittygram.nadeko.net',
27 'wikipedia.org': 'wikiless.miningtcup.me',
28 'medium.com': 'scribe.privacyredirect.com',
29 'gelbooru.com': 'gel.nadeko.net',
30 'github.com': 'gothub.libre.tw'
31 };
32
33 const hostname = location.hostname.toLowerCase();
34
35 // Match the domain itself and any of its subdomains.
36 const sourceDomain = Object.keys(redirects).find(domain =>
37 hostname === domain || hostname.endsWith(`.${domain}`)
38 );
39
40 if (!sourceDomain) return;
41
42 const targetHost = redirects[sourceDomain];
43
44 // Preserve the path, query string, and fragment.
45 const targetUrl =
46 `${location.protocol}//${targetHost}${location.pathname}${location.search}${location.hash}`;
47
48 location.replace(targetUrl);
49})();
50