mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-29 23:58:06 +01:00
ccab4ee1a4
* added drizzle app for testing * working * clean up * clean up script * make build step required * add drizzle-tests to .eslintignore * clean up drizzle run script * lint * use truffle unbox * undo eslintignore changes * revert change * dont use global * dont need this steps * use the new account flow * restore package-lock.json
60 lines
2.0 KiB
JavaScript
60 lines
2.0 KiB
JavaScript
window.onload = function () {
|
|
if (window.location.pathname === '/phishing.html') {
|
|
const {hostname} = parseHash()
|
|
document.getElementById('esdbLink').innerHTML = '<b>To read more about this scam, navigate to: <a href="https://etherscamdb.info/domain/' + hostname + '"> https://etherscamdb.info/domain/' + hostname + '</a></b>'
|
|
}
|
|
}
|
|
|
|
const querystring = require('querystring')
|
|
const dnode = require('dnode')
|
|
const { EventEmitter } = require('events')
|
|
const PortStream = require('extension-port-stream')
|
|
const extension = require('extensionizer')
|
|
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
|
|
const { getEnvironmentType } = require('./lib/util')
|
|
const ExtensionPlatform = require('./platforms/extension')
|
|
|
|
document.addEventListener('DOMContentLoaded', start)
|
|
|
|
function start () {
|
|
const windowType = getEnvironmentType(window.location.href)
|
|
|
|
global.platform = new ExtensionPlatform()
|
|
global.METAMASK_UI_TYPE = windowType
|
|
|
|
const extensionPort = extension.runtime.connect({ name: windowType })
|
|
const connectionStream = new PortStream(extensionPort)
|
|
const mx = setupMultiplex(connectionStream)
|
|
setupControllerConnection(mx.createStream('controller'), (err, metaMaskController) => {
|
|
if (err) {
|
|
return
|
|
}
|
|
|
|
const suspect = parseHash()
|
|
const unsafeContinue = () => {
|
|
window.location.href = suspect.href
|
|
}
|
|
const continueLink = document.getElementById('unsafe-continue')
|
|
continueLink.addEventListener('click', () => {
|
|
metaMaskController.whitelistPhishingDomain(suspect.hostname)
|
|
unsafeContinue()
|
|
})
|
|
})
|
|
}
|
|
|
|
function setupControllerConnection (connectionStream, cb) {
|
|
const eventEmitter = new EventEmitter()
|
|
const accountManagerDnode = dnode({
|
|
sendUpdate (state) {
|
|
eventEmitter.emit('update', state)
|
|
},
|
|
})
|
|
connectionStream.pipe(accountManagerDnode).pipe(connectionStream)
|
|
accountManagerDnode.once('remote', (accountManager) => cb(null, accountManager))
|
|
}
|
|
|
|
function parseHash () {
|
|
const hash = window.location.hash.substring(1)
|
|
return querystring.parse(hash)
|
|
}
|