1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
document.addEventListener("DOMContentLoaded", () => {
const d = document, m = Math,
h = d.documentElement,
c = d.cookie.split("; "),
t = c.find(r => r.startsWith("theme=")),
o = "path=/; samesite=strict; expires",
q = "querySelectorAll",
l = "classList";
h[l][(t && t.split("=")[1] == "invert")?"add":"remove"]("invert");
d.querySelector("#invert").addEventListener("click", () =>
d.cookie = h[l].toggle("invert")?
`theme=invert; ${o}=Fri, 31 Dec 9999 23:59:59 GMT`:
`theme=; ${o}=Thu, 01 Jan 1970 00:00:00 GMT`);
// Add line numbers to code blocks
[...d[q]("pre.hljs code")].forEach(e => e.innerHTML =
e.innerHTML.split("\n").map((l,i,a) => l &&
`<div class="code-line" data-line-number="${
(i+1).toString().padStart(Math.ceil(Math.log10(a.length)), 0)
}">${l}</div>`).join("\n"));
// Disable Android Chrome "tap to search" when revealing spoiler text
[...d[q]("mark")].forEach(e => e.tabIndex = "-1");
const ZLM_UNICODE_START = 0xED80;
const LERFU_INDEX = "ptkflscmx.' 1234bdgvrzjn`-,~ aeiouy qw AEIOUY";
const lerfuLookup = c => String.fromCodePoint(ZLM_UNICODE_START + LERFU_INDEX.indexOf(c));
function latinToZlm(c) {
if (c.codePointAt(0) == 0x2019) c = "'";
if (c.codePointAt(0) >= 0xED80) return c;
if (" \n\t".includes(c)) return c;
if (c == "h" || c == "H") c = "'";
if (LERFU_INDEX.indexOf(c) >= 0) return lerfuLookup(c);
if (LERFU_INDEX.indexOf(c.toLowerCase()) >= 0) return lerfuLookup(c.toLowerCase());
return c;
}
[...d[q]("[lang=jbo]")].forEach(e => e.innerText = e.innerText.split("").map(latinToZlm).join(""));
});
|