diff --git a/src/index.ts b/src/index.ts index 37df9fc..c947be4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -181,6 +181,20 @@ function start() { ]); const phishingSafelistStream = mux.createStream('metamask-phishing-safelist'); + const backToSafetyLink = document.getElementById('back-to-safety'); + if (!backToSafetyLink) { + throw new Error('Unable to locate back to safety link'); + } + + backToSafetyLink.addEventListener('click', async () => { + phishingSafelistStream.write({ + jsonrpc: '2.0', + method: 'backToSafetyPhishingWarning', + params: [], + id: createRandomId(), + }); + }); + const { hash } = new URL(window.location.href); const hashContents = hash.slice(1); // drop leading '#' from hash const hashQueryString = new URLSearchParams(hashContents); @@ -234,18 +248,4 @@ function start() { window.location.href = suspectHref; }); - - const backToSafetyLink = document.getElementById('back-to-safety'); - if (!backToSafetyLink) { - throw new Error('Unable to locate back to safety link'); - } - - backToSafetyLink.addEventListener('click', async () => { - phishingSafelistStream.write({ - jsonrpc: '2.0', - method: 'backToSafetyPhishingWarning', - params: [], - id: createRandomId(), - }); - }); }