diff options
author | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2018-11-05 21:07:56 +0800 |
---|---|---|
committer | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-11-06 07:07:09 +0800 |
commit | 26ada8a828ab684c310080a18115a8ef3234aaee (patch) | |
tree | 5590e696390208691d61b5bdf82b80a9fe1ad27d /app/scripts/contentscript.js | |
parent | 31cb111d2e98c17728a75ebe00430654d827e136 (diff) | |
download | tangerine-wallet-browser-26ada8a828ab684c310080a18115a8ef3234aaee.tar tangerine-wallet-browser-26ada8a828ab684c310080a18115a8ef3234aaee.tar.gz tangerine-wallet-browser-26ada8a828ab684c310080a18115a8ef3234aaee.tar.bz2 tangerine-wallet-browser-26ada8a828ab684c310080a18115a8ef3234aaee.tar.lz tangerine-wallet-browser-26ada8a828ab684c310080a18115a8ef3234aaee.tar.xz tangerine-wallet-browser-26ada8a828ab684c310080a18115a8ef3234aaee.tar.zst tangerine-wallet-browser-26ada8a828ab684c310080a18115a8ef3234aaee.zip |
Update Connect Request screen design (#5644)
* Parameterize NetworkDisplay background colour
* Update design for login request screen
* Pass siteTitle, siteImage through for calls to ethereum.enable()
* Bring the site images closer together
Diffstat (limited to 'app/scripts/contentscript.js')
-rw-r--r-- | app/scripts/contentscript.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js index fa8b3207f..1cdc85945 100644 --- a/app/scripts/contentscript.js +++ b/app/scripts/contentscript.js @@ -126,6 +126,8 @@ function listenForProviderRequest () { extension.runtime.sendMessage({ action: 'init-provider-request', origin: source.location.hostname, + siteImage: getSiteIcon(source), + siteTitle: getSiteName(source), }) break case 'ETHEREUM_IS_APPROVED': @@ -285,3 +287,31 @@ function redirectToPhishingWarning () { href: window.location.href, })}` } + +function getSiteName (window) { + const document = window.document + const siteName = document.querySelector('head > meta[property="og:site_name"]') + if (siteName) { + return siteName.content + } + + return document.title +} + +function getSiteIcon (window) { + const document = window.document + + // Use the site's favicon if it exists + const shortcutIcon = document.querySelector('head > link[rel="shortcut icon"]') + if (shortcutIcon) { + return shortcutIcon.href + } + + // Search through available icons in no particular order + const icon = Array.from(document.querySelectorAll('head > link[rel="icon"]')).find((icon) => Boolean(icon.href)) + if (icon) { + return icon.href + } + + return null +} |