atcoder-virtual-quick-vst

AtCoderバーチャル参加ページの開始時刻入力の簡略化。

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         atcoder-virtual-quick-vst
// @namespace    https://github.com/ilplrr
// @version      1.0
// @description  AtCoderバーチャル参加ページの開始時刻入力の簡略化。
// @author       ilplrr
// @match        https://atcoder.jp/contests/*/virtual
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const vstInputTag = document.querySelector('#vst-tmp');
    if (!vstInputTag) return;

    const div = document.createElement('div');
    div.style.textAlign = 'center';
    div.style.marginBottom = '15px';
    document.querySelector('#form-register').insertBefore(div, document.querySelectorAll('.form-group')[1]);

    const createBtn = (text, sec) => {
        const btn = document.createElement('input');
        btn.type = 'button';
        btn.value = text;
        btn.style.marginRight = '1rem';
        btn.addEventListener('click',() => {
            const vst = new Date();
            vst.setSeconds(vst.getSeconds() + sec);
            let s = '';
            s += [vst.getFullYear(), vst.getMonth()+1, vst.getDate()].map((x) => x.toString().padStart(2, '0')).join('-'); // yyyy-mm-dd
            s += ' ';
            s += [vst.getHours(), vst.getMinutes(), vst.getSeconds()].map((x) => x.toString().padStart(2, '0')).join(':'); // hh:mm:ss
            vstInputTag.value = s;
        });
        return btn;
    };

    div.appendChild(createBtn('10秒後', 10));
    div.appendChild(createBtn('1分後', 1*60));
    div.appendChild(createBtn('3分後', 3*60));
    div.appendChild(createBtn('5分後', 5*60));
})();