AtCoder Standings Excluding Unrated User

AtCoderの順位表から参加登録していないユーザを隠すスクリプトです。

  1. // ==UserScript==
  2. // @name AtCoder Standings Excluding Unrated User
  3. // @namespace https://hals.one/
  4. // @version 0.2.2
  5. // @description AtCoderの順位表から参加登録していないユーザを隠すスクリプトです。
  6. // @author HalsSC
  7. // @match https://atcoder.jp/contests/*/standings
  8. // @exclude https://atcoder.jp/contests/*/standings/json
  9. // @license MIT
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. const delay = 1000;
  14.  
  15. // 順位表の中で参加登録していないユーザの行を見つけ、hidden属性をtrueにする関数
  16. function hidden_unrated(){
  17. setTimeout((function(){
  18. const unrated_users = document.querySelectorAll("td.standings-rank");
  19. console.log(unrated_users);
  20. unrated_users.forEach(function(user) {
  21. let element = user;
  22. if (element.innerHTML !== "-"){ return; } // 参加者はスキップ
  23. while (element && element.tagName !== "TR") {
  24. element = element.parentElement;
  25. }
  26. // FAに垢消しが含まれるとFA欄まで消えちゃう
  27. if(element && element.className !== "standings-fa"){
  28. element.hidden = true;
  29. }
  30. });
  31. }), delay);
  32. }
  33.  
  34. // 「お気に入りのみ表示」にclickアクションとしてhidden_unrated関数を登録する関数
  35. function set_onclick(){
  36. setTimeout((function(){
  37. const button = document.getElementById("checkbox-fav-only");
  38. button.addEventListener("click", hidden_unrated);
  39. }), delay);
  40. }
  41.  
  42. // メイン関数
  43. (function(){
  44. hidden_unrated();
  45. set_onclick();
  46. })();