atcoder-traffic

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

Versione datata 06/08/2018. 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        atcoder-traffic
// @namespace
// @description beta.atcoder.jpとatcoder.jpのコンテストサイトを行き来する etc.
// @version     1.1
// @author      euglenese
// @match       https://beta.atcoder.jp/contests/*
// @match       https://*.contest.atcoder.jp/*
// @namespace https://greasyfork.org/users/201019
// ==/UserScript==

function location_match(regex){
	return location.href.match(new RegExp(regex));
}

function erase(text, regex){
	return text.replace(new RegExp(regex), "");
}

var contest_name, position_name, linked;

function position_name_change(before, after){
	if(position_name == before){
		position_name = after;
	}	
}

var beta_contest_URL = "https\:\/\/beta\.atcoder\.jp\/contests\/";
var https = "https\:\/\/";
var contest_URL = "\.contest\.atcoder\.jp\/";
var any_string = "[0-9a-z-_#]+";
var any_string2 = "[0-9a-z-_#]*";
var any_slash = "[0-9a-z-_#/]+";

if(location_match(beta_contest_URL)){
	if(location_match(beta_contest_URL + any_string + "\/" + any_slash)){
		contest_name = erase(location.href, beta_contest_URL).split("/")[0];
		position_name = erase(location.href, beta_contest_URL + contest_name + "/");
		position_name_change("tasks", "assignments");
		position_name_change("submissions", "submissions/all");
		linked = "https://" + contest_name + ".contest.atcoder.jp/" + position_name;
	}else{
		contest_name = erase(location.href, beta_contest_URL).split("/")[0];
		linked = "https://" + contest_name + ".contest.atcoder.jp/";
	}
	$(".contest-title").attr("href", linked);
}else{
	if(location_match(https + any_string + contest_URL + any_slash)){
		contest_name = erase(erase(location.href, https), contest_URL + any_slash);
		position_name = erase(location.href, https + contest_name + contest_URL);
		position_name_change("submissions/all", "submissions");
		linked = "https://beta.atcoder.jp/contests/" + contest_name + "/" + position_name;;
	}else{
		contest_name = erase(erase(location.href, https), contest_URL);
		linked = "https://beta.atcoder.jp/contests/" + contest_name;
	}
	$(".brand").removeAttr("href");
	$(".contest-name").replaceWith(function() {
  		$(this).replaceWith("<span class='contest-name'><a href='" + linked + "'>" + $(this).text() + "</a></span>");
	});
	$(".contest-name a").css("color", "white");
	$(".contest-name a").css("text-decoration", "none");
	for(var i in [0, 1]){
		$("time").eq(i).replaceWith(function() {
			console.log($(this).text());
			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";
	  		$(this).replaceWith("<time class='timezone-fixed'><a href='" + url + "'>" + $(this).text() + "</a></time>");
		});
		$("time a").eq(i).css("color", "white");
		$("time a").css("text-decoration", "none");
	}
}