Fix all the "[email protected]" instances
I somehow thought there were only two, but in fact there are a lot.
This commit is contained in:
parent
851543f44d
commit
6ba3246598
2 changed files with 17 additions and 10 deletions
|
|
@ -122,6 +122,12 @@ function getBodyXML(chapter, contentEl) {
|
|||
}
|
||||
});
|
||||
|
||||
// In Ward, CloudFlare email protection obfuscates the email addresses:
|
||||
// https://usamaejaz.com/cloudflare-email-decoding/
|
||||
for (const emailEl of contentEl.querySelectorAll("[data-cfemail]")) {
|
||||
const decoded = decodeCloudFlareEmail(emailEl.dataset.cfemail);
|
||||
emailEl.replaceWith(contentEl.ownerDocument.createTextNode(decoded));
|
||||
}
|
||||
|
||||
// Synthesize a <body> tag to serialize
|
||||
const bodyEl = contentEl.ownerDocument.createElement("body");
|
||||
|
|
@ -393,3 +399,14 @@ function isEmptyOrGarbage(el) {
|
|||
function escapeRegExp(str) {
|
||||
return str.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
|
||||
}
|
||||
|
||||
function decodeCloudFlareEmail(hash) {
|
||||
let email = "";
|
||||
const xorWithThis = parseInt(hash.substring(0, 2), 16);
|
||||
for (let i = 2; i < hash.length; i += 2) {
|
||||
const charCode = parseInt(hash.substring(i, i + 2), 16) ^ xorWithThis;
|
||||
email += String.fromCharCode(charCode);
|
||||
}
|
||||
|
||||
return email;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4121,16 +4121,6 @@
|
|||
"before": "<p>Ward is the second work in the Parahumans series, and reading <strong><a href=\"https://parahumans.wordpress.com/\">Worm</a></strong> first is strongly recommended. A lot of this won’t make sense otherwise and if you do find yourself a fan of the universe, the spoilers in Ward will affect the reading of the other work.</p>\n<p>Ward is not recommended for young or sensitive readers.</p>\n<hr/>",
|
||||
"after": "",
|
||||
"_comment": "This is out of place in an eBook."
|
||||
},
|
||||
{
|
||||
"before": "<a href=\"/cdn-cgi/l/email-protection\" class=\"__cf_email__\" data-cfemail=\"793d1c1f1c0b1c170d57303934181015\">[email protected]</a>",
|
||||
"after": "Deferent.I@Mail",
|
||||
"_comment": "These protected emails occur only twice in the entire book so we just hard-code it here instead of using techniques like https://usamaejaz.com/cloudflare-email-decoding/"
|
||||
},
|
||||
{
|
||||
"before": "<a href=\"/cdn-cgi/l/email-protection\" class=\"__cf_email__\" data-cfemail=\"b9fddcdfdccbdcd7cd97f0f9f4d8d0d5\">[email protected]</a>",
|
||||
"after": "Deferent.I@Mail",
|
||||
"_comment": "These protected emails occur only twice in the entire book so we just hard-code it here instead of using techniques like https://usamaejaz.com/cloudflare-email-decoding/"
|
||||
}
|
||||
],
|
||||
"https://www.parahumans.net/2017/11/21/daybreak-1-4/": [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue