Skip to content

Commit

Permalink
πŸ‘Œ Allow overriding favicon.ico (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Pevsner committed Jul 30, 2018
1 parent 5e73683 commit cbce677
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion source/contentScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ getSettings().then(settings => {
function updateFavicon({ name, shouldOverride }) {
if (shouldOverride) removeAllFaviconLinks();

appendFaviconLink(name);
appendFaviconLink(name, shouldOverride);
}
10 changes: 7 additions & 3 deletions source/utilities/faviconHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit cbce677

Please sign in to comment.