diff options
author | bitpshr <mail@bitpshr.net> | 2018-10-02 08:52:31 +0800 |
---|---|---|
committer | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-11-06 07:07:09 +0800 |
commit | 89b4aa5d62237f36fac9dcce9c546005ec18968b (patch) | |
tree | 38bb13f74680cff733c330b2009eddbf4770a098 /app/scripts/contentscript.js | |
parent | c76c9ca2c86317f902f443db2c5704d4bf6311c0 (diff) | |
download | tangerine-wallet-browser-89b4aa5d62237f36fac9dcce9c546005ec18968b.tar tangerine-wallet-browser-89b4aa5d62237f36fac9dcce9c546005ec18968b.tar.gz tangerine-wallet-browser-89b4aa5d62237f36fac9dcce9c546005ec18968b.tar.bz2 tangerine-wallet-browser-89b4aa5d62237f36fac9dcce9c546005ec18968b.tar.lz tangerine-wallet-browser-89b4aa5d62237f36fac9dcce9c546005ec18968b.tar.xz tangerine-wallet-browser-89b4aa5d62237f36fac9dcce9c546005ec18968b.tar.zst tangerine-wallet-browser-89b4aa5d62237f36fac9dcce9c546005ec18968b.zip |
EIP-1102: Add option to force-enable provider
Diffstat (limited to 'app/scripts/contentscript.js')
-rw-r--r-- | app/scripts/contentscript.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js index 060343031..1788cfc36 100644 --- a/app/scripts/contentscript.js +++ b/app/scripts/contentscript.js @@ -24,6 +24,7 @@ if (shouldInjectWeb3()) { injectScript(inpageBundle) setupStreams() listenForProviderRequest() + checkForcedInjection() } /** @@ -134,10 +135,28 @@ function listenForProviderRequest () { case 'reject-provider-request': injectScript(`window.dispatchEvent(new CustomEvent('ethereumprovider', { detail: { error: 'User rejected provider access' }}))`) break + case 'force-injection': + extension.storage.local.get(['forcedOrigins'], ({ forcedOrigins = [] }) => { + extension.storage.local.set({ forcedOrigins: [ ...forcedOrigins, window.location.hostname ] }, () => { + injectScript(`window.location.reload()`) + }) + }) + break } }) } +/** + * Checks the current origin to see if it exists in the extension's locally-stored list + * off user-whitelisted dapp origins. If it is, this origin will be marked as approved, + * meaning the publicConfig stream will be enabled. This is only meant to ease the transition + * to 1102 and will be removed in the future. + */ +function checkForcedInjection () { + extension.storage.local.get(['forcedOrigins'], ({ forcedOrigins = [] }) => { + originApproved = forcedOrigins.indexOf(window.location.hostname) > -1 + }) +} /** * Error handler for page to plugin stream disconnections |