AddLinkToNewAtcoder

ja

ของเมื่อวันที่ 23-10-2017 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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>
  `);
})();