// ==UserScript== // @name Luogu Search AnyWhere // @version 0.2 // @description Search AnyWhere in Luogu! // @author tiger2005 // @match https://www.luogu.com.cn/* // @icon https://cdn.luogu.com.cn/upload/usericon/3.png // @grant none // @license MIT // @require https://code.jquery.com/jquery-3.6.0.min.js // @namespace https://greasyfork.org/users/829530 // @downloadURL none // ==/UserScript== (function() { 'use strict'; var addedContent = false; let majorInterval = setInterval(function(){ if($(".user-nav .search-wrap").length == 0) return; // clearInterval(majorInterval); var sicon = $(".user-nav .search-wrap").next(); $(".user-nav .search-wrap").remove(); sicon.css("margin-left", "10px"); if(! addedContent){ $("body").append(`
`); addedContent = true; $(".inputArea > input").focus(function(){ $(this).parent().addClass("onFocus"); }); $(".inputArea > input").blur(function(){ $(this).parent().removeClass("onFocus"); if($(this).val().length != 0) $(this).parent().addClass("withContent"); else $(this).parent().removeClass("withContent"); }); $(".inputArea").mouseenter(function(){ $(this).addClass("onHover"); }); $(".inputArea").mouseleave(function(){ $(this).removeClass("onHover"); }); } const problemColors = [ "Gray", "Red", "Orange", "Yellow", "Green", "Blue", "Purple", "Black" ]; const problemNames = [ "暂无评定", "入门", "普及-", "普及/提高-", "普及+/提高", "提高+/省选-", "省选/NOI-", "NOI/NOI+/CTSC" ]; var searchTimeout = null; const searchInfo = () => { searchTimeout = null; var info = $(".inputArea > input").val(); info = $.trim(info); if(info == ""){ $(".searchAnywhereContent").html(""); return; } $(".searchAnywhereContent").html(`