Luogu自动跳题目列表
打开题单时需手动跳转到题目列表?
用下面Tampermonkey脚本
注:所有代码皆原创
// ==UserScript==
// @name Luogu自动跳题目列表
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Automatically redirects to #problems on Luogu Training Page
// @author 顾念
// @match https://www.luogu.com.cn/training/*
// @match https://www.luogu.com.cn/training/list
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 获取当前页面的URL
var currentURL = window.location.href;
// 检查当前页面URL是否已经包含 #problems
if (!currentURL.includes("#problems")) {
if (!currentURL.includes("/list")) {
// 如果没有,则添加 #problems 并重定向到新的URL
var newURL = currentURL + "#problems";
window.location.href = newURL;
}
}
// 获取所有匹配的链接
var links = document.querySelectorAll('a[data-v-0640126c][data-v-128051e7][href^="/training/"]');
// 遍历链接列表
links.forEach(function(link) {
// 获取原始链接
var originalHref = link.getAttribute('href');
// 如果链接中不包含 #problems
if (originalHref.indexOf('#problems') === -1) {
// 在链接后面添加 #problems
var newHref = originalHref + '#problems';
// 更新链接
link.setAttribute('href', newHref);
}
});
})();