poweronoff.click/layouts/shortcodes/obfuscate.html
2021-09-17 15:20:18 +02:00

18 lines
709 B
HTML

{{/* shortcodes/obfuscate.html */}}
{{ $encoded := (.Inner | htmlEscape | markdownify | base64Encode) }}
{{ $halfLength := div (len $encoded) 2 }}
{{ $part1 := substr $encoded 0 $halfLength }}
{{ $part2 := substr $encoded $halfLength }}
<span id="mangled_{{ md5 $encoded }}">[ OBFUSCATED ]</span>
<script>
(() => {
let base64ToUnicode = str =>
decodeURIComponent(atob(str).split("").map(c =>
"%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join(""));
document.addEventListener("DOMContentLoaded", () => {
let element = document.getElementById("mangled_{{ md5 $encoded }}");
element.innerHTML = base64ToUnicode({{ $part1 }} + {{ $part2 }});
});
})();
</script>