background/background.js
/* 
  Messages from popup or other modules are handled here.
*/
Messages from popup or other modules are handled here.
Messages from popup or other modules are handled here .
async function handleMessage(message) {
  console.log(message);
  switch (message.id) {
    case 'WRITE_CACHE_TO_STORAGE':
      await writeCacheToStorage();
      break;
    case 'RESET_ALARM_FOR_HOSTNAME':
      await alarm_clear(message.hostname);
      await alarm_set(message.hostname);
      break;
    case 'HOST_SETTINGS_CHANGED':
      const tabs = await browser.tabs.query({ active: true, currentWindow: true });
      await browser.tabs.update(tabs[0].id, { url: tabs[0].url });
      onUserInteraction();
      break;
    default:
      throw new Error(`Message id "${message.id}" is not implementd.`)
      break;
  }
}
async function handleMessage ( message ) { console . log ( message ) ; switch ( message . id ) { case 'WRITE_CACHE_TO_STORAGE' : await writeCacheToStorage ( ) ; break ; case 'RESET_ALARM_FOR_HOSTNAME' : await alarm_clear ( message . hostname ) ; await alarm_set ( message . hostname ) ; break ; case 'HOST_SETTINGS_CHANGED' : const tabs = await browser . tabs . query ( { active : true , currentWindow : true } ) ; await browser . tabs . update ( tabs [ 0 ] . id , { url : tabs [ 0 ] . url } ) ; onUserInteraction ( ) ; break ; default : throw new Error ( ` ${ message . id } ` ) break ; } }
Messages from popup or other modules are handled here.
Messages from popup or other modules are handled here .