Bold First Letter

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

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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);
        }
    }
})();