Content added Content deleted
(added text highlighter to editor please dont fuck it miraheze) |
(it doesnt work anyway bruh) |
||
Line 1: | Line 1: | ||
var syntaxElements = document.querySelectorAll("pre"); |
var syntaxElements = document.querySelectorAll("pre"); |
||
syntaxElements.forEach(checkSyntax); |
|||
function checkSyntax(code) { |
|||
if (code.textContent.indexOf("game.") > -1) { |
|||
code.innerHTML = code.textContent |
|||
.replace(".", "<span style='color: #b1ac8b;'>.</span>") |
|||
.replace("game", "<span style='color: #9cdcfe;'>game</span>"); |
|||
} |
|||
} |
|||
var sectionSyntax = document.querySelectorAll('.cm-mw-section-header'); |
|||
sectionSyntax.forEach(checkSectionSyntax); |
|||
function checkSectionSyntax(sectionText) { |
|||
if (sectionText.textContent.indexOf("==") > -1) { |
|||
var sectionHeader = '<span class="cm-mw-section-header">==</span>'; |
|||
if (sectionText.textContent == "===") { |
|||
var sectionHeader = '<span class="cm-mw-section-header">===</span>'; |
|||
} |
|||
var sectionParent = sectionText.parentElement; |
|||
if (sectionText.nextSibling != null) { |
|||
sectionParent.innerHTML = sectionHeader + "<span style='color: #d4f2ff;'>" + sectionText.nextSibling.textContent + "</span>" + sectionHeader; |
|||
} |
|||
} |
|||
} |
|||
var linkSyntax = document.querySelectorAll('.cm-mw-link-pagename'); |
|||
linkSyntax.forEach(checkLinkSyntax); |
|||
function checkLinkSyntax(linkText) { |
|||
if (linkText.textContent.indexOf("File") > -1) { |
|||
linkText.innerHTML = "File:<span style='color: #89ddff;'>" + linkText.textContent.slice(5); + "</span>"; |
|||
} |
|||
else { |
|||
linkText.innerHTML = "<span style='color: #89ddff;'>" + linkText.textContent + "</span>"; |
|||
} |
|||
var nodes = linkText.parentElement.getElementsByClassName("cm-mw-link-ground"); |
|||
for (var i = 0; i < nodes.length; i++) { |
|||
if (!nodes[i].classList.contains('cm-mw-link-bracket')) { |
|||
nodes[i].style.padding = "4px 0 4px 0"; |
|||
} |
|||
} |
|||
linkText.parentElement.firstElementChild.style.borderRadius = "0.4em 0 0 0.4em"; |
|||
linkText.parentElement.lastElementChild.style.borderRadius = "0 0.4em 0.4em 0"; |
|||
linkText.parentElement.firstElementChild.style.padding = "4px 0 4px 4px"; |
|||
linkText.parentElement.lastElementChild.style.padding = "4px 4px 4px 0"; |
|||
} |
} |
||
} |
Revision as of 21:38, 7 November 2023
var syntaxElements = document.querySelectorAll("pre");
syntaxElements.forEach(checkSyntax);
function checkSyntax(code) {
if (code.textContent.indexOf("game.") > -1) {
code.innerHTML = code.textContent
.replace(".", "<span style='color: #b1ac8b;'>.</span>")
.replace("game", "<span style='color: #9cdcfe;'>game</span>");
}
}