Frontend-Redirectr

Redirect popular sites to alternative privacy-friendly frontends

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu betiği yüklemek için bir betik yöneticisi eklentisi yüklemeniz gerekecektir.

(Zaten bir betik yöneticim var, hadi yükleyelim!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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;
        }
    }
})();