Greasy Fork

Greasy Fork is available in English.

洛谷帖子自动跳转器

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

您需要先安装一个扩展,例如 篡改猴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/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 最后一部分非数字");
    }
})();