Updating an extension button dynamically – inspiration required

You may change the extension icon like this:

chrome.browserAction.setIcon({path: icon});

There is also a ‘badge’ – small box over the extension icon that shows ie. number of unread messages in gmail extension. You can manipulate it like this:

chrome.browserAction.setBadgeBackgroundColor({color:[190, 190, 190, 230]});
chrome.browserAction.setBadgeText({text:"?"});

It is also possible to generate icon dynamically on a canvas element and then display it like this:

chrome.browserAction.setIcon({imageData:canvasContext.getImageData(0, 0, canvas.width,canvas.height)});

Note that you must call this from your background script, since the content script will not have permission!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)