如何捕获或收听浏览器通知? [英] How to capture or listen to browser notifications?

查看:90
本文介绍了如何捕获或收听浏览器通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在chrome浏览器上收听针对Google,facebook,whatsapp等网站的传入通知。
我看到了提及的 ,因为 webkitNotifications.createNotification 已不再使用。其中一些网站使用服务人员,所以我想知道我是否可以使用webAPI,比如 ServiceWorkerRegistration.getNotifications() PushManager ServiceWorkerGlobalScope 甚至是通知 API?我一直在阅读,无法找到任何事情来做到这一点。我也不介意破解。使用硒可以做任何事情吗?它有可能吗?如果没有,我不会浪费更多时间。
干杯!



注意:我正在寻找一种解决方案,可以在其他网站(而不是我的)上收听通知。

解决方案

我需要完全相同的东西。我假设您正在寻找Chrome扩展程序或应用程序。我无法访问或拦截服务工作人员显示的通知(通常是在浏览器关闭后显示的通知)。但是在页面中使用Notications API的人员可以简单地使用您的对象版本自定义Notications,如以下所述:用于网络通知的事件监听器



在页面加载到Chrome之前,将其放入扩展和加载的内容脚本中,并聆听页面中引发的每个事件。

I want to listen to incoming 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 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.

这篇关于如何捕获或收听浏览器通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆