Greasy Fork

来自缓存

洛谷帖子自动跳转器

在洛谷的讨论页面自动跳转到洛谷帖子保存站(需要挂个梯子)

// ==UserScript==
// @name         洛谷帖子自动跳转器
// @namespace    https://greasyfork.org/zh-CN/scripts/526671
// @namespace    http://www.luogu.com.cn/user/527300
// @version      0.4
// @description  在洛谷的讨论页面自动跳转到洛谷帖子保存站(需要挂个梯子)
// @author       W_C_B_H(白猫戴黑帽)
// @match        https://www.luogu.com.cn/discuss/*
// @match        https://www.luogu.com/discuss/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    const url = window.location.href;
    const lastPart = url.split('/').pop();
    const lastNumber = isNaN(lastPart) ? null : Number(lastPart);
    if (lastNumber !== null)
    {
        window.location.href = "https://lglg.top/" + lastNumber;
    }
    else
    {
        console.log("url 最后一部分非数字");
    }
})();