-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdecrypt.emails.js
More file actions
30 lines (30 loc) · 903 Bytes
/
decrypt.emails.js
File metadata and controls
30 lines (30 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
fn.decrypt = wrap(() => {
const selector = 'a[href="/cdn-cgi/l/email-protection"]';
function hex_at(str, index) {
const r = str.substr(index, 2);
return parseInt(r, 16);
}
function decrypt(ciphertext) {
let output = "";
const key = hex_at(ciphertext, 0);
for(let i = 2; i < ciphertext.length; i += 2) {
const plaintext = hex_at(ciphertext, i) ^ key;
output += String.fromCharCode(plaintext);
}
return decodeURIComponent(escape(output));
}
function decode(doc) {
if (typeof jQuery === 'function' && doc instanceof jQuery) {
doc.find(selector).replaceWith(function () {
return decrypt(this.dataset.cfemail);
});
} else {
[...doc.querySelectorAll(selector)].forEach(function (el) {
el.replaceWith(decrypt(el.dataset.cfemail));
});
}
return doc;
}
decode.decrypt = decrypt;
return decode;
});