HighlightAtCoderContestNot2100

highlight in red AtCoder rated contests whose start time is not 21:00.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name       HighlightAtCoderContestNot2100
// @namespace 	https://greasyfork.org/users/201019
// @description highlight in red AtCoder rated contests whose start time is not 21:00.
// @version     1.1
// @author      Eug1ena
// @match       https://atcoder.jp/*
// ==/UserScript==

// https://atcoder.jp/ 用の部分 (日本語版、2021/05/23時点)
(function(){
    const contest_doms = document.querySelectorAll("ul.m-list_contest > li");

    contest_doms.forEach(function(contest){
        const rated_info = contest.querySelector("div.rated span").innerText;

        // Ratingの情報に数字か文字列"All"が含まれている場合にratedであると判定する
        if(rated_info.match(/[0-9]+/) || rated_info.match(/All/)){
            const time_dom = contest.querySelector("div.time time");
            const time_info = time_dom.innerText;

            if(!time_info.match(/21\:00/)){
                time_dom.style.color = "#ff0000";
                time_dom.style.backgroundColor = "#ffeeee";
            }
        }
    });
}());

// https://atcoder.jp/home 用の部分 (日本語版、2021/05/23時点)
(function(){
    const contest_doms = document.querySelectorAll("div#contest-table-active tbody tr, div#contest-table-upcoming tbody tr, div#contest-table-recent tbody tr");

    contest_doms.forEach(function(contest){
        console.log(contest)
        const rated_dom_class = contest.querySelector("small span").classList;

        if(rated_dom_class.contains("user-blue") || rated_dom_class.contains("user-orange") || rated_dom_class.contains("user-red")){
            const time_dom = contest.querySelector("small time");
            const time_info = time_dom.innerText;

            if(!time_info.match(/21\:00/)){
                time_dom.style.color = "#ff0000";
                time_dom.style.backgroundColor = "#ffeeee";
            }
        }
    });
}());