diff options
author | Saptak Sengupta <saptak013@gmail.com> | 2018-03-16 13:50:34 +0800 |
---|---|---|
committer | Saptak Sengupta <saptak013@gmail.com> | 2018-03-17 03:32:08 +0800 |
commit | 6174c00c1036e77e1dc2ec39f20cf3a2a8518a21 (patch) | |
tree | 4f7553c83dc566a7bab6c5d856558656a84034a2 /app/scripts | |
parent | e2efc91aee64072c408ab509219dcbfb389c7609 (diff) | |
download | tangerine-wallet-browser-6174c00c1036e77e1dc2ec39f20cf3a2a8518a21.tar tangerine-wallet-browser-6174c00c1036e77e1dc2ec39f20cf3a2a8518a21.tar.gz tangerine-wallet-browser-6174c00c1036e77e1dc2ec39f20cf3a2a8518a21.tar.bz2 tangerine-wallet-browser-6174c00c1036e77e1dc2ec39f20cf3a2a8518a21.tar.lz tangerine-wallet-browser-6174c00c1036e77e1dc2ec39f20cf3a2a8518a21.tar.xz tangerine-wallet-browser-6174c00c1036e77e1dc2ec39f20cf3a2a8518a21.tar.zst tangerine-wallet-browser-6174c00c1036e77e1dc2ec39f20cf3a2a8518a21.zip |
Inject Script: Blacklist domains where not to inject script
Put a blacklist domain check where if the page url is in the list
of blacklisted domains, we shouldn't inject script in that web page.
Diffstat (limited to 'app/scripts')
-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' |