MozillaZine

webextension get favicon from bookmark [solved for now]

Talk about add-ons and extension development.
Brummelchen
 
Posts: 2289
Joined: March 19th, 2005, 10:51 am

Post Posted September 2nd, 2017, 4:40 am

this is what i need to replace:
Code: Select all
img.src = "chrome://favicon/" + url_;

but i did not found yet any how-to on MDN
https://developer.mozilla.org/en-US/Add ... nsions/API
the permission is
Code: Select all
"chrome://favicon/"

but firefox dont support this, neither a replacement.
and as far i read i cannot use the sdk api level:
https://developer.mozilla.org/en-US/Add ... es_favicon

converted extension is working that far but show no icons

any help appreciated, either link or a code snippet.
edit - maybe solved for now - there exist no replacement for sdk getfavicon:
https://developer.mozilla.org/en-US/Add ... Add-on_SDK
Low-level APIs

Add-on SDK WebExtensions
places/bookmarks bookmarks
places/favicon None

#-o


Update:
i just examined another (chrome+firefox) extension "group speed dial") which contains the request method
Code: Select all
https://plus.google.com/_/favicon?domain_url=${t}

which tries to get the favicon online.

Update2
plus.google is blocked due tracking protection and only root domain returns propper favicon (in most cases).
Code: Select all
        img.src = 'https://s2.googleusercontent.com/s2/favicons?domain_url=' + extractHostname(url);

Code: Select all
   extractHostname(url) {
      var hostname;
      //find & remove protocol (http, ftp, etc.) and get hostname

      if (url.indexOf("://") > -1) {
         hostname = url.split('/')[2];
      }
      else {
         hostname = url.split('/')[0];
      }

      //find & remove port number
      hostname = hostname.split(':')[0];
      //find & remove "?"
      hostname = hostname.split('?')[0];

      return hostname;
   },

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 1 guest