Codeforces show contestId

在每场比赛名称的前面添加一个比赛Id的超链接,指向这场比赛。

  1. // ==UserScript==
  2. // @name Codeforces show contestId
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 在每场比赛名称的前面添加一个比赛Id的超链接,指向这场比赛。
  6. // @author Tanphoon
  7. // @match https://codeforces.com/contests
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=codeforces.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. let CurrentContests = document.querySelector("#pageContent > div.contestList > div.datatable > div:nth-child(6) > table > tbody");
  17. let PastContests = document.querySelector("#pageContent > div.contestList > div.contests-table > div.datatable > div:nth-child(6) > table > tbody");
  18.  
  19.  
  20. function AddContestId(table) {
  21. for (let i = 0; i < table.rows.length; i++) {
  22. let curRow = table.rows[i];
  23. let newCell = curRow.insertCell(0);
  24. let Id = curRow.getAttribute('data-contestid');
  25. if (i & 1)
  26. newCell.setAttribute("class", "dark");
  27. if (i == 0) {
  28. newCell.innerHTML = 'ContestId';
  29. } else {
  30. newCell.innerHTML = `<a href = "https://codeforces.com/contests/${Id}" target = "_blank">${Id}</a>`;
  31. }
  32. }
  33.  
  34. }
  35.  
  36. AddContestId(CurrentContests);
  37. AddContestId(PastContests);
  38. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址