Skip to content

Instantly share code, notes, and snippets.

@sahajamit
Created November 16, 2019 04:33
Show Gist options
  • Save sahajamit/7578a56065e87b8964ddd6d4411a4425 to your computer and use it in GitHub Desktop.
Save sahajamit/7578a56065e87b8964ddd6d4411a4425 to your computer and use it in GitHub Desktop.
// To Start Listening to all the Web Notifications
window.notifications = [];
window.DefaultNotification = window.Notification;
(function () {
function notificationCallback(title, opt) {
console.log("notification title: ", title);
console.log("notification body: ", opt.body);
console.log("notification tag: ", opt.tag);
console.log("notification icon: ", opt.icon);
}
const handler = {
construct(target, args) {
notificationCallback(...args);
var notification = new target(...args);
window.notifications.push(notification);
return notification;
}
};
const ProxifiedNotification = new Proxy(Notification, handler);
window.Notification = ProxifiedNotification;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment