Bold First Letter

𝗠ake 𝗲very 𝗳irst 𝗹etter 𝗶n 𝗲very 𝘄ord 𝗯𝗼𝗹𝗱.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Bold First Letter
// @namespace    https://codeforces.com/
// @version      0.2
// @description  𝗠ake 𝗲very 𝗳irst 𝗹etter 𝗶n 𝗲very 𝘄ord 𝗯𝗼𝗹𝗱.
// @author       𝗺agurofly
// @match        https://codeforces.com/contest/*/problem/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=codeforces.com
// @grant        unsafeWindow
// ==/UserScript==

(async function() {
    'use strict';

    await new Promise(done => setTimeout(done, 500));

    const doc = unsafeWindow.document;

    for (const paragraph of doc.querySelectorAll(".problem-statement p")) {
        for (const node of paragraph.childNodes) {
            if (node.nodeType !== node.TEXT_NODE) continue;

            const wordPattern = /^[-\w]+$/;
            const words = node.textContent.split(" ");
            const wrapper = doc.createElement("span");
            for (let i = 0; i < words.length - 1; i++) words[i] += " ";
            for (const word of words) {
                if (wordPattern.test(word[0])) {
                    const bold = doc.createElement("span");
                    bold.style.fontWeight = "600";
                    bold.style.color = "darkslateblue";
                    const m = Math.ceil(word.length * 0.25);
                    bold.textContent = word.slice(0, m);
                    const text = doc.createTextNode(word.slice(m));
                    wrapper.appendChild(bold);
                    wrapper.appendChild(text);
                } else {
                    wrapper.appendChild(doc.createTextNode(word));
                }
            }

            paragraph.insertBefore(wrapper, node);
            paragraph.removeChild(node);
        }
    }
})();