mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
b50fe3184a
fixes #10090
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
import querystring from 'querystring';
|
|
import PortStream from 'extension-port-stream';
|
|
import extension from 'extensionizer';
|
|
import createRandomId from '../../shared/modules/random-id';
|
|
import { setupMultiplex } from './lib/stream-utils';
|
|
import { getEnvironmentType } from './lib/util';
|
|
import ExtensionPlatform from './platforms/extension';
|
|
|
|
document.addEventListener('DOMContentLoaded', start);
|
|
|
|
function start() {
|
|
const hash = window.location.hash.substring(1);
|
|
const suspect = querystring.parse(hash);
|
|
|
|
document.getElementById('csdbLink').href = `https://cryptoscamdb.org/search`;
|
|
|
|
global.platform = new ExtensionPlatform();
|
|
|
|
const extensionPort = extension.runtime.connect({
|
|
name: getEnvironmentType(),
|
|
});
|
|
const connectionStream = new PortStream(extensionPort);
|
|
const mx = setupMultiplex(connectionStream);
|
|
const backgroundConnection = mx.createStream('controller');
|
|
const continueLink = document.getElementById('unsafe-continue');
|
|
continueLink.addEventListener('click', () => {
|
|
backgroundConnection.write({
|
|
jsonrpc: '2.0',
|
|
method: 'safelistPhishingDomain',
|
|
params: [suspect.hostname],
|
|
id: createRandomId(),
|
|
});
|
|
window.location.href = suspect.href;
|
|
});
|
|
}
|