Reputation: 81
So i am working on a Chrome Extension that manages the user's bookmarks. What i want to do is display a box (a div) displaying the image associated with each bookmark and it's name under it. I am able to get the title and url stuff to work. But am unable to retrieve the icon associated with each bookmark.
Can someon please tell me how to do this ?
For reference my JS file is :
function list_bookmarks(bookmarks){
var i;
for ( i=0; i<bookmarks.length ; i++) {
console.log("Works" + i);
var current_bookmark = bookmarks[i];
if(current_bookmark.url) {
var icon = document.createElement('div');
icon.id = "pict";
icon.style.backgroundImage = current_bookmark.FAVICON; // Something here *
document.body.appendChild(icon);
var item = document.createElement('a');
item.className = 'block';
var linkText = document.createTextNode(current_bookmark.title);
item.appendChild(linkText);
item.title = current_bookmark.title;
item.href = current_bookmark.url;
document.body.appendChild(item);
console.log(current_bookmark.title); }
if(current_bookmark.children){ list_bookmarks(current_bookmark.children);}
}
}
window.onload = function(){
console.log("Listing Bookmarks Now :");
chrome.bookmarks.getTree(function(list){
list_bookmarks(list);
});
};
Thank You So Much.:)
Upvotes: 1
Views: 560
Reputation: 10897
chrome://favicon/
to the permissions
field in manifest.json
icon.style.backgroundImage = 'url(chrome://favicon/' + current_bookmark.url + ')';
See Issue 45474 for more details.
Upvotes: 3