Skip to content

Instantly share code, notes, and snippets.

@derralf
Created October 30, 2021 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derralf/d9df41a41a7933bf29a8000734dbf8a5 to your computer and use it in GitHub Desktop.
Save derralf/d9df41a41a7933bf29a8000734dbf8a5 to your computer and use it in GitHub Desktop.
E-mail obfuscator for boop app
/**
{
"api":1,
"name":"Obfuscate E-Mail",
"description":"Obfuscates email address, uses alternating decimal code and hexadecimal code to make decryption difficult for harvesters.",
"author":"derralf",
"icon":"quote",
"tags":"encode,mail,obfuscate"
}
**/
function main(state) {
let originalString = state.text;
let encodedString = '';
let nowCodeString = '';
let originalLength = originalString.length;
state.text = originalString;
for (let i = 0; i < originalLength; i++) {
// Switch encoding odd/even
let encodeMode = (i%2 == 0) ? 1 : 2;
switch (encodeMode) {
case 1:
// Decimal code
nowCodeString = '&#' + originalString[i].charCodeAt(0) + ';';
break;
case 2:
// Hexadecimal code
nowCodeString = '&#x' + originalString[i].charCodeAt(0).toString(16) + ';';
break;
default:
state.postError("ERROR: wrong encoding mode.");
}
encodedString += nowCodeString;
}
state.text = encodedString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment