atcoder-virtual-quick-vst

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

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