aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/contentscript.js
diff options
context:
space:
mode:
authorsdtsui <szehungdanieltsui@gmail.com>2017-08-07 10:55:34 +0800
committersdtsui <szehungdanieltsui@gmail.com>2017-08-07 10:55:34 +0800
commit02c2106c3bb6900801cf5ffe4a1d9bd46183b089 (patch)
tree23f6d76a57c7b58a385ee49e8a24e402ed474775 /app/scripts/contentscript.js
parentfd36d95c506db55afa33a251c6c187c194a55854 (diff)
parent2ba5737728d2539fc3bc9015e440f37341219cdc (diff)
downloadtangerine-wallet-browser-02c2106c3bb6900801cf5ffe4a1d9bd46183b089.tar
tangerine-wallet-browser-02c2106c3bb6900801cf5ffe4a1d9bd46183b089.tar.gz
tangerine-wallet-browser-02c2106c3bb6900801cf5ffe4a1d9bd46183b089.tar.bz2
tangerine-wallet-browser-02c2106c3bb6900801cf5ffe4a1d9bd46183b089.tar.lz
tangerine-wallet-browser-02c2106c3bb6900801cf5ffe4a1d9bd46183b089.tar.xz
tangerine-wallet-browser-02c2106c3bb6900801cf5ffe4a1d9bd46183b089.tar.zst
tangerine-wallet-browser-02c2106c3bb6900801cf5ffe4a1d9bd46183b089.zip
Merge branch 'master' into feat/mm-ui-5
Diffstat (limited to 'app/scripts/contentscript.js')
-rw-r--r--app/scripts/contentscript.js22
1 files changed, 16 insertions, 6 deletions
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
index 291b922e8..6fde0edcd 100644
--- a/app/scripts/contentscript.js
+++ b/app/scripts/contentscript.js
@@ -37,28 +37,33 @@ function setupInjection () {
function setupStreams () {
// setup communication to page and plugin
- var pageStream = new LocalMessageDuplexStream({
+ const pageStream = new LocalMessageDuplexStream({
name: 'contentscript',
target: 'inpage',
})
pageStream.on('error', console.error)
- var pluginPort = extension.runtime.connect({name: 'contentscript'})
- var pluginStream = new PortStream(pluginPort)
+ const pluginPort = extension.runtime.connect({ name: 'contentscript' })
+ const pluginStream = new PortStream(pluginPort)
pluginStream.on('error', console.error)
// forward communication plugin->inpage
pageStream.pipe(pluginStream).pipe(pageStream)
// setup local multistream channels
- var mx = ObjectMultiplex()
+ const mx = ObjectMultiplex()
mx.on('error', console.error)
mx.pipe(pageStream).pipe(mx)
+ mx.pipe(pluginStream).pipe(mx)
// connect ping stream
- var pongStream = new PongStream({ objectMode: true })
+ const pongStream = new PongStream({ objectMode: true })
pongStream.pipe(mx.createStream('pingpong')).pipe(pongStream)
- // ignore unused channels (handled by background)
+ // connect phishing warning stream
+ const phishingStream = mx.createStream('phishing')
+ phishingStream.once('data', redirectToPhishingWarning)
+
+ // ignore unused channels (handled by background, inpage)
mx.ignoreStream('provider')
mx.ignoreStream('publicConfig')
}
@@ -88,3 +93,8 @@ function suffixCheck () {
}
return true
}
+
+function redirectToPhishingWarning () {
+ console.log('MetaMask - redirecting to phishing warning')
+ window.location.href = 'https://metamask.io/phishing.html'
+}