司机社多域名跳转与替换

Redirect and replace domain links of South-Plus

// ==UserScript==
// @name         司机社多域名跳转与替换
// @license MIT
// @namespace    http://tampermonkey.net/
// @version      0.7
// @icon         data:image/x-icon;base64,AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAABILAAASCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAACQAAAAkAAAAJAAAABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwAAAC8AAAAwAAAAMAAAAC3AAAAmQAAAGwAAAAdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZwAAAP8gICD/LCws/yEhIf8VFRX/AgIC/gAAANAAAABHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWAAAAJkAAACWAAAAlgAAAJYAAACYAAAAcQAAAAUAAAAAAAAAAAAAAAAAAAB9CQkJ/7CwsP/t7e3/5OTk/9PT0/+NjY3/Gxsb/wAAANUAAAAkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACWAwMD/xoaGv8eHh7/HBwc/wYGBv8AAADQAAAARgAAAD8AAAA/AAAAQgAAAMImJib/4+Pj//////////////////////+SkpL/AQEB/wAAAG0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJYXFxf/wcHB/+Tk5P/S0tL/LS0t/wAAAP0AAAD2AAAA9gAAAPYAAAD2AAAA/V1dXf/19fX/9vb2//r6+v///////////8rKyv8PDw//AAAAlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlhoaGv/b29v///////f39/+Xl5f/eXl5/3t7e/97e3v/e3t7/3t7e/98fHz/f39//0RERP88PDz/goKC//39/f//////4ODg/x0dHf8AAACWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACWGhoa/9vb2//////////////////////////////////////////////////AwMD/CQkJ/wAAAP9OTk7/+vr6///////h4eH/Hh4e/wAAAJYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJYaGhr/29vb////////////+Pj4//b29v/29vb/9vb2//r6+v///////////8DAwP8JCQn/AAAA/05OTv/6+vr//////+Hh4f8eHh7/AAAAlgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlhoaGv/b29v///////Pz8/9mZmb/PT09/z8/P/88PDz/hYWF//7+/v//////wMDA/wkJCf8AAAD/Tk5O//r6+v//////4eHh/x4eHv8AAACWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACWGhoa/9vb2///////7u7u/zMzM/8AAAD/AAAA/wAAAP9cXFz//f39///////AwMD/CQkJ/wAAAP9OTk7/+vr6///////h4eH/Hh4e/wAAAJYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJYaGhr/29vb///////4+Pj/q6ur/5WVlf+Wlpb/lJSU/7y8vP/+/v7//////8DAwP8JCQn/AAAA/05OTv/6+vr//////+Hh4f8eHh7/AAAAlgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlhoaGv/b29v/////////////////////////////////////////////////wMDA/wkJCf8AAAD/Tk5O//r6+v//////4eHh/x4eHv8AAACWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD0AAADDGBgY/83Nzf/y8vL/8PDw//Dw8P/w8PD/8PDw//Dw8P/w8PD/8PDw//Pz8/+0tLT/CAgI/wAAAP9OTk7/+vr6///////h4eH/Hh4e/wAAAJYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlgAAAP8GBgb/Li4u/zc3N/83Nzf/Nzc3/zc3N/83Nzf/Nzc3/zc3N/83Nzf/ODg4/ykpKf8CAgL/AAAA/05OTv/6+vr//////+Hh4f8eHh7/AAAAlgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACWDg4O/4eHh/+goKD/np6e/56env+enp7/np6e/56env+enp7/np6e/56env+enp7/oqKi/25ubv8AAAD/Tk5O//r6+v//////4eHh/x4eHv8AAACWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJYYGBj/2NjY////////////////////////////////////////////////////////////sbGx/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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////4H///+Af///gD/8A4Af/AAAH/wAAB/8AAAf/AAAH/wAAB/8AAAf/AAAH/wAAB/8AAAf+AAAH/gAAB/4AAAf+AAAH/AAAB/wAAAf8AAAH/AAAB/wAAAf8AAAH/AAAB/wAAAf//////////////////////////8=
// @description  Redirect and replace domain links of South-Plus
// @author       SakuraPY
// @match        *://*.sjskk.vip/*
// @match        *://*.sjs47.cc/*
// @match        *://*.sjs47.me/*
// @match        *://*.xsijishe.com/*
// @match        *://*.sjsyy.vip/*
// @match        *://*.xsijishe.cc/*
// @match        *://*.sijisheb.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const domains = [
        "sjskk.vip",
        "sjs47.cc",
        "sjs47.me",
        "sjsyy.vip",
        "xsijishe.com",
        "xsijishe.cc",
        "sijisheb.com"
    ];
    // Set your selected domain here
    const selectedDomain = 'xsijishe.net';

    // Redirect if the current host is not the selected domain or its subdomain
    //const now_domain = window.location.host;
    //if (!now_domain.includes(selectedDomain)) {
    //    window.location.host = selectedDomain;
    //}
    if (window.location.host !== selectedDomain) {
        window.location.host = selectedDomain;
    }
    // Replace <a href=></a> that targets the domains(or the subdomain of the domains) above(and its text) to the selected domain
    // if it is inside <a>, like the img <a href="u.php?action-show-uid-1359305.html"><img src="https://pic.imgdb.cn/item/62a500b209475431296f9991.png"></a>
    // dont replace it
    const links = document.getElementsByTagName('a');
    for (let i = 0; i < links.length; i++) {
        const link = links[i];
        const href = link.href;
        const text = link.text;
        if (href) {
            for (let j = 0; j < domains.length; j++) {
                if (href.includes(domains[j])) {
                    // if not inside <a>, replace it
                    if (link.childElementCount === 0) {
                        //replace url
                        //link.href = href.replace(domains[j], selectedDomain);
                        //replace url(all host)
                        link.href = href.replace(href.split('/')[2], selectedDomain);
                        //replace text
                        //link.text = text.replace(domains[j], selectedDomain);
                        //replace text(all host)
                        link.text = text.replace(href.split('/')[2], selectedDomain);
                    }
                }
            }
        }
    }
})();