diff options
-rw-r--r-- | content.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/content.js b/content.js index 4c219b3..1ea1429 100644 --- a/content.js +++ b/content.js @@ -10,19 +10,19 @@ function decodeHtml(str) { return doc.documentElement.textContent } -// decodes a "protected" "email" +// decodes an obfuscated e-mail function decode(data) { const [key, ...encoded] = data.match(/.{2}/g).map(e => parseInt(e, 16)) - const bytes = encoded.map(e => String.fromCharCode(e ^ key)).join("") + const bytes = encoded.map(e => String.fromCharCode(e ^ key)).join('') // not sure why the proprietary code decodes entities, but I'm not changing it return decodeHtml(decodeUtf8(bytes)) } -// processes a document fragment for "protected" "emails" +// processes a document fragment for obfuscated e-mails function process(root) { // mailto links - // format: <a href="/cdn-cgi/l/email-protection#{encrypted data}">...</a> + // format: <a href="/cdn-cgi/l/email-protection#{obfuscated data}">...</a> for (const node of root.querySelectorAll('a')) { try { const url = new URL(node.href) @@ -33,8 +33,8 @@ function process(root) { } } - // everything else Cloudflare thinks is an email - // format: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="{encrypted data}">[email protected]</a> + // everything else Cloudflare thinks is an e-mail + // format: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="{obfuscated data}">[email protected]</a> for (const node of root.querySelectorAll('.__cf_email__')) node.replaceWith(decode(node.getAttribute('data-cfemail'))) |