QCoder AC Problem

QCoderの問題でACのものに色がつきます

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         QCoder AC Problem
// @namespace    https://ruku.tellpro.net
// @version      2024-11-04
// @description  QCoderの問題でACのものに色がつきます
// @author       ruku
// @match        https://www.qcoder.jp/*
// @icon         https://www.qcoder.jp/_next/static/media/20231120_logo.5742ea86.svg
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  "use strict";
  let prevURL = "";
  let data = new Map();
  setInterval(() => {
    const url = location.href;
    if (!/https:\/\/www\.qcoder\.jp\/ja\/contests\/(.+)/.test(url)) {
      return;
    }
    if (url !== prevURL) {
      prevURL = url;
      const match = url.match(/https:\/\/www\.qcoder\.jp\/ja\/contests\/(.+)/)[1];
      const apiURL = `https://www.qcoder.jp/api/contests/${match.split("/")[0]}/submissions/me`;
      fetch(apiURL)
        .then((e) => {
          return e.json();
        })
        .then((e) => {
          data = new Map();
          e.reverse();
          for (const dat of e) {
            if (data[dat.problemLabel] !== "AC") {
              data[dat.problemLabel] = dat.submissionStatusCode;
            }
          }
        });
    }
    const ATags = document.getElementsByTagName("A");
    const menuItems = Array.from(ATags).filter((a) => a.getAttribute("role") === "menuitem");
    for (const item of menuItems) {
      const AURL = item.href.split("/");
      if (data[AURL[AURL.length - 1]] === "AC") {
        item.style = "background-color: rgb(212, 237, 201);";
      } else if (data[AURL[AURL.length - 1]] !== undefined) {
        item.style = "background-color: rgb(255, 227, 227);";
      }
    }
  }, 1000);
})();