mirror of
https://github.com/falsycat/ar.falsy.cat.git
synced 2024-10-29 17:04:52 +00:00
18 lines
505 B
JavaScript
18 lines
505 B
JavaScript
|
|
function addTitleToCodeBlocks() {
|
|
const els = document.getElementsByClassName("highlight");
|
|
for (let i = 0; i < els.length; i++) {
|
|
try {
|
|
if (els[i].title.length) {
|
|
let div = document.createElement("div");
|
|
if (els[i].getElementsByClassName("code-title").length) continue;
|
|
div.textContent = els[i].title;
|
|
div.classList.add("code-title")
|
|
els[i].insertBefore(div, els[i].firstChild);
|
|
}
|
|
} catch (error) {
|
|
console.debug(error);
|
|
}
|
|
}
|
|
}
|