File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -160,14 +160,19 @@ function renderTabListEl(tab, space) {
160160 const linkEl = document . createElement ( 'a' ) ;
161161 const faviconEl = document . createElement ( 'img' ) ;
162162
163- // try to get best favicon url path
163+ // Use the provided favicon URL if it exists and is not a generic Chrome theme icon.
164164 if ( tab . favIconUrl && tab . favIconUrl . indexOf ( 'chrome://theme' ) < 0 ) {
165165 faviconSrc = tab . favIconUrl ;
166- } else {
167- // TODO(codedread): Fix this, it errors.
168- //faviconSrc = `chrome://favicon/${tab.url}`;
166+ // Otherwise, if the tab has a URL, construct a URL to fetch the favicon
167+ // via the extension's _favicon API. This is the recommended approach for Manifest V3.
168+ } else if ( tab . url ) {
169+ const pageUrl = encodeURIComponent ( tab . url ) ;
170+ faviconSrc = `chrome-extension://${ chrome . runtime . id } /_favicon/?pageUrl=${ pageUrl } &size=16` ;
171+ }
172+
173+ if ( faviconSrc ) {
174+ faviconEl . setAttribute ( 'src' , faviconSrc ) ;
169175 }
170- faviconEl . setAttribute ( 'src' , faviconSrc ) ;
171176
172177 linkEl . innerHTML = escapeHtml ( tab . title ?? tab . url ) ;
173178 linkEl . setAttribute ( 'href' , tab . url ) ;
You can’t perform that action at this time.
0 commit comments