Greasy Fork

来自缓存

Greasy Fork is available in English.

蓝奏云域名替换

替换www为pan

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         蓝奏云域名替换
// @namespace    http://greasyfork.icu/zh-CN/users/6065-hatn
// @version      0.2.1
// @description  替换www为pan
// @icon         http://www.gravatar.com/avatar/10670da5cbd7779dcb70c28594abbe56?r=PG&s=92&default=identicon
// @author       hatn
// @copyright	 2020, hatn
// @include      *
// @run-at     	 document-start
// @grant        unsafeWindow
// ==/UserScript==
let lzyObj = {
    cat: /https:\/\/www.lanzous.com\/\S+/gi,
    targetStr: "https://pan.",
    originStr: "https://www.",
	init () {
        let i = 0, s = this;
        let urlStr = location.href;
        if (s.cat.test(urlStr)) {
            let toUrl = urlStr.replace(s.originStr, s.targetStr);
            location.href = toUrl;
        }
        let maxTimes = 50;
        let timer = setInterval(() => {
            if (i >= maxTimes) {
                let jq_url = 'https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js';
                let jqDom = document.createElement('script');
                jqDom.type = 'text/javascript';
                jqDom.async = true;
                jqDom.src = jq_url;
                jqDom.onload = () => s.replace();
                document.body.appendChild(jqDom);
                return clearInterval(timer);
            }
            ++i;
            if (typeof jQuery == 'undefined') return;
            clearInterval(timer);
            return s.replace();
            //console.log(i, 'times');
        }, 100);
    },

    replace() {
        let s = this;
        let $check = $('a[href^="https://www.lanzous.com/"]');
        if ($check.length < 1) return console.log('Log: There is no match !');
        $check.each(function() {
            let $s = $(this);
            let originUrl = $s.attr('href');
            if (!s.cat.test(originUrl)) return true; // 只处理分享链接
            let innerHTML = this.innerHTML;
            // console.log(originUrl, innerHTML);
            let newUrl = originUrl.replace(s.originStr, s.targetStr);
            let newHTML = innerHTML.replace(s.originStr, s.targetStr);
            // console.log(newUrl, newHTML);
            $s.attr('href', newUrl);
            this.innerHTML = newHTML;
        });
    }
};

lzyObj.init();