atcoder-traffic

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

Verze ze dne 06. 08. 2018. Zobrazit nejnovější verzi.

  1. // ==UserScript==
  2. // @name atcoder-traffic
  3. // @namespace
  4. // @description beta.atcoder.jpとatcoder.jpのコンテストサイトを行き来する etc.
  5. // @version 1.1
  6. // @author euglenese
  7. // @match https://beta.atcoder.jp/contests/*
  8. // @match https://*.contest.atcoder.jp/*
  9. // @namespace https://greatest.deepsurf.us/users/201019
  10. // ==/UserScript==
  11.  
  12. function location_match(regex){
  13. return location.href.match(new RegExp(regex));
  14. }
  15.  
  16. function erase(text, regex){
  17. return text.replace(new RegExp(regex), "");
  18. }
  19.  
  20. var contest_name, position_name, linked;
  21.  
  22. function position_name_change(before, after){
  23. if(position_name == before){
  24. position_name = after;
  25. }
  26. }
  27.  
  28. var beta_contest_URL = "https\:\/\/beta\.atcoder\.jp\/contests\/";
  29. var https = "https\:\/\/";
  30. var contest_URL = "\.contest\.atcoder\.jp\/";
  31. var any_string = "[0-9a-z-_#]+";
  32. var any_string2 = "[0-9a-z-_#]*";
  33. var any_slash = "[0-9a-z-_#/]+";
  34.  
  35. if(location_match(beta_contest_URL)){
  36. if(location_match(beta_contest_URL + any_string + "\/" + any_slash)){
  37. contest_name = erase(location.href, beta_contest_URL).split("/")[0];
  38. position_name = erase(location.href, beta_contest_URL + contest_name + "/");
  39. position_name_change("tasks", "assignments");
  40. position_name_change("submissions", "submissions/all");
  41. linked = "https://" + contest_name + ".contest.atcoder.jp/" + position_name;
  42. }else{
  43. contest_name = erase(location.href, beta_contest_URL).split("/")[0];
  44. linked = "https://" + contest_name + ".contest.atcoder.jp/";
  45. }
  46. $(".contest-title").attr("href", linked);
  47. }else{
  48. if(location_match(https + any_string + contest_URL + any_slash)){
  49. contest_name = erase(erase(location.href, https), contest_URL + any_slash);
  50. position_name = erase(location.href, https + contest_name + contest_URL);
  51. position_name_change("submissions/all", "submissions");
  52. linked = "https://beta.atcoder.jp/contests/" + contest_name + "/" + position_name;;
  53. }else{
  54. contest_name = erase(erase(location.href, https), contest_URL);
  55. linked = "https://beta.atcoder.jp/contests/" + contest_name;
  56. }
  57. $(".brand").removeAttr("href");
  58. $(".contest-name").replaceWith(function() {
  59. $(this).replaceWith("<span class='contest-name'><a href='" + linked + "'>" + $(this).text() + "</a></span>");
  60. });
  61. $(".contest-name a").css("color", "white");
  62. $(".contest-name a").css("text-decoration", "none");
  63. for(var i in [0, 1]){
  64. $("time").eq(i).replaceWith(function() {
  65. console.log($(this).text());
  66. 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";
  67. $(this).replaceWith("<time class='timezone-fixed'><a href='" + url + "'>" + $(this).text() + "</a></time>");
  68. });
  69. $("time a").eq(i).css("color", "white");
  70. $("time a").css("text-decoration", "none");
  71. }
  72. }