AddLinkToNewAtcoder

ja

Versione datata 23/10/2017. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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