Change Email by Code

45

Dear Hype community,

does anybody know how I could set up my email via javascript? Due to security issues I don’t want my email displayed as clear text which you could show with browser developer tools - instead I would like to have some sort of an encrypted email address only a human eye would understand right away.

For example:
var_1 = “t”
var_2 = “es”
var_3 = “t@g”
var_4 = “ma”
var_5 = “il.co
var_6 = “m”

Email = str(var_1+var_2+var_3+var_4+var_5+var_6) = "test@gmail.com"

I must admit I’m not a programmer. I would be most grateful for some useful tips.
Thanks in advance,

Ilian

But, forgive me if I'm mis-understanding, the user will see an email address within the browser anyway so why do you want to make it obscure within the developer tools?

However, this would be similar to what you posted in Javascript.

var_1 = "t";
var_2 = "es";
var_3 = "t@g";
var_4 = "ma";
var_5 = "il.co";
var_6 = "m";

var email = var_1 +var_2 + var_3 + var_4 +var_5 + var_6;
// console.log(email) = test@gmail.com
1 Like

Thank you very much! :slight_smile:

I’m planing some sort of google’s “reCAPTCHA” for a static hype webpage, which I would like to share with the hype community when it’s ready. I’ve created a field with tiles. Once you’ve clicked the right ones the button to send an email is clickable and an image cover is moving aside from the button. To prevent bots from sending spam mails I need that “human verification” unless the bot has got an AI. In addition a good bot probably would find my mail address in the source code of the page if it is in clear text, therefore I came up with the idea, to make the email unreadable for malware.

What do you think?

If you don’t mind would you be so kind and could tell me how I can set the code up? Element ID of a button… I guess?

Something like:

var email = hypeDocument.getElementById('email_button').children[0];

or

var email = hypeDocument.getElementById('email_button').innerHTML;

When it comes to programming I’m totally without a paddle… I’m sorry.

Apologies, I’m not 100% sure what you are wanting to do.

Are you asking how you would add the code to a button click?

If so, you would create an action on a button and the option you would choose would be to run a new javascript function and then within the function you would then add your code.

Let us know a bit more on what you want to achieve and then we can offer a more detailed response :wink:

1 Like

Thank you very much for your patience DBear - I really appreciate.

If so, you would create an action on a button and the option you would choose would be to run a new javascript function and then within the function you would then add your code.

Exactly what I wanted to do so far but unfortunately this doesn't work... Therefore I thought I have to write more lines of code in order to make this script running properly. The Mac's email editor won't open.

I would like to simply send an email by clicking on the button like the predefined function "Compose Email" but instead of writing my email address in the textfield, I need to set it up via javascript to split the email address into sections unpractical to interpret for malware.

All in all this is the final step of my "reCAPTCHA" project. I created some sort of checkbox game to hide the email button. Once a user succeeds all the right images, he/she can email. This test should prevent bots from sending emails. But Google's reCAPTCHA in fact uses some sort of database request to reveal the actual email address. In order to guarantee a similar result on static websites, I would need some kind of "spaghettification" of my mail address. That's what I would like to achieve.

Add something like this to the end of your code.

location.href = 'mailto:' + email

2 Likes

Just like what Mark said. This is the process that a browser would use to send an email. “mailto:” followed by an email address. E.g

mailto:myemail@justanexample.com

This would then open the users email client and set up a new email to send.

So in your case. As Mark has clearly stated you could use location to set the browsers URL bar to load up the line with your email and the “mailto:” in front

1 Like

Thank you so much!
It works perfectly. 100% what I wanted to achieve.

And just to add, I use location.href ='mailto:' + email instead of window.open('mailto:' + email) to avoid a blank browser tab/window opening.

1 Like