您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
洛谷题目跳转器优化
当前为
// ==UserScript== // @name Better Luogu Problem Searcher // @namespace n/a // @version 0.0.2 // @description 洛谷题目跳转器优化 // @author iotang // @match https://www.luogu.org // @match https://www.luogu.org/ // @match https://www.luogu.org/#feed // @match https://www.luogu.org/#feed/ // @match http://www.luogu.org // @match http://www.luogu.org/ // @match http://www.luogu.org/#feed // @match http://www.luogu.org/#feed/ // @grant none // ==/UserScript== (function() { 'use strict'; var hrefOld = "https://www.luogu.org/problemnew"; var hrefNew = "https://www.luogu.org/fe/problem"; function jumpfn() { var target = document.getElementsByClassName("am-form-field")[0].value; if(target === "")return; var checked = document.getElementById("switch_to_fe").checked; var go; if(checked === true)go = hrefNew + "/list?keyword=" + target + "&content=true"; else go = hrefOld + "/lists?name=" + target + "&orderitem=pid&tag=&content=1&type="; location.href = go; } function searchfn() { var target = document.getElementsByClassName("am-form-field")[0].value; if(target === "")return; var targetu = target.toUpperCase(); var checked = document.getElementById("switch_to_fe").checked; var go = ""; if(checked === true)go = hrefNew; else go = hrefOld + "/show"; if(target.match(/^[1-9][0-9][0-9][0-9]+$/) == target)go = go + "/P" + target; else if(targetu.match(/^[0-9]+[A-Z][0-9]?$/) == targetu)go = go + "/CF" + targetu; else if(targetu.match(/^(?:U|P|CF|SP|AT|UVA)[0-9]+[A-Z]?[0-9]?$/) == targetu)go = go + "/" + targetu; else { if(checked === true)go = hrefNew + "/list?keyword=" + target + "&content=true"; else go = hrefOld + "/lists?name=" + target + "&orderitem=pid&tag=&content=1&type="; } location.href = go; } var locations = document.getElementsByClassName("lg-index-content")[0] .getElementsByClassName("lg-article lg-index-stat")[0] .getElementsByClassName("am-btn am-btn-primary am-btn-sm")[0] .parentNode; var button = document.createElement("button"); button.className = "am-btn am-btn-success am-btn-sm"; button.name = "gotosearch"; button.id = "gotosearch"; button.innerHTML = "搜索"; button.onclick = function(){jumpfn();}; var checkbox = document.createElement("input"); checkbox.type = "checkbox"; checkbox.class = "switch_to_fe"; checkbox.id = "switch_to_fe"; checkbox.defaultChecked = "true"; locations.appendChild(button); locations.appendChild(checkbox); document.getElementsByClassName("am-form-field")[0].placeholder = "输入题号或题目名,按回车确认"; document.getElementsByClassName("am-form-field")[0].onkeyup = function(event){if(event.keyCode === 13){searchfn();}}; document.getElementsByClassName("lg-article lg-index-stat")[0].getElementsByTagName("h2")[0].innerHTML = "问题搜索"; document.getElementsByName("gotorandom")[0].innerHTML = "随机"; })();