最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to capture or listen to browser notifications? - Stack Overflow

programmeradmin0浏览0评论

I want to listen to ining notifications on the chrome browser for sites like google, facebook, whatsapp etc. I saw that the hack mentioned here which no longer works because webkitNotifications.createNotification is deprecated. Some of these sites use service workers, so I wonder if I can use webAPIs like ServiceWorkerRegistration.getNotifications(), PushManager, ServiceWorkerGlobalScope or even the Notification API? I've been reading around and cannot find anything to do this. I don't mind a hack as well. Can anything be done using selenium? Is it possible at all? If not, I'll not waste more time on it. Cheers!

Note: I'm looking for a solution where I can listen to notifications on other websites, not mine.

I want to listen to ining notifications on the chrome browser for sites like google, facebook, whatsapp etc. I saw that the hack mentioned here which no longer works because webkitNotifications.createNotification is deprecated. Some of these sites use service workers, so I wonder if I can use webAPIs like ServiceWorkerRegistration.getNotifications(), PushManager, ServiceWorkerGlobalScope or even the Notification API? I've been reading around and cannot find anything to do this. I don't mind a hack as well. Can anything be done using selenium? Is it possible at all? If not, I'll not waste more time on it. Cheers!

Note: I'm looking for a solution where I can listen to notifications on other websites, not mine.

Share Improve this question edited Jun 16, 2017 at 15:04 BDL 22.2k32 gold badges54 silver badges62 bronze badges asked May 4, 2017 at 11:25 Kaushik EvaniKaushik Evani 1,22410 silver badges19 bronze badges 2
  • What a general purpose? Do you want to collect your notifications in one place? Browser doesn't allow you to mess with a context of other pages from your page. Maybe extension can, but i'm not sure. – Dmitry Manannikov Commented May 18, 2017 at 7:03
  • 1 I want to listen to ining notifications from WhatsApp – Kaushik Evani Commented May 23, 2017 at 6:55
Add a ment  | 

1 Answer 1

Reset to default 3

I needed exact same thing. I assume you are looking for Chrome extension or App. I had no ways to access or intercept notifications shown through service workers (usually ones shows even after browser close). But the ones using Notications API in page you can simply customize Notications with your version of object as mentioned in: Event Listener for Web Notification

Put this in content script of extension and load before page is loaded in Chrome and listen to every events raised from page.

发布评论

评论列表(0)

  1. 暂无评论