document.addEventListener("DOMContentLoaded", () => document.querySelectorAll("pre.msh .js-copy").forEach((copy) => copy.addEventListener("click", (e) => e.preventDefault() content = copy.nextElementSibling range = document.createRange() range.selectNode(content) window.getSelection().addRange(range) try successful = document.execCommand("copy") copy.innerHTML = "Copied!" setTimeout => copy.innerHTML = "Copy" , 1500 msg = successful ? "successful" : "unsuccessful" console.log({ msg }) catch error console.log("Oops, unable to copy...") window.getSelection().removeAllRanges() ) ) document.querySelectorAll("pre.msh code[data-language='html'] span.line").forEach((line) => content = line.innerHTML content = content.replaceAll(/(<(\/?))(.+?(?=>))(>)/g, "$1$3$4") line.innerHTML = content pink = line.querySelector(".c2") if pink != null content = pink.innerHTML.split(" ") content = content.map((part, index) => if index > 0 if part.includes("=") part = part.replaceAll(/(.+?)(".*)/g, "$1$2") else part = part.replaceAll(/(.*\S)/g, "$1") part ).join(" ") pink.innerHTML = content return ) document.querySelectorAll("pre.msh code[data-language='css'] span.line").forEach((line) => content = line.innerHTML if line.dataset.indent content = content.split(/:/g).map((part, index) => if index == 0 part.replace(/(.*)/g, "$1") else part = part.replaceAll(/(\S.+?(?=\s|;))/g, "$1") part = part.replaceAll(/(".+?(?=,|\s|;))/g, "$1") part = part.replaceAll(/(url\(.+?(?=\s|;))/g, "$1") part.replaceAll(/\((.+?(?=\)))/g, "($1") ).join(":") else content = content.replaceAll(/(.+?(?=,|\s|{}))/g, "$1") content = content.replaceAll(/((\.|:).+?(?=\s))/g, "$1") line.innerHTML = content return ) )