cremeaux/assets/js/main.js

20 lines
889 B
JavaScript
Raw Normal View History

2020-11-26 22:02:41 +01:00
const obfuscates = document.getElementsByClassName("obfuscate");
for (const element of obfuscates) {
2020-11-26 22:02:41 +01:00
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++) {
2020-11-26 22:02:41 +01:00
url += separators[i] + element.dataset["param" + (i+2)].split("").reverse().join("");
}
2020-11-26 22:02:41 +01:00
let text = element.dataset.param2.split("").reverse().join("");
for (let i = 1; i < separators.length; i++) {
2020-11-26 22:02:41 +01:00
text += separators[i] + element.dataset["param" + (i+2)].split("").reverse().join("");
}
2020-11-26 22:02:41 +01:00
link.innerText = url.replace(new RegExp(element.dataset.regex, 'i'), element.dataset.replace);
link.href = url;
link.rel = "nofollow";
element.parentElement.insertBefore(link, element);
}
2020-11-26 22:02:41 +01:00
while (obfuscates.length > 0) obfuscates[0].remove();