拯救洛谷云剪切板计划!(包解决的)

· · 科技·工程

咳咳 (推荐一下洛谷美化)

自从洛谷云剪切板炸掉之后也是十分难受

so 我来救场了 参考这篇文章写的 完善了一些

step.1 安装油猴脚本

step.2

打开面板 如图(这里我已经安装过了 不用管)

点击“管理面板”一栏(这里我已经安装过了 不用管)

点击“已安装脚本”左边的“+” 打开以下界面

将下面这一堆代码覆盖进去

// ==UserScript==
// @name         洛谷专栏/云剪贴板续命
// @namespace    https://www.cnblogs.com/jerrycyx/p/18755697
// @version      1.2
// @description  洛谷专栏/云剪贴板自动重定向至相关保存站
// @author       Jerrycyx
// @match        https://www.luogu.com.cn/*
// @match        https://www.luogu.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const currentUrl = window.location.href;
    const path = window.location.pathname;
    const host = window.location.hostname;

    if (host === 'www.luogu.com') {
        if (path.startsWith('/article/') || path.startsWith('/paste/')) {
            const newUrl = `https://www.luogu.me${path}`;
            window.location.replace(newUrl);
            return;
        }
    }

    //此处曾是讨论区跳转代码,所幸现在已不再需要了!

    if(host === 'www.luogu.com.cn' && (path.startsWith('/article/') || path.startsWith('/paste/'))) {
        const warningTitle = document.querySelector('body > div:nth-child(1) > div > h3');
        if (document.title == '安全访问中心 - 洛谷' && warningTitle.textContent.trim() == '即将离开洛谷') {
            const urlElement = document.querySelector('#url');
            if (urlElement) {
                urlElement.textContent = urlElement.textContent
                    .replace('luogu.com', 'luogu.me')
                    .replace('luogu.com.cn', 'luogu.me');
            }

            const continueLink = document.querySelector('body > div:nth-child(1) > div > p:nth-child(5) > a');
            if (continueLink) {
                continueLink.href = continueLink.href
                    .replace('luogu.com', 'luogu.me')
                    .replace('luogu.com.cn', 'luogu.me');
            }
        }
       return;
    }
})();

保存

完成 去看看云剪切板能不能用了吧!可以来这试试