背景
在洛谷一段时间了,想看看自己做了那些题?
却只有:
还是按字典序排列的……
带点颜色,显示下难度?
没问题!
实现——用户脚本
欢迎来到 Greasy Fork,这里是一个提供用户脚本的网站。
本文主要来自Greasy Fork。
用户脚本是什么?
用户脚本是一段代码,它们能够优化您的网页浏览体验。安装之后,有些脚本能为网站添加新的功能,有些能使网站的界面更加易用,有些则能隐藏网站上烦人的部分内容。在 Greasy Fork 上的用户脚本都是由用户编写并向全世界发表的,您可以免费安装,轻松体验。
第一步:安装一个用户脚本管理器
要使用用户脚本,您首先需要安装一个用户脚本管理器。根据您使用的浏览器不同,可用的用户脚本管理器也有所不同。
Chrome:Tampermonkey 或 Violent monkey
Firefox:Greasemonkey、Tampermonkey或 Violentmonkey
Safari:Tampermonkey
Microsoft Edge:Tampermonkey
Opera:Tampermonkey或 Violentmonkey
Maxthon:Violentmonkey
Dolphin:Tampermonkey
UC:Tampermonkey
Qupzilla:(不需要额外软件)
AdGuard:(不需要额外软件)
直接下载带脚本编辑器的浏览器
比如:超星网课助手虽然这是网课助手,但是自带的脚本编辑真好
解压后,可以看到:
运行后看到:
第二步:安装一个用户脚本
打开管理器:
新建一个脚本:
安装洛谷题目难度显示 luogu dif render脚本。
快速下载
// ==UserScript== // @name 洛谷题目难度显示 luogu dif render // @namespace http://tampermonkey.net/ // @version 0.6 // @description 在个人空间显示每一道题的难度 // @author rainy // @match https://www.luogu.com.cn/user/* // @grant none // ==/UserScript== var colors = ['rgb(191, 191, 191)', 'rgb(254, 76, 97)', 'rgb(243, 156, 17)', 'rgb(255, 193, 22)', 'rgb(82, 196, 26)', 'rgb(52, 152, 219)', 'rgb(157, 61, 207)', 'rgb(14, 29, 105)']; (function() { 'use strict'; var problems = []; for(var passed of window._feInjection.currentData.passedProblems) problems.push({pid: passed.pid, dif: passed.difficulty, rendered: false}); for(var tryed of window._feInjection.currentData.submittedProblems) problems.push({pid: tryed.pid, dif: tryed.difficulty, rendered: false}); setInterval(() => { if(window.location.href.split("#").length == 2 && window.location.href.split("#")[1] == 'problem'){ for(var i = 0;i < problems.length;i++) if(!problems[i].rendered) { var elements = document.querySelectorAll('a'); for(var el of elements) if(el.textContent == problems[i].pid) { if (el.classList) el.classList.remove("color-default"); else el.className = el.className.replace('color-default', ' '); problems[i].rendered = true; el.style.color = colors[problems[i].dif]; break; } } }else for(var j = 0;j < problems.length;j++) problems[j].rendered = false; }, 1000); })();
(浏览此网站 查找您想尝试的其他用户脚本。)
然后再次打开洛谷,可看到:
-----分割线-----
参考文章:
https://greasyfork.org/zh-CN/help/installing-user-scripts
原脚本网站:
https://greasyfork.org/zh-CN/scripts/392036-%E6%B4%9B%E8%B0%B7%E9%A2%98%E7%9B%AE%E9%9A%BE%E5%BA%A6%E6%98%BE%E7%A4%BA-luogu-dif-render/code
来源:https://www.cnblogs.com/include-blog/p/12501863.html