Skip to content

Instantly share code, notes, and snippets.

@rebeccajae
Last active June 6, 2019 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rebeccajae/0da9eda4e568469e9e698a99bd53f3a9 to your computer and use it in GitHub Desktop.
Save rebeccajae/0da9eda4e568469e9e698a99bd53f3a9 to your computer and use it in GitHub Desktop.
Jankily adds gcal notifications to webapp.
// ==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