atcoder_all_open

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

当前为 2021-05-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name atcoder_all_open
  3. // @namespace jp.misw
  4. // @author hotman
  5. // @description 問題Tabの隣に全ての問題を(ワンクリックで)開く全ての問題Tabを作成します。うまく動かない場合はatcoder上でのポップアップ制限を外して下さい
  6. // @version 1.0.8
  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. function toURL(flag=false){
  16. var url=location.href;
  17. var test_name=location.href.split('/')[4];
  18. if(flag===true || url.match(/atcoder.jp\/contests\/..*\/tasks$/) != null ) {
  19. var cnt=document.getElementsByClassName("table table-bordered table-striped")[0].children[1].childElementCount;
  20. for(var i=0;i<cnt;i++){
  21. window.open('https://atcoder.jp/contests/'+test_name+'/tasks/'+test_name+'_'+String.fromCharCode('a'.charCodeAt(0)+i));
  22. }
  23. }else{
  24. window.open('https://atcoder.jp/contests/'+test_name+'/tasks\/?all_open=yes');
  25. }
  26. }
  27.  
  28.  
  29. function all_open(){
  30. var url=location.href;
  31. console.log(url);
  32. if(url.match(/all_open=yes/) != null ){
  33. toURL(true);
  34. window.open('about:blank','_self').close();
  35. }else{
  36. var parent=document.getElementsByClassName("nav nav-tabs")[0];
  37. var add=document.createElement("li");
  38. parent.insertBefore(add,parent.children[2]);
  39. var a=document.createElement("a");
  40. add.appendChild(a);
  41. a.textContent="全ての問題";
  42. a.setAttribute("href","javascript:void(0);");
  43. a.addEventListener('click',toURL, false);
  44. }
  45. }
  46. all_open();