Created
October 30, 2021 15:43
-
-
Save derralf/d9df41a41a7933bf29a8000734dbf8a5 to your computer and use it in GitHub Desktop.
E-mail obfuscator for boop app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
{ | |
"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