atcoder_all_open

問題Tabの隣に全ての問題を(ワンクリックで)開く全ての問題Tabを作成します。うまく動かない場合はatcoder上でのポップアップ制限を外して下さい

目前为 2023-06-29 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name atcoder_all_open
  3. // @namespace jp.misw
  4. // @author hotman
  5. // @description 問題Tabの隣に全ての問題を(ワンクリックで)開く全ての問題Tabを作成します。うまく動かない場合はatcoder上でのポップアップ制限を外して下さい
  6. // @version 1.0.9
  7. // @include https://atcoder.jp/contests/*
  8. // @exclude https://atcoder.jp/contests/
  9. // @exclude https://atcoder.jp/contests/archive
  10. // @grant none
  11. // @description 問題Tabの隣に全ての問題を(ワンクリックで)開く全ての問題Tabを作成します。うまく動かない場合はatcoder上でのポップアップ制限を外して下さい
  12. // ==/UserScript==
  13.  
  14.  
  15. (() => {
  16. 'use strict';
  17. const toURL = (flag = false) => {
  18. let url = location.href;
  19. let test_name = location.href.split('/')[4];
  20. if (flag === true || url.match(/atcoder.jp\/contests\/..*\/tasks$/) != null) {
  21. let table = document.getElementsByClassName("table table-bordered table-striped")[0].children[1];
  22. // 暴発防止のため、20問以上は読み込まない
  23. let cnt = Math.min(table.childElementCount, 20);
  24. for (let i = 0; i < cnt; i++) {
  25. let link = table.children[i].querySelector("a");
  26. window.open(link.href);
  27. }
  28. } else {
  29. window.open('https://atcoder.jp/contests/' + test_name + '/tasks\/?all_open=yes');
  30. }
  31. }
  32.  
  33. const all_open = () => {
  34. var url = location.href;
  35. console.log(url);
  36. if (url.match(/all_open=yes/) != null) {
  37. toURL(true);
  38. window.open('about:blank', '_self').close();
  39. } else {
  40. let parent = document.getElementsByClassName("nav nav-tabs")[0];
  41. let add = document.createElement("li");
  42. parent.insertBefore(add, parent.children[2]);
  43. let a = document.createElement("a");
  44. add.appendChild(a);
  45. a.textContent = "全ての問題";
  46. a.setAttribute("href", "javascript:void(0);");
  47. a.addEventListener('click', toURL, false);
  48. }
  49. }
  50. all_open();
  51. })();