题目难度显示

qwq

当前为 2019-11-05 提交的版本,查看 最新版本

// ==UserScript==
// @name         题目难度显示
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  qwq
// @author       rainy
// @match        https://www.luogu.org/user/*
// @grant        none
// ==/UserScript==

function forEachElement(selector, fn) {
  var elements = document.querySelectorAll(selector);
  for (var i = 0; i < elements.length; i++){fn(elements[i], i);}
 }

(function() {
    'use strict';
    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)'];
    setTimeout(() => {
        if(window._feInjection.currentData.user.uid != window._feInjection.currentUser.uid) return;
        if(window.location.href.split("#").length == 1) return;
        else if(window.location.href.split("#")[1] != 'problem') return;
        for(var passed of window._feInjection.currentData.passedProblems) {
            forEachElement("a", (el, i) => { if(passed.pid == el.textContent)el.style.color = colors[passed.difficulty]; });
        }
        for(var tryed of window._feInjection.currentData.submittedProblems) {
            forEachElement("a", (el, i) => { if(tryed.pid == el.textContent)el.style.color = colors[tryed.difficulty]; });
        }
    }, 2333);
})();