Complete Luogu

Complete luogu 是一个为优化洛谷体验而撰写的脚本。该脚本提供了一些在洛谷已被禁用的功能的替代选项。

最新版本提供的功能有:

  • 进入洛谷讨论区时,如果该帖子已经被封禁,自动跳转到 lglg.top。(如果该帖子此前未被保存,那么这样也无法看到该帖子)
  • 由于洛谷重新开放了讨论区,上述功能已取消以加快运行速度。
  • 进入文章区、剪切板时,如果该页面被Cloudflare封禁,会自动跳转到 luogu.me。
  • 进入他人的个人主页时,自动消除红色屏蔽条并显示主页内容(可能会失败,刷新一下就好了。
Ver 2025-02-22
// ==UserScript==
// @name         Complete Luogu
// @namespace    http://tampermonkey.net/
// @version      2025-02-22
// @description  通过此脚本,自动跳转无法访问的帖子、剪切板、文章,并自动展示个人主页。
// @author       Luke_li
// @match        https://www.luogu.com/article/*
// @match        https://www.luogu.com/paste/*
// @match        https://www.luogu.com.cn/discuss*
// @match        https://www.luogu.com.cn/problem/*
// @match        https://www.luogu.com.cn/user/*
// @icon         https://cdn.luogu.com.cn/upload/usericon/539784.png
// @grant        none
// ==/UserScript==



// config

//由于技术原因,从大部分页面(尤其是题目页面)进入讨论可能跳转失败或者无法返回题面。
//因此,我设置了禁止在题目页面进入讨论时自动跳转的选项。
const redirect_discuss_in_problem_page=1;//是否允许从题面进入讨论区时自动跳转
const alert_when_prohibitted_by_config=1;//是否在上项设置设置为 0 时提示



function work() {
    'use strict';

    if(document.title == "错误 - 洛谷 | 计算机科学教育新生态") {
        if(location.href.includes("https://www.luogu.com.cn/discuss/")) {
            location.assign(location.href.replace("https://www.luogu.com.cn/discuss/","https://lglg.top/"));
        }
    }
    else if(document.title == "Error - 洛谷") {
        if(!redirect_discuss_in_problem_page){
            if(alert_when_prohibitted_by_config) {
                alert("无法跳转。请返回上一页或查看脚本的config");
            }
        }
        else if(location.href.includes("https://www.luogu.com.cn/discuss/")) {
            location.assign(location.href.replace("https://www.luogu.com.cn/discuss/","https://lglg.top/"));
        }
    }
    else if(document.title == 'Attention Required! | Cloudflare') {
        if(location.href.includes("https://www.luogu.com/article/") || location.href.includes("https://www.luogu.com/paste")) {
            location.assign(location.href.replace("https://www.luogu.com","https://www.luogu.me"));
        }
    }
    if(location.href.includes("https://www.luogu.com.cn/user/"))
    {
        let mainpage = document.getElementsByClassName('introduction marked');
        mainpage[0].style="";
        let warning = document.querySelector('[style="background-color: rgb(255, 235, 236); border-radius: 5px; border: 1px solid rgb(225, 50, 56); padding: 1em; font-style: italic;"]');
        warning.style="display: none;";
    }
}

(function() {
    'use strict';

    setTimeout(function() {
        work();
        let prevURL = window.location.href;
        setInterval(function() {
            if(window.location.href !== prevURL) {
                prevURL = window.location.href;
                work();
            }
        },150);
    },300);
})();
Ver 2025-03-25
// ==UserScript==
// @name         Complete Luogu
// @namespace    http://tampermonkey.net/
// @version      2025-03-25
// @description  通过此脚本,自动跳转无法访问的帖子、剪切板、文章,并自动展示个人主页。
// @author       Luke_li
// @match        https://www.luogu.com/article/*
// @match        https://www.luogu.com/paste/*
// @match        https://www.luogu.com.cn/article/*
// @match        https://www.luogu.com.cn/paste/*
// @match        https://www.luogu.com.cn/discuss*
// @match        https://www.luogu.com.cn/problem/*
// @match        https://www.luogu.com.cn/user/*
// @icon         https://cdn.luogu.com.cn/upload/usericon/539784.png
// @grant        none
// ==/UserScript==



// config

//由于技术原因,在某些环境下(如网络较差时)从题目页面进入讨论可能跳转失败或者无法返回题面。
//因此,我禁止了在题目页面进入讨论的自动跳转。如果你希望使用此功能,可以打开以下选项尝试一下。
//有什么修改建议也可以洛谷私信我
const redirect_discuss_in_problem_page=1;//是否允许从题面进入讨论区时自动跳转
const alert_when_prohibitted_by_config=1;//是否在上项设置设置为 0 时提示
//由于技术原因,在本标签页跳转讨论时会出现上一页面历史丢失的情况,所以我加入了本开关。如果没有弹出窗口,请检查浏览器设置,取消弹出窗口限制。
const popout_window=1;//是否使用弹出窗口的跳转方式,1为是,0为在本标签页跳转



function work() {
    'use strict';

    if(document.title == "错误 - 洛谷 | 计算机科学教育新生态") {
        if(location.href.includes("https://www.luogu.com.cn/discuss/")) {
            if(popout_window) {
                window.open(location.href.replace("https://www.luogu.com.cn/discuss/","https://lglg.top/"));
                history.back();
            }
            else {
                location.assign(location.href.replace("https://www.luogu.com.cn/discuss/","https://lglg.top/"));
            }
        }
    }
    else if(document.title == "Error - 洛谷") {
        if(!redirect_discuss_in_problem_page){
            if(alert_when_prohibitted_by_config) {
                alert("无法跳转。请返回上一页或查看脚本的config");
            }
        }
        else if(location.href.includes("https://www.luogu.com.cn/discuss/")) {
            if(popout_window) {
                window.open(location.href.replace("https://www.luogu.com.cn/discuss/","https://lglg.top/"));
                history.back();
            }
            else {
                location.assign(location.href.replace("https://www.luogu.com.cn/discuss/","https://lglg.top/"));
            }
        }
    }
    else if(document.title == 'Attention Required! | Cloudflare') {
        if(location.href.includes("https://www.luogu.com/article/") || location.href.includes("https://www.luogu.com/paste")) {
            location.assign(location.href.replace("https://www.luogu.com","https://www.luogu.me"));
        }
    }
    if(location.href.includes("https://www.luogu.com.cn/user/"))
    {
        let mainpage = document.getElementsByClassName('introduction marked');
        mainpage[0].style="";
        let warning = document.querySelector('[style="background-color: rgb(255, 235, 236); border-radius: 5px; border: 1px solid rgb(225, 50, 56); padding: 1em; font-style: italic;"]');
        warning.style="display: none;";
    }
}

(function() {
    'use strict';

    setTimeout(function() {
        work();
        let prevURL = window.location.href;
        setInterval(function() {
            if(window.location.href !== prevURL) {
                prevURL = window.location.href;
                work();
            }
        },150);
    },300);
})();
Ver 2025-04-02
// ==UserScript==
// @name         Complete Luogu
// @namespace    http://tampermonkey.net/
// @version      2025-04-02
// @description  通过此脚本,自动跳转无法访问的剪切板、文章,并自动展示个人主页。
// @author       Luke_li
// @match        https://www.luogu.com/article/*
// @match        https://www.luogu.com/paste/*
// @match        https://www.luogu.com.cn/article/*
// @match        https://www.luogu.com.cn/paste/*
// @match        https://www.luogu.com.cn/user/*
// @icon         https://cdn.luogu.com.cn/upload/usericon/539784.png
// @grant        none
// ==/UserScript==


function work() {
    'use strict';

    if(document.title == 'Attention Required! | Cloudflare') {
        if(location.href.includes("https://www.luogu.com/article/") || location.href.includes("https://www.luogu.com/paste")) {
            location.assign(location.href.replace("https://www.luogu.com","https://www.luogu.me"));
        }
    }
    if(location.href.includes("https://www.luogu.com.cn/user/"))
    {
        let mainpage = document.getElementsByClassName('introduction marked');
        mainpage[0].style="";
        let warning = document.querySelector('[style="background-color: rgb(255, 235, 236); border-radius: 5px; border: 1px solid rgb(225, 50, 56); padding: 1em; font-style: italic;"]');
        warning.style="display: none;";
    }
}

(function() {
    'use strict';

    setTimeout(function() {
        work();
        let prevURL = window.location.href;
        setInterval(function() {
            if(window.location.href !== prevURL) {
                prevURL = window.location.href;
                work();
            }
        },150);
    },150);
})();
posted @ 2025-03-06 15:35  Luke_li  阅读(58)  评论(0)    收藏  举报