Greasy Fork

Greasy Fork is available in English.

蓝奏云域名替换

替换www为pan

当前为 2020-07-15 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         蓝奏云域名替换
// @namespace    http://greasyfork.icu/zh-CN/users/6065-hatn
// @version      0.2
// @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 = 100;
        let timer = setInterval(() => {
            if (i >= maxTimes) return clearInterval(timer);
            ++i;
            if (typeof jQuery == 'undefined') return;
            s.replace();
            //console.log(i, 'times');
            return clearInterval(timer);
        }, 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() {
            $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();