How do I retrive bookmark icons?

Hello,

I am trying to make a start page extension clone, just like the firefox’s default newtab startpage.

I am currently having trouble with how do I retrieve the bookmarks icons given that I have a valid url?

If I try to do something like

let favicon = await fetch('http://www.youtube.com/favicon.ico')
console.log(favicon);

I get an error

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the
remote resource at https://www.youtube.com/favicon.ico.
(Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

I thought alternatively I can get the bookmark icon from the bookmarks api. But I couldn’t find anything about retrieving the favicon in the docs.

And when I log the bookmark object i get this:

Object { 
  id: "RllsohIbn0cg",
  title: "utube",
  index: 8,
  dateAdded: 1619912742004,
  type: "bookmark",
  url: "https://www.youtube.com/",
  parentId: "tVpVAI7jfEV1" 
}

So, how can I retrieve the bookmark icon?

Does it work for your scenario to simply create the <img src=""> tag or assign background-image: url() and let Firefox fetch the image that way?

1 Like

YES, that solved it. Thanks a lot.