hide single problem tag on CF

hide single problem tag on Codeforces

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         hide single problem tag on CF
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  hide single problem tag on Codeforces
// @author       ouuan
// @match        https://codeforces.com/*
// @match        https://codeforc.es/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var cur = 0;
    var tags, btn, hint;

    function change() {
        if (cur ^= 1) {
            tags.style.display = 'block';
            hint.style.display = 'none';
            btn.innerText = '▲';
        } else {
            hint.style.display = 'block';
            tags.style.display = 'none';
            btn.innerText = '▼';
        }
    }

    var boxes = document.querySelectorAll('.roundbox.sidebox');

    for (var box of boxes) {
        if (box.innerText.match('Problem tags')) {
            tags = box.children[3];
            tags.style.display = 'none';
            hint = document.createElement('span');
            hint.innerText = 'Tags are hidden.';
            hint.style.padding = '0.5em';
            hint.style.display = 'block';
            box.appendChild(hint);
            btn = document.createElement('span');
            btn.style.cursor = 'pointer';
            btn.innerText = '▼';
            btn.onclick = change;
            box.children[2].appendChild(btn);
        }
    }
})();