AtCoder Problem Buttons

問題選択を一度に行えるボタンを追加します

2022-05-18 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name    AtCoder Problem Buttons
// @namespace    http://tampermonkey.net/
// @version    0.1
// @description    問題選択を一度に行えるボタンを追加します
// @author    Chippppp
// @license    MIT
// @match    https://atcoder.jp/contests/*/submit*
// @grant    none
// ==/UserScript==

(function() {
    "use strict";
    let problemButton = document.getElementsByClassName("select2 select2-container select2-container--bootstrap")[0];
    let problemButtons = [];
    for (let i of document.getElementById("select-task").children) {
        let button = document.createElement("button");
        if (problemButtons.length == 0) problemButton.after(button);
        else problemButtons.slice(-1)[0].after(button);
        button.className = "btn btn-default";
        button.type = "button";
        button.innerText = i.innerText;
        button.value = i.value;
        problemButtons.push(button);
    }
    for (let i of problemButtons) {
        i.addEventListener("click", function() {
            for (let button of problemButtons) button.className = "btn btn-default";
            this.className = "btn btn-success";
            document.getElementById("select-task").value = this.value;
            document.getElementById("select2-select-task-container").innerText = i.innerText;
        });
        if (i.innerText == problemButton.innerText) i.click();
    }
    let observer = new MutationObserver(function() {
        for (let i of problemButtons) if (i.innerText == problemButton.innerText) i.click();
    });
    const config = {
        attributes: true,
        childList: true,
        characterData: true,
    };
    observer.observe(document.getElementsByClassName("select2-selection select2-selection--single")[0], config);
})();