|
| 1 | +// ==UserScript== |
| 2 | +// @name Improved Codeforces |
| 3 | +// @namespace com.edwinkofler |
| 4 | +// @version 0.2.1 |
| 5 | +// @description Improvements for Codeforces |
| 6 | +// @author Edwin Kofler |
| 7 | +// @match https://codeforces.com/* |
| 8 | +// @run-at document-end |
| 9 | +// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABPCAMAAAAqV5CTAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAJZQTFRFAAAAGY/NF4rKGpTRuhwkFYXHth0lvhwksh0lFIHF+9Zv9sVA+c9b98pO+MxU+dFh+tRo98hHG5jTFIDE+9hzwRwkwRwksR4mtx0lFYbI+tRo98pNF4nJ98lKGI/NtR0ltx0lFIHEvhwkGZHPuhwk+tJk+9dw98dFG5bSuxwk+9dw9sU/GI7Ntx0l9sVA9sZE9sZD+9Vs9xzUIQAAADJ0Uk5TAP//////////////////////u3eHOuVmUlVVU+EtkuwLDCBUySniDQ+yBdo2g4m567QkVzKVAAABaklEQVR4nO3Za2+CMBSAYTaHXAQUVOROQS5zgtP//+cGwhRGmzTxuCzLeb8WeEK/9VQQuErcKBBF8bXt5dossPbvfC9zlrgtMUaaIlDFVRQaAqokAQMJKjikUhjILIJD1kzEQgQRRBBBBJFbZRl25X0f4Eh4OpumruuGYWiatlwuV6vVxYNFwuPCnCBqMVQeRhqDhqjF5r5nDyOnBR1RixwOObIQ9b5hDyMLJrJB5KlIWmfx/NpblxRndQqKEOcgy/Mx0nTYQiJOLI8R6YpIdgqIZLJM+xNJqgkYspVZSJaCIQ4TsbdgyA6RX0eUf/MniCCCCCKIIIIIIogggshfRXimRC7HnRb7YNqcfnnmXQkT2d+eITELORCuyZ0QMRBrcM9Ys5B27uGfqYg3nKgmERUZGgKpYxpi79rF0v+cIhdvPLVN1sEUicZXmcTJpkjmkH659L/zunJhWuX27bsqypUscX6UUj70pL4AXxmrOcwVT6EAAAAASUVORK5CYII= |
| 10 | +// ==/UserScript== |
| 11 | +(function () { |
| 12 | + 'use strict'; |
| 13 | + |
| 14 | + const sheet = new CSSStyleSheet(); |
| 15 | + sheet.replaceSync('.sidebox { margin-bottom: 1em !important; }'); |
| 16 | + document.adoptedStyleSheets.push(sheet); |
| 17 | + |
| 18 | +const captions = document.querySelectorAll('.roundbox.sidebox .caption.titled'); |
| 19 | + for (const caption of captions) { |
| 20 | + if (!caption.textContent.includes('About Contest')) continue; |
| 21 | + if (caption.querySelector('.sidebar-caption-icon')) continue; |
| 22 | + |
| 23 | + const icon = document.createElement('i'); |
| 24 | + icon.className = 'sidebar-caption-icon las la-angle-right'; |
| 25 | + const topLinks = caption.querySelector('.top-links'); |
| 26 | + if (topLinks) { |
| 27 | + caption.insertBefore(icon, topLinks); |
| 28 | + } else { |
| 29 | + caption.appendChild(icon); |
| 30 | + } |
| 31 | + |
| 32 | + const siblings = []; |
| 33 | + let sibling = caption.nextElementSibling; |
| 34 | + while (sibling) { |
| 35 | + siblings.push(sibling); |
| 36 | + sibling = sibling.nextElementSibling; |
| 37 | + } |
| 38 | + if (siblings.length === 0) continue; |
| 39 | + |
| 40 | + for (const s of siblings) s.style.display = 'none'; |
| 41 | + |
| 42 | + icon.addEventListener('click', function (e) { |
| 43 | + e.preventDefault(); |
| 44 | + icon.classList.toggle('la-angle-down'); |
| 45 | + icon.classList.toggle('la-angle-right'); |
| 46 | + const collapsed = icon.classList.contains('la-angle-right'); |
| 47 | + for (const s of siblings) s.style.display = collapsed ? 'none' : ''; |
| 48 | + }); |
| 49 | + } |
| 50 | +})(); |
0 commit comments