From cbce677b33d02cc08b9af484ac3833566b334921 Mon Sep 17 00:00:00 2001 From: Ben Pevsner Date: Sun, 29 Jul 2018 18:41:28 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20Allow=20overriding=20favicon.ico?= =?UTF-8?q?=20(#27)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 2 +- package.json | 2 +- source/contentScript.js | 2 +- source/utilities/faviconHelpers.js | 10 +++++++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index f56dc38..539cf0e 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Favioli", "description": "Emoji favicons for the web", - "version": "0.3.2", + "version": "0.3.3", "background": { "scripts": [ "build/background.js" ] }, diff --git a/package.json b/package.json index dc66705..d71cf73 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "favioli", - "version": "0.3.2", + "version": "0.3.3", "author": "Ben Pevsner", "license": "Unlicense", "description": "Emoji Favicons for the web", diff --git a/source/contentScript.js b/source/contentScript.js index c06bef4..a2cbda9 100644 --- a/source/contentScript.js +++ b/source/contentScript.js @@ -9,5 +9,5 @@ getSettings().then(settings => { function updateFavicon({ name, shouldOverride }) { if (shouldOverride) removeAllFaviconLinks(); - appendFaviconLink(name); + appendFaviconLink(name, shouldOverride); } diff --git a/source/utilities/faviconHelpers.js b/source/utilities/faviconHelpers.js index 129cf66..d24bd89 100644 --- a/source/utilities/faviconHelpers.js +++ b/source/utilities/faviconHelpers.js @@ -22,19 +22,23 @@ const memoizedEmojiUrl = memoize(createEmojiUrl); /** * Given an emoji string, append it to the document head * @param {string} name + * @param {boolean} shouldOverride */ let existingFavicon = null; -export function appendFaviconLink(name) { +export function appendFaviconLink(name, shouldOverride) { const href = memoizedEmojiUrl(name); if (existingFavicon) { existingFavicon.setAttribute("href", href); } else { const link = createLink(href, EMOJI_SIZE, "image/png"); - const defaultLink = createLink("/favicon.ico"); existingFavicon = documentHead.appendChild(link); - documentHead.appendChild(defaultLink); + + if (!shouldOverride) { + const defaultLink = createLink("/favicon.ico"); + documentHead.appendChild(defaultLink); + } } }