How to keep chrome extension running in background -


i know how keep chrome extensions running in background, i.e user not need click on browser extension button @ right hand corner, , functionality of extension still incorporated browser. adblock, etc. runs whenever open browser without user needing explicitly click on extension button.

thanks.

chrome provides many events extension. example, chrome.tabs.on***d, chrome.alerms.***d, chrome.idle.on***d, chrome.runtime.on***d , etc. can register each event handler with:

chrome.***.on***.addlistener((evt) => {...}); 

in cases, enough handle events above implement features want. is, think don't need keep extension in background. instead, should handle each event. if extension inactive, , when event event handler registered occur, extension becomes active automatically chrome.

however, if want keep extension in background strongly, can keep in background writing following definition in manifest.json file:

"background": {   ...   "persistent": true } 

note not recommended. basically, should specify "false" , handle events.


Comments