讨论区重定向脚本

· · 个人记录

// ==UserScript==
// @name         洛谷讨论重定向
// @namespace    http://tampermonkey.net/
// @version      1.0
// @author       Carey_chen
// @match        https://www.luogu.com.cn/discuss/*
// @icon         https://www.luogu.com.cn/favicon.ico
// ==/UserScript==

(function() {
    'use strict';
    let now = window.location.href;
    for (let i = 0; i < now.length; i++)
    {
        if('0' <= now[i] && now[i] <= '9')
        {
            console.log(i);
            window.location.replace("https://lglg.top/" + now.substring(i));
            break;
        }
    }
})();