Skip to content

Commit

Permalink
Add FaviconKit support for favicons
Browse files Browse the repository at this point in the history
- Fixed issue with opening multiple new tabs
- Added option to always open bookmarks in the current tab
  • Loading branch information
pukmajster committed Apr 7, 2021
1 parent 1f054e3 commit 332e564
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const defaultConfig = `{
"bookmarkOptions": {
"alwaysOpenInNewTab": true,
"useFavicoKit": false
"useFaviconKit": false
},
"steamGames": [
Expand Down Expand Up @@ -74,7 +74,7 @@ const baseConfig = `{
"bookmarkOptions": {
"alwaysOpenInNewTab": true,
"useFavicoKit": false
"useFaviconKit": false
},
"steamGames": [
Expand Down
18 changes: 16 additions & 2 deletions js/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,25 @@ function Bookmark({ label, url, baseUrl, logoUrl }) {

let displayUrl = (baseUrl ?? url).replace('https://', '')

// Prep the URL for FaviconKit
let safeUrl = (logoUrl ?? baseUrl ?? url).replace('https://', '');
safeUrl.replace('http://', '');

let logoSrc =
config.bookmarkOptions.useFaviconKit
?
`https://api.faviconkit.com/${safeUrl}/16`
:
`http://www.google.com/s2/favicons?sz=192&domain_url=${logoUrl ?? baseUrl ?? url}`

let target = config.bookmarkOptions.alwaysOpenInNewTab ? '_blank' : '';
let rel = config.bookmarkOptions.alwaysOpenInNewTab ? 'noopener' : '';

return html`
<a target="_system" href="${url ?? baseUrl}" >
<a target="${rel}" href="${url ?? baseUrl}" rel="${rel}" >
<div class="Bookmark " >
<div class="BookmarkIcon" >
<img height="16" width="16" src='http://www.google.com/s2/favicons?sz=192&domain_url=${logoUrl ?? baseUrl ?? url}' />
<img height="16" width="16" src='${logoSrc}' />
</div>
<div class="BookmarkInfo" >
Expand Down

0 comments on commit 332e564

Please sign in to comment.