AtCoder Problem Buttons

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

Stan na 18-05-2022. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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