Last active
June 6, 2019 03:32
-
-
Save rebeccajae/0da9eda4e568469e9e698a99bd53f3a9 to your computer and use it in GitHub Desktop.
Jankily adds gcal notifications to webapp.
This file contains 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
// ==UserScript== | |
// @name Google Calendar Desktop Notifications | |
// @namespace https://www.rebeccapruim.com/ | |
// @version 0.1 | |
// @description Provides desktop notification support for Google Calendar's webapp. | |
// @match https://calendar.google.com/* | |
// @copyright 2019+, Rebecca J. Pruim | |
// @grant unsafeWindow | |
// ==/UserScript== | |
(function(){ | |
const fallbackToConsoleLog = true; | |
if (!("Notification" in window)) { | |
console.log("Desktop Notifications not supported."); | |
}else if (Notification.permission === "granted") { | |
unsafeWindow.alert = function(notif) { | |
new Notification(notif); | |
} | |
return; | |
}else if (Notification.permission !== "denied") { | |
Notification.requestPermission().then(function(permission) { | |
if (permission === "granted") { | |
unsafeWindow.alert = function(notif) { | |
new Notification(notif); | |
} | |
return; | |
} | |
}); | |
} | |
if(fallbackToConsoleLog){ | |
unsafeWindow.alert = console.log; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment