diff options
author | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-03-17 06:48:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-17 06:48:08 +0800 |
commit | 3bc8493166f14f075e688fe1050a035f4fa69c12 (patch) | |
tree | 364ecd5869b96dd35b51cc7ffd221c202209ddfb /app | |
parent | 6f749e5576cb981a469d0cf969b15901bcc05cfa (diff) | |
parent | 6174c00c1036e77e1dc2ec39f20cf3a2a8518a21 (diff) | |
download | tangerine-wallet-browser-3bc8493166f14f075e688fe1050a035f4fa69c12.tar tangerine-wallet-browser-3bc8493166f14f075e688fe1050a035f4fa69c12.tar.gz tangerine-wallet-browser-3bc8493166f14f075e688fe1050a035f4fa69c12.tar.bz2 tangerine-wallet-browser-3bc8493166f14f075e688fe1050a035f4fa69c12.tar.lz tangerine-wallet-browser-3bc8493166f14f075e688fe1050a035f4fa69c12.tar.xz tangerine-wallet-browser-3bc8493166f14f075e688fe1050a035f4fa69c12.tar.zst tangerine-wallet-browser-3bc8493166f14f075e688fe1050a035f4fa69c12.zip |
Merge pull request #3590 from SaptakS/feature/whitelist
Inject Script: Blacklist domains where not to inject script
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/contentscript.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js index 2ed7c87b6..7abbc60e7 100644 --- a/app/scripts/contentscript.js +++ b/app/scripts/contentscript.js @@ -96,7 +96,8 @@ function logStreamDisconnectWarning (remoteLabel, err) { } function shouldInjectWeb3 () { - return doctypeCheck() && suffixCheck() && documentElementCheck() + return doctypeCheck() && suffixCheck() + && documentElementCheck() && !blacklistedDomainCheck() } function doctypeCheck () { @@ -129,6 +130,20 @@ function documentElementCheck () { return true } +function blacklistedDomainCheck () { + var blacklistedDomains = ['uscourts.gov', 'dropbox.com'] + var currentUrl = window.location.href + var currentRegex + for (let i = 0; i < blacklistedDomains.length; i++) { + const blacklistedDomain = blacklistedDomains[i].replace('.', '\\.') + currentRegex = new RegExp(`(?:https?:\\/\\/)(?:(?!${blacklistedDomain}).)*$`) + if (!currentRegex.test(currentUrl)) { + return true + } + } + return false +} + function redirectToPhishingWarning () { console.log('MetaMask - redirecting to phishing warning') window.location.href = 'https://metamask.io/phishing.html' |