简体   繁体   中英

Chrome Notifications - Magic Push even when the website is not open

I have built a chrome extension in the past and I have used chrome notifications API in that extension so I'm familiar with how it works.

I recently found this website which shows this notifications when something happens but the weirdest part is that even when this website is not opened in any tab it pushes these notifications (as long as chrome is open). I want to know how they do it.

I checked my settings->extensions list to see if I installed their extension somehow but there is none. So where are they running this magic javascript from?

Website is called https://www.greentoe.com

According to the official documentation and as stated by @Andreas

The reason for this is that when a push message is received, the browser can start up a service worker, which runs in the background without a page being open, and dispatch an event so that you can decide how to handle that push message.

The javascript code you are asking for is inside the worker.

If you want to see the workers actually used in your browser just go to chrome://inspect/#service-workers in a new tab. You can see the worker code by clicking on the inspect link under the worker name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM