diff options
author | Sebastian McKenzie <da94cbd8bad9d80980933bc473eea671a03afbd6@cloudflare.com> | 2020-07-31 13:14:41 +0200 |
---|---|---|
committer | Sebastian McKenzie <da94cbd8bad9d80980933bc473eea671a03afbd6@cloudflare.com> | 2020-07-31 13:14:41 +0200 |
commit | 3f97b892fc8382aa2cd5db764d27b0ebcc944ae0 (patch) | |
tree | 6af4286a74eecdacc5f5c1ce9e06eb9af4671cc5 /tool/userscript.cf_email_decoder.js | |
parent | 54ed4afdcbc060e093277bb07d0baad16fffb6f7 (diff) | |
download | cloudflare-tor-3f97b892fc8382aa2cd5db764d27b0ebcc944ae0.tar.lz cloudflare-tor-3f97b892fc8382aa2cd5db764d27b0ebcc944ae0.tar.xz cloudflare-tor-3f97b892fc8382aa2cd5db764d27b0ebcc944ae0.zip |
userscript.cf_email_decoder.js
Diffstat (limited to 'tool/userscript.cf_email_decoder.js')
-rw-r--r-- | tool/userscript.cf_email_decoder.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tool/userscript.cf_email_decoder.js b/tool/userscript.cf_email_decoder.js index eaf7b13a..b4678b83 100644 --- a/tool/userscript.cf_email_decoder.js +++ b/tool/userscript.cf_email_decoder.js @@ -3,7 +3,7 @@ // @namespace https://codeberg.org/smege1001/cf_email_decoder // @match *://*/* // @grant none -// @version 1.0 +// @version 1.1 // @author smege1001 // ==/UserScript== @@ -35,14 +35,26 @@ for (var linksIndex = 0; linksIndex < links.length; linksIndex++) { var link = links[linksIndex]; if (emailprotectionURLHashRegex.test(link.href)) { var hash = link.href.match(emailprotectionURLHashRegex)[1]; - link.href = "mailto:" + decodeEmail(hash); //replace the stupid email protection with just a mailto link + var decodedEmail = decodeEmail(hash); + + link.href = "mailto:" + decodedEmail; //replace the stupid email protection with just a mailto link + + if (link.getElementsByClassName("__cf_email__")) { + var linkChild = link.getElementsByClassName("__cf_email__")[0]; + linkChild.innerText = decodedEmail; + + linkChild.removeAttribute("data-cfemail"); + linkChild.classList.remove("__cf_email__"); + + if (linkChild.getAttribute("class") == "") linkChild.removeAttribute("class"); + } } else if (emailprotectionURLNoHashRegex.test(link.href) && link.hasAttribute("data-cfemail")) { var hash = link.getAttribute("data-cfemail"); var decodedEmail = decodeEmail(hash); link.href = "mailto:" + decodedEmail; link.innerText = decodedEmail; //the inner text is just [email protected] - + //remove the useless attributes link.removeAttribute("data-cfemail"); link.classList.remove("__cf_email__"); |