hugo-theme-lowtech/assets/js/main.js

20 lines
889 B
JavaScript
Raw Normal View History

2021-03-13 00:17:54 +01:00
const obfuscates = document.getElementsByClassName("obfuscate");
for (const element of obfuscates) {
const link = document.createElement("a");
const separators = element.dataset.separators;
const protocol = element.dataset.param1.split("").reverse().join("");
let url = protocol;
for (let i = 0; i < separators.length; i++) {
url += separators[i] + element.dataset["param" + (i+2)].split("").reverse().join("");
}
let text = element.dataset.param2.split("").reverse().join("");
for (let i = 1; i < separators.length; i++) {
text += separators[i] + element.dataset["param" + (i+2)].split("").reverse().join("");
}
link.innerText = url.replace(new RegExp(element.dataset.regex, 'i'), element.dataset.replace);
link.href = url;
link.rel = "nofollow";
element.parentElement.insertBefore(link, element);
}
while (obfuscates.length > 0) obfuscates[0].remove();