Frontend-Redirectr

Redirect popular sites to alternative privacy-friendly frontends

Vous devrez installer une extension telle que Tampermonkey, Greasemonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Userscripts pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey pour installer ce script.

Vous devrez installer une extension de gestionnaire de script utilisateur pour installer ce script.

(J'ai déjà un gestionnaire de scripts utilisateur, laissez-moi l'installer !)

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

(J'ai déjà un gestionnaire de style utilisateur, laissez-moi l'installer!)

// ==UserScript==
// @name         Frontend-Redirectr
// @namespace    https://github.com/NimiGames68/Frontend-Redirectr
// @version      1.0
// @description  Redirect popular sites to alternative privacy-friendly frontends
// @license      MIT
// @author       NimiGames68
// @match        *://genius.com/*
// @match        *://*.genius.com/*
// @match        *://imgur.com/*
// @match        *://*.imgur.com/*
// @match        *://medium.com/*
// @match        *://*.medium.com/*
// @match        *://pastebin.com/*
// @match        *://*.pastebin.com/*
// @match        *://*.pinterest.com/*
// @match        *://tenor.com/*
// @match        *://*.tenor.com/*
// @match        *://twitch.tv/*
// @match        *://*.twitch.tv/*
// @match        *://music.youtube.com/*
// @match        *://youtube.com/*
// @match        *://*.youtube.com/*
// @match        *://youtu.be/*
// @match        *://translate.google.com/*
// @include      /^https?:\/\/translate\.google\.[^/]+\/.*/
// @match        *://*.stackexchange.com/*
// @match        *://*.stackoverflow.com/*
// @match        *://*.superuser.com/*
// @match        *://*.serverfault.com/*
// @match        *://*.askubuntu.com/*
// @match        *://*.stackapps.com/*
// @match        *://*.mathoverflow.net/*
// @match        *://*.bing.com/*
// @match        *://*.tumblr.com/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function () {
    'use strict';

    const host = location.hostname;

    // Google Translate → Mozhi
    if (/^translate\.google\.[^/]+$/i.test(host)) {
        location.replace(
            "https://mozhi.canine.tools" +
            location.pathname +
            location.search +
            location.hash
        );
        return;
    }

    // YouTube Music → Ytify
    if (/^music\.youtube\.com$/i.test(host)) {
        const videoId = new URLSearchParams(location.search).get('v');

        location.replace(
            videoId
                ? `https://ytify.pp.ua/?s=${encodeURIComponent(videoId)}`
                : 'https://ytify.pp.ua/'
        );
        return;
    }

    // YouTube → Invidious
    if (/^(www\.)?youtube\.com$/i.test(host)) {
        location.replace(
            "https://inv.nadeko.net" +
            location.pathname +
            location.search +
            location.hash
        );
        return;
    }

    // youtu.be → Invidious
    if (/^youtu\.be$/i.test(host)) {
        location.replace(
            "https://inv.nadeko.net/watch?v=" +
            encodeURIComponent(location.pathname.slice(1))
        );
        return;
    }

    // Stack Exchange → AnonymousOverflow
    if (
        /(^|\.)stackexchange\.com$/i.test(host) ||
        /(^|\.)stackoverflow\.com$/i.test(host) ||
        /(^|\.)superuser\.com$/i.test(host) ||
        /(^|\.)serverfault\.com$/i.test(host) ||
        /(^|\.)askubuntu\.com$/i.test(host) ||
        /(^|\.)stackapps\.com$/i.test(host) ||
        /(^|\.)mathoverflow\.net$/i.test(host)
    ) {
        let newUrl;

        if (
            host === "stackoverflow.com" ||
            host === "www.stackoverflow.com"
        ) {
            newUrl =
                "https://overflow.hostux.net" +
                location.pathname +
                location.search +
                location.hash;
        } else {
            newUrl =
                "https://overflow.hostux.net/exchange/" +
                host +
                location.pathname +
                location.search +
                location.hash;
        }

        location.replace(newUrl);
        return;
    }

    const redirects = {
        "genius.com": "https://genius.fsky.io",
        "imgur.com": "https://imgur.artemislena.eu",
        "medium.com": "https://m.opnxng.com",
        "pinterest.com": "https://pinterest.bunk.im",
        "tenor.com": "https://tenor.fsky.io",
        "twitch.tv": "https://safetwitch.darkness.services",
        "tumblr.com": "https://priviblur.canine.tools",
        "www.bing.com": "https://startpage.com"
    };

    for (const domain in redirects) {
        if (host === domain || host.endsWith("." + domain)) {
            location.replace(
                redirects[domain] +
                location.pathname +
                location.search +
                location.hash
            );
            return;
        }
    }
})();