Skip to content

Commit

Permalink
backport href migration (#135)
Browse files Browse the repository at this point in the history
* move btn
  • Loading branch information
witmicko authored Dec 13, 2023
1 parent a349cbf commit 721c57e
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(),
});
});
}

0 comments on commit 721c57e

Please sign in to comment.