Greasy Fork is available in English.

AtCoderFavSubmissionFilter

AtCoderの「すべての提出」の現在のページでお気に入りユーザー以外を非表示にする

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         AtCoderFavSubmissionFilter
// @namespace    https://github.com/yayayaneko/AtCoderSubmissionFilters
// @version      0.1.0
// @description  AtCoderの「すべての提出」の現在のページでお気に入りユーザー以外を非表示にする
// @author       yayayaneko
// @license      MIT
// @match        https://atcoder.jp/contests/*/submissions*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=atcoder.jp
// @grant        none
// ==/UserScript==

(function() {
    "use strict";
    const fav = new Set(JSON.parse(localStorage.getItem("fav")) ?? []);

    function addCheckbox(applyFilterCallback) {
        const target = document.querySelector(".panel-submission .panel-heading form > div:last-child");
        if (!target) return;

        const containerDiv = document.createElement('div');
        const contentDiv = document.createElement("div");
        contentDiv.className = "checkbox";
        const label = document.createElement("label");
        const checkbox = document.createElement("input");
        checkbox.type = "checkbox";
        checkbox.id = "checkbox-fav-sub-only";

        checkbox.checked = localStorage.getItem("fav-sub-only")==="true";
        checkbox.addEventListener("change", () => {
            localStorage.setItem("fav-sub-only", checkbox.checked);
            applyFilterCallback(checkbox.checked);
        });

        label.appendChild(checkbox);
        label.appendChild(document.createTextNode(" お気に入りのみ表示"));
        contentDiv.appendChild(label);
        containerDiv.appendChild(contentDiv)
        target.after(containerDiv);
    }

    function applyFilter(filterflg) {
        const rows = document.querySelectorAll("table tbody tr");
        rows.forEach(row => {
            const username = row.querySelector("td:nth-child(3)").innerText.trim();
            row.style.display = (filterflg && !fav.has(username)) ? "none" : "";
        });
    }

    const observer = new MutationObserver(() => {
        const row = document.querySelector("tbody tr");
        if (row){
            observer.disconnect();
            addCheckbox(applyFilter);
            const lastState = localStorage.getItem("fav-sub-only")==="true";
            applyFilter(lastState);
        }
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();