Created
November 16, 2019 04:33
-
-
Save sahajamit/7578a56065e87b8964ddd6d4411a4425 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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