diff options
-rw-r--r-- | content.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/content.js b/content.js index 72ddcc4..4c219b3 100644 --- a/content.js +++ b/content.js @@ -24,9 +24,13 @@ function process(root) { // mailto links // format: <a href="/cdn-cgi/l/email-protection#{encrypted data}">...</a> for (const node of root.querySelectorAll('a')) { - const url = new URL(node.href) - if (url.pathname === '/cdn-cgi/l/email-protection' && url.hash !== '') - node.href = `mailto:${decode(url.hash.slice(1))}` + try { + const url = new URL(node.href) + if (url.pathname === '/cdn-cgi/l/email-protection' && url.hash !== '') + node.href = `mailto:${decode(url.hash.slice(1))}` + } catch { + // either there wasn't an href, or it wasn't a valid URL + } } // everything else Cloudflare thinks is an email |