Greasy Fork is available in English.

atcoder-traffic

beta.atcoder.jpとatcoder.jpのコンテストサイトを行き来する etc.

2018-08-07 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

  1. // ==UserScript==
  2. // @name atcoder-traffic
  3. // @namespace https://greatest.deepsurf.us/users/201019
  4. // @description beta.atcoder.jpとatcoder.jpのコンテストサイトを行き来する etc.
  5. // @version 2.1
  6. // @author euglenese
  7. // @match https://beta.atcoder.jp/contests/*
  8. // @match https://*.contest.atcoder.jp/*
  9. // ==/UserScript==
  10.  
  11. var joi_pdf_number = [
  12. [20, 21, 23, 24],
  13. [20, 21, 22, 24],
  14. [20, 21, 22, 23],
  15. [20, 21, 22, 23]
  16. ];
  17.  
  18. function location_match(regex){
  19. return location.href.match(new RegExp(regex));
  20. }
  21.  
  22. function erase(text, regex){
  23. return text.replace(new RegExp(regex), "");
  24. }
  25.  
  26. var contest_name, position_name, linked;
  27.  
  28. function position_name_change(before, after){
  29. if(position_name == before){
  30. position_name = after;
  31. }
  32. }
  33.  
  34. var beta_contest_URL = "https\:\/\/beta\.atcoder\.jp\/contests\/";
  35. var https = "https\:\/\/";
  36. var contest_URL = "\.contest\.atcoder\.jp\/";
  37. var any_string = "[0-9a-z-_#]+";
  38. var any_string2 = "[0-9a-z-_#]*";
  39. var any_slash = "[0-9a-z-_#/]+";
  40. var any_char = "[0-9a-z-_#]";
  41. var any_digit = "[0-9]";
  42.  
  43. if(location_match(beta_contest_URL)){
  44. if(location_match(beta_contest_URL + any_string + "\/" + any_slash)){
  45. contest_name = erase(location.href, beta_contest_URL).split("/")[0];
  46. position_name = erase(location.href, beta_contest_URL + contest_name + "/");
  47. position_name_change("tasks", "assignments");
  48. position_name_change("submissions", "submissions/all");
  49. linked = "https://" + contest_name + ".contest.atcoder.jp/" + position_name;
  50. }else{
  51. contest_name = erase(location.href, beta_contest_URL).split("/")[0];
  52. linked = "https://" + contest_name + ".contest.atcoder.jp/";
  53. }
  54. $(".contest-title").attr("href", linked);
  55. }else{
  56. if(location_match(https + any_string + contest_URL + any_slash)){
  57. contest_name = erase(erase(location.href, https), contest_URL + any_slash);
  58. position_name = erase(location.href, https + contest_name + contest_URL);
  59. position_name_change("submissions/all", "submissions");
  60. linked = "https://beta.atcoder.jp/contests/" + contest_name + "/" + position_name;;
  61. }else{
  62. contest_name = erase(erase(location.href, https), contest_URL);
  63. linked = "https://beta.atcoder.jp/contests/" + contest_name;
  64. }
  65. $(".brand").removeAttr("href");
  66. $(".contest-name").replaceWith(function() {
  67. $(this).replaceWith("<span class='contest-name'><a href='" + linked + "'>" + $(this).text() + "</a></span>");
  68. });
  69. $(".contest-name a").css("color", "white");
  70. $(".contest-name a").css("text-decoration", "none");
  71. for(var i in [0, 1]){
  72. $("time").eq(i).replaceWith(function() {
  73. var url = "https://www.timeanddate.com/worldclock/fixedtime.html?iso=" + $(this).text().substr(0, 4) + $(this).text().substr(5, 2) + $(this).text().substr(8, 2) + "T" + $(this).text().substr(11, 2) + $(this).text().substr(14, 2) + "&p1=248";
  74. $(this).replaceWith("<time class='timezone-fixed'><a href='" + url + "'>" + $(this).text() + "</a></time>");
  75. });
  76. $("time a").eq(i).css("color", "#ccc");
  77. $("time a").css("text-decoration", "none");
  78. }
  79. }
  80.  
  81. var joi_years = "(2007|2008|2009|2010|2011|2012)";
  82.  
  83. if(location_match(beta_contest_URL + "joisc" + joi_years + "\/tasks\/joisc" + joi_years + "_") || location_match(https + "joisc" + joi_years + contest_URL + "tasks\/joisc" + joi_years + "_")){
  84. var this_year;
  85. if(location_match(beta_contest_URL + "joisc" + joi_years + "\/tasks\/joisc" + joi_years + "_")){
  86. this_year = erase(erase(location.href, beta_contest_URL + "joisc"), "\/tasks\/joisc" + joi_years + "_" + any_string);
  87. }else{
  88. this_year = erase(erase(location.href, https + "joisc"), contest_URL + "tasks\/joisc" + joi_years + "_" + any_string);
  89. }
  90. this_year = parseInt(this_year);
  91. for(var i = 0; i < 4; i++){
  92. var url;
  93. if(this_year == 2008 || this_year == 2009){
  94. url = "https://www.ioi-jp.org/camp/" + this_year + "/" + this_year + "-sp-tasks/" + this_year + "-sp_tr-day" + (i + 1) + "_" + joi_pdf_number[this_year - 2007][i] + ".pdf";
  95. }else if(this_year <= 2010){
  96. url = "https://www.ioi-jp.org/camp/" + this_year + "/" + this_year + "-sp-tasks/" + this_year + "-sp-day" + (i + 1) + "_" + joi_pdf_number[this_year - 2007][i] + ".pdf";
  97. }else{
  98. url = "https://www.ioi-jp.org/camp/" + this_year + "/" + this_year + "-sp-tasks/" + this_year + "-sp-day" + (i + 1) + ".pdf";
  99. }
  100. $("#task-statement").append("<a href='" + url + "'>PDFリンク (Day " + (i + 1) + ")</a><br>");
  101. }
  102. }