* Updates the tabId's extension icon and badge. * * @param {number} tabId ID of a tab. * @param {string} iconPrefix File name prefix of the icon to use. * @param {string} title Title to display in extension icon hover. * @param {string} text Text to display in badge. * @param {string} color Ba
(tabId, iconPrefix, title, text, color)
| 248 | * @param {string} color Background color for badge. |
| 249 | */ |
| 250 | function updateTabStatus(tabId, iconPrefix, title, text, color) { |
| 251 | // Verify tab still exists |
| 252 | chrome.tabs.get(tabId, () => { |
| 253 | if (!chrome.runtime.lastError) { |
| 254 | chrome.action.setIcon({ |
| 255 | path: { |
| 256 | '19': iconPrefix + '-128.png', |
| 257 | '38': iconPrefix + '-38.png', |
| 258 | }, |
| 259 | tabId, |
| 260 | }); |
| 261 | if (title !== undefined) |
| 262 | {chrome.action.setTitle({title, tabId});} |
| 263 | if (text !== undefined) |
| 264 | {chrome.action.setBadgeText({text, tabId});} |
| 265 | if (color !== undefined) |
| 266 | {chrome.action.setBadgeBackgroundColor( |
| 267 | {color: hex2rgba(color), tabId});} |
| 268 | } |
| 269 | }); |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * Fetches the content of the tab's URL and validates it. Then updates the |
no test coverage detected