userscript.cf_email_decoder.js
This commit is contained in:
parent
54ed4afdcb
commit
3f97b892fc
|
@ -3,7 +3,7 @@
|
||||||
// @namespace https://codeberg.org/smege1001/cf_email_decoder
|
// @namespace https://codeberg.org/smege1001/cf_email_decoder
|
||||||
// @match *://*/*
|
// @match *://*/*
|
||||||
// @grant none
|
// @grant none
|
||||||
// @version 1.0
|
// @version 1.1
|
||||||
// @author smege1001
|
// @author smege1001
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
|
@ -35,14 +35,26 @@ for (var linksIndex = 0; linksIndex < links.length; linksIndex++) {
|
||||||
var link = links[linksIndex];
|
var link = links[linksIndex];
|
||||||
if (emailprotectionURLHashRegex.test(link.href)) {
|
if (emailprotectionURLHashRegex.test(link.href)) {
|
||||||
var hash = link.href.match(emailprotectionURLHashRegex)[1];
|
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")) {
|
} else if (emailprotectionURLNoHashRegex.test(link.href) && link.hasAttribute("data-cfemail")) {
|
||||||
var hash = link.getAttribute("data-cfemail");
|
var hash = link.getAttribute("data-cfemail");
|
||||||
var decodedEmail = decodeEmail(hash);
|
var decodedEmail = decodeEmail(hash);
|
||||||
|
|
||||||
link.href = "mailto:" + decodedEmail;
|
link.href = "mailto:" + decodedEmail;
|
||||||
link.innerText = decodedEmail; //the inner text is just [email protected]
|
link.innerText = decodedEmail; //the inner text is just [email protected]
|
||||||
|
|
||||||
//remove the useless attributes
|
//remove the useless attributes
|
||||||
link.removeAttribute("data-cfemail");
|
link.removeAttribute("data-cfemail");
|
||||||
link.classList.remove("__cf_email__");
|
link.classList.remove("__cf_email__");
|
||||||
|
|
Loading…
Reference in New Issue