Frontend-Redirectr

Redirect popular sites to alternative privacy-friendly frontends

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

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