AddLinkToNewAtcoder

ja

As of 2017-10-23. See the latest version.

  1. // ==UserScript==
  2. // @name AddLinkToNewAtcoder
  3. // @namespace AddLinkToNewAtcoder
  4. // @version 1.1
  5. // @author Luzhiled
  6. // @description ja
  7. // @include http://*.contest.atcoder.jp/*
  8. // @include https://*.contest.atcoder.jp/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function ConvertToNewAtcodersURL(url, pathName, query) {
  16. console.log(pathName);
  17. if (pathName.match(/settings/) || pathName.match(/users/)) {
  18. return 'https://beta.atcoder.jp' + pathName;
  19. }
  20. let contestName = url.replace(/^https?:\/\//, '').split('.')[0];
  21. pathName = pathName.replace(/assignments/g, "tasks");
  22. pathName = pathName.replace(/\/all/g, "");
  23. query = query.replace(/user_screen_name/g, "f.User");
  24. pathName = pathName.replace(/editorial/g, "");
  25. pathName = pathName.replace(/statistics/g, "");
  26. return 'https://beta.atcoder.jp/contests/' + contestName + pathName + query;
  27. }
  28.  
  29. let linkToBeta = ConvertToNewAtcodersURL(location.href, location.pathname, location.search);
  30.  
  31. $('ul.nav.nav-tabs').append(`
  32. <li>
  33. <a href="${linkToBeta}">
  34. <i class="icon-user"></i>
  35. <span class="lang lang-selected">
  36. <span class="lang-en lang-child hidden-lang">to Beta version</span>
  37. <span class="lang-ja lang-child">Beta版へ</span>
  38. <span>
  39. </a>
  40. </li>
  41. `);
  42. })();