AtCoder Problem Buttons

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

Tính đến 18-05-2022. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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.

(I already have a user style manager, let me install it!)

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