cjplfybt
document.addEventListener("DOMContentLoaded", function () {
if (document.body.classList.contains("single-post")) {
let sectionCounter = 0;
let subsectionCounter = 0;
const container = document.querySelector("#page.hfeed.site");
if (!container) {
return; // Если контейнер не найден, прекращаем выполнение
}
function processHeadings(element) {
const children = Array.from(element.childNodes);
children.forEach((child) => {
if (child.nodeType === Node.ELEMENT_NODE) {
if (child.tagName === "H2") {
sectionCounter++;
subsectionCounter = 0; // Сбрасываем счётчик для H3
} else if (child.tagName === "H3") {
subsectionCounter++;
const counterText = `${subsectionCounter}`;
child.style.setProperty("--counter", `"${counterText}"`);
}
processHeadings(child);
}
});
}
processHeadings(container);
}
});
cjdhfydf