atcoder-tasks-dropdown-menu-colorizer

Apply the same coloring as the atcoder-tasks-page-colorizer in the drop-down menu of tasks added by Comfortable AtCoder.

Από την 29/04/2022. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        atcoder-tasks-dropdown-menu-colorizer
// @namespace   https://twitter.com/KakurenboUni
// @version     1.0.0
// @require     https://greasyfork.org/scripts/437862-atcoder-problems-api/code/atcoder-problems-api.js?version=1004082
// @match       https://atcoder.jp/*
// @description Apply the same coloring as the atcoder-tasks-page-colorizer in the drop-down menu of tasks added by Comfortable AtCoder.
// @author      uni-kakurenbo
// @license     MIT
// @supportURL  https://twitter.com/KakurenboUni
// ==/UserScript==

getSubmissions(userScreenName).then(colorize);

function colorize(problems_info) {
	let tabs = document.querySelector(".nav-tabs").querySelectorAll("li");
    const tasks = [].find.call(tabs, (tab) => tab?.innerText.match(/問題|Tasks/ig));
    tasks.querySelector(".dropdown-menu").querySelectorAll("li").forEach((y) => {
		const problem_id = y.querySelector('a').getAttribute('href').split('/').pop();
		const trial = problems_info.filter(x => x.problem_id == problem_id);
        if(trial.length != 0) y.classList.add(trial.map(x => x.result).includes('AC') ? 'bg-success' : 'bg-warning');
	});
}