forked from MetaMask/metamask-extension
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #460 from poanetwork/develop
5.2.5
- Loading branch information
Showing
9 changed files
with
561 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,35 @@ | ||
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') | ||
import querystring from 'querystring' | ||
import PortStream from 'extension-port-stream' | ||
const extension = require('extensionizer') | ||
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex | ||
const { getEnvironmentType } = require('./lib/util') | ||
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 windowType = getEnvironmentType(window.location.href) | ||
const hash = window.location.hash.substring(1) | ||
const suspect = querystring.parse(hash) | ||
|
||
document.getElementById('csdbLink').href = `https://cryptoscamdb.org/search` | ||
|
||
global.platform = new ExtensionPlatform() | ||
global.METAMASK_UI_TYPE = windowType | ||
|
||
const extensionPort = extension.runtime.connect({ name: windowType }) | ||
const extensionPort = extension.runtime.connect({ | ||
name: getEnvironmentType(), | ||
}) | ||
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() | ||
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 | ||
}) | ||
} | ||
|
||
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) | ||
} |
Oops, something went wrong.