modules/utils.js
/** 
 * Update browsers extension icon, text and background
 * Handle the case where the tab_id no longer exists
 */
Update browsers extension icon, text and background
Handle the case where the tab_id no longer exists
Update browsers extension icon text and background Handle the case where the tab_id no longer exists
function updateIconAndBadge(tab_id, icon_path, badge_text, badge_background_color) {
    chrome.browserAction.setIcon({ path: icon_path, tabId: tab_id },
        () => {
            if (chrome.runtime.lastError) {
                console.log(`Tab ${tab_id} no longer exists.`);
            }
            else {
                chrome.browserAction.setBadgeText({
                    tabId: tab_id,
                    text: badge_text
                });
                chrome.browserAction.setBadgeBackgroundColor({
                    tabId: tab_id,
                    color: badge_background_color
                });
            }
        });
}
function updateIconAndBadge ( tab_id , icon_path , badge_text , badge_background_color ) { chrome . browserAction . setIcon ( { path : icon_path , tabId : tab_id } , ( ) => { if ( chrome . runtime . lastError ) { console . log ( ` ${ tab_id } ` ) ; } else { chrome . browserAction . setBadgeText ( { tabId : tab_id , text : badge_text } ) ; chrome . browserAction . setBadgeBackgroundColor ( { tabId : tab_id , color : badge_background_color } ) ; } } ) ; }
Update browsers extension icon, text and background
 Handle the case where the tab_id no longer exists
Update browsers extension icon text and background Handle the case where the tab_id no longer exists
// Set the icon path // Call back // Check for error // Failed - tab is gone // Ok - Set the badge text  // Set the back ground colour