AddLinkToNewAtcoder

ja

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

// ==UserScript==
// @name         AddLinkToNewAtcoder
// @namespace    AddLinkToNewAtcoder
// @version      1.2
// @author       Luzhiled
// @description  ja
// @include      http://*.contest.atcoder.jp/*
// @include      https://*.contest.atcoder.jp/*
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  function ConvertToNewAtcodersURL(url, pathName, query) {
    if (pathName.match(/settings/) || pathName.match(/users/)) {
      return 'https://beta.atcoder.jp' + pathName;
    }
    let contestName = url.replace(/^https?:\/\//, '').split('.')[0];
    pathName = pathName.replace(/assignments/g, "tasks");
    pathName = pathName.replace(/\/all/g, "");
    query = query.replace(/user_screen_name/g, "f.User");
    pathName = pathName.replace(/editorial/g, "");
    pathName = pathName.replace(/statistics/g, "");
    return 'https://beta.atcoder.jp/contests/' + contestName + pathName + query;
  }

  let linkToBeta = ConvertToNewAtcodersURL(location.href, location.pathname, location.search);

  $('ul.nav.nav-tabs').append(`
    <li>
      <a href="${linkToBeta}">
        <i class="icon-user"></i>
        <span class="lang lang-selected">
          <span class="lang-en lang-child hidden-lang">to Beta version</span>
          <span class="lang-ja lang-child">Beta版へ</span>
        <span>
      </a>
    </li>
  `);
})();