atcoder_all_open

問題Tabの隣に全ての問題を(ワンクリックで)開く全ての問題Tabを作成します。うまく動かない場合はatcoder上でのポップアップ制限を外して下さい

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name     atcoder_all_open
// @namespace jp.misw
// @author hotman
// @description 問題Tabの隣に全ての問題を(ワンクリックで)開く全ての問題Tabを作成します。うまく動かない場合はatcoder上でのポップアップ制限を外して下さい
// @version  1.0.9
// @include  https://atcoder.jp/contests/*
// @exclude  https://atcoder.jp/contests/
// @exclude  https://atcoder.jp/contests/archive
// @grant    none
// @description 問題Tabの隣に全ての問題を(ワンクリックで)開く全ての問題Tabを作成します。うまく動かない場合はatcoder上でのポップアップ制限を外して下さい
// ==/UserScript==


(() => {
    'use strict';
    const toURL = (flag = false) => {
        let url = location.href;
        let test_name = location.href.split('/')[4];
        if (flag === true || url.match(/atcoder.jp\/contests\/..*\/tasks$/) != null) {
            let table = document.getElementsByClassName("table table-bordered table-striped")[0].children[1];
            // 暴発防止のため、20問以上は読み込まない
            let cnt = Math.min(table.childElementCount, 20);
            for (let i = 0; i < cnt; i++) {
                let link = table.children[i].querySelector("a");
                window.open(link.href);
            }
        } else {
            window.open('https://atcoder.jp/contests/' + test_name + '/tasks\/?all_open=yes');
        }
    }

    const all_open = () => {
        var url = location.href;
        console.log(url);
        if (url.match(/all_open=yes/) != null) {
            toURL(true);
            window.open('about:blank', '_self').close();
        } else {
            let parent = document.getElementsByClassName("nav nav-tabs")[0];
            let add = document.createElement("li");
            parent.insertBefore(add, parent.children[2]);
            let a = document.createElement("a");
            add.appendChild(a);
            a.textContent = "全ての問題";
            a.setAttribute("href", "javascript:void(0);");
            a.addEventListener('click', toURL, false);
        }
    }
    all_open();
})();