atcoder-tasks-dropdown-menu-colorizer

Apply the same coloring as the atcoder-tasks-page-colorizer in the drop-down menu of tasks added by Comfortable AtCoder.

נכון ליום 29-04-2022. ראה הגרסה האחרונה.

  1. // ==UserScript==
  2. // @name atcoder-tasks-dropdown-menu-colorizer
  3. // @namespace https://twitter.com/KakurenboUni
  4. // @version 1.0.0
  5. // @require https://greatest.deepsurf.us/scripts/437862-atcoder-problems-api/code/atcoder-problems-api.js?version=1004082
  6. // @match https://atcoder.jp/*
  7. // @description Apply the same coloring as the atcoder-tasks-page-colorizer in the drop-down menu of tasks added by Comfortable AtCoder.
  8. // @author uni-kakurenbo
  9. // @license MIT
  10. // @supportURL https://twitter.com/KakurenboUni
  11. // ==/UserScript==
  12.  
  13. getSubmissions(userScreenName).then(colorize);
  14.  
  15. function colorize(problems_info) {
  16. let tabs = document.querySelector(".nav-tabs").querySelectorAll("li");
  17. const tasks = [].find.call(tabs, (tab) => tab?.innerText.match(/問題|Tasks/ig));
  18. tasks.querySelector(".dropdown-menu").querySelectorAll("li").forEach((y) => {
  19. const problem_id = y.querySelector('a').getAttribute('href').split('/').pop();
  20. const trial = problems_info.filter(x => x.problem_id == problem_id);
  21. if(trial.length != 0) y.classList.add(trial.map(x => x.result).includes('AC') ? 'bg-success' : 'bg-warning');
  22. });
  23. }