Favicon as icon for bookmark/web archive?

In list views of bookmarks and web archives, it’d be great if the icon were the favicon for the site, rather than a very tiny thumbnail or generic “web page” icon.

Thanks for the suggestion. First request I’ve seen.

DEVONthink “bookmarks” are standard OS X .webloc plists, which store only the URL of the site. There were some old OS X utilities (“Faviconic” or something like that, IIRC) that set the icon of the .webloc to the favicon. I don’t know if those apps are still around.

But DEVONthink is currently able to display a thumbnail as an icon, right? Where is that stored, and wouldn’t that mean an icon could be stored as well?

You can create thumbnails for bookmarks via Data > Thumbnail.

Just for the heck of it: Here’s a JXA script that sets the thumbnail of the currently selected bookmark(s) to the favicon of the site (if there is one). It recognizes link rel="icon" elements in the HTML head, “favicon.*” images and images ending in “.ico”. The first one found is set as thumbnail.
NOTE: This script can not be used in a smart rule (yet), since JXA in DT smart rules is still broken. A fix is announced for one of the next DT versions.

(() => {
  
  const app = Application("DEVONthink 3");
  app.includeStandardAdditions = true;
  const records = app.selectedRecords.whose( {_match: [ObjectSpecifier().type, "bookmark"]})();
  records.forEach(r => {
    let favicon = "";
    let found = false;
    const URL = r.url();
    const domain = URL.split('/').slice(0,3).join('/');
    
    const HTML = app.downloadMarkupFrom(URL);
    const embImages = app.getEmbeddedImagesOf(HTML, { baseURL: domain});
    
    if (embImages.length > 0) {
      for (let img of embImages) {
        
        /*
        if img ends with ".ico" or img contains "/favicon" 
            or img is part of a <link rel="icon" ...> element in the header, then
          set favicon to img
          exit loop
        */
        found = /favicon|\.ico$/.test(img) || RegExp(`<link.*rel="icon".*${img}`).test(HTML);
        if (found) {
          favicon = img;
          break; /* exit the loop here */
        }
      }
      if (found && favicon !== "") {
        r.thumbnail = favicon;
      }
    }
  });
})()
1 Like