atcoder-tasks-page-colorizer

tasksページにおいて、提出した問題に色付けを行います。

目前為 2021-12-31 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        atcoder-tasks-page-colorizer
// @namespace   https://twitter.com/kymn_
// @version     1.1.2
// @description tasksページにおいて、提出した問題に色付けを行います。
// @author      keymoon
// @license     MIT
// @supportURL  https://twitter.com/kymn_
// @match       https://atcoder.jp/contests/*/tasks
// @require     https://greasyfork.org/scripts/437862-atcoder-problems-api/code/atcoder-problems-api.js?version=1004082
// ==/UserScript==

if (moment() < endTime) return;

$('#main-div thead th:last-child').before('<th width="10%" class="text-center">最終提出</th>');
getSubmissions(userScreenName).then(colorize);

function colorize(problems_info) {
	$('#main-div tbody tr').each((x,y) => {
		let problem_id = y.querySelector('td:nth-child(2) a').getAttribute('href').split('/').pop();
		let trial = problems_info.filter(x => x.problem_id == problem_id);
		colorize_row(y,trial);
	})

	function colorize_row(row, trial) {
		var submitted = trial.length != 0;
		var is_accepted = trial.map(x => x.result).includes('AC');
		var last_submit = !submitted ? null : trial.reduce((x,y) => x.epoch_second > y.epoch_second ? x : y);
		$(row.querySelector('td:last-child')).before(`<td class="text-center">${submitted ? `<a href="https://atcoder.jp/contests/${last_submit.contest_id}/submissions/${last_submit.id}">${moment.unix(last_submit.epoch_second).format("YYYY/MM/DD")}</a>` : '-'}</td>`);
		if(submitted) row.classList.add(is_accepted ? 'success' : 'warning');
    }
}