AtCoder-Submission-RadioButton

AtCoderで提出時ラジオボタンを生成します

目前為 2019-10-06 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         AtCoder-Submission-RadioButton
// @namespace    https://github.com/penicillin0/
// @version      0.1.1
// @description  AtCoderで提出時ラジオボタンを生成します
// @author       penicillin0
// @license      MIT
// @match        https://atcoder.jp/contests/*/submit*
// @supportURL   https://twitter.com/penicillin0at
// ==/UserScript==

(function () {
    'use strict';
    // 問題名を配列に
    const problem_names_Elements = document.getElementById('select-task').children;

    //問題ごとにループ
    for (var i = 0; i < problem_names_Elements.length; i++) {
        const problem_name = problem_names_Elements[i].innerHTML

        // ボタンの作成
        const button_txt = `<input type="radio" value="ボタン2" name="quiz" onclick="clickBtn(${i});" />${problem_name}<br>`
        // ボタンの挿入位置
        const button_place = document.querySelector('div.col-sm-12 span.error');
        // ボタンの挿入
        button_place.insertAdjacentHTML('beforebegin', button_txt);
    };

    // scriptの作成
    const script_elem = document.createElement("script");
    // scriptの中身
    script_elem.innerText = `function clickBtn(index) {
        document.getElementById('select-task').selectedIndex = index;
    };`
    // buttonの下の挿入
    const button_place = document.querySelector('div.col-sm-12 span.error');
    button_place.appendChild(script_elem);
})();