Feature #81939
openAllow right click and copy for spam protected email addresses
0%
Description
Currently, if someone right clicks and copies a spam protected email address, they get javascript:linkTo_UnCryptMailto('sdfgserwhatevereteggh');
For email where the link text is not the address, I could see those who don't use an email client being unsure of how to get the address.
What I've experimented with is triggering a function on opening the context menu, to replace the href contents with the correct email.
Example here: https://jsfiddle.net/nhaskins/1nk7ky75/2/
I've tested this in TYPO3 by adding the following function to typo3/sysext/frontend/Classes/Page/PageGenerator.php at line 756 (end of $scriptJsCode)
function UnCryptMailto(el) {
var str = el.getAttribute("href").split("\'")[1];
el.setAttribute("href", decryptString(str,' . $tsfe->spamProtectEmailAddresses * -1 . '));
el.removeAttribute("oncontextmenu");
}
and the following in typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php at line 5646 (just before $tagAttributes = [];)
if ($tsfe->spamProtectEmailAddresses) {
$finalTagParts['aTagParams'] .= ' oncontextmenu="UnCryptMailto(this)"';
}
I'm pretty sure this isn't the best way to include the oncontextmenu attribute, and it looks like it would need to be added to at least the f:link.email viewhelper as well.