Google Calendar Alert Interrupter

Interrupt me to get my attention where there is a meeting!

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Google Calendar Alert Interrupter
// @namespace    http://dustindavis.me/
// @version      0.1
// @description  Interrupt me to get my attention where there is a meeting!
// @author       Dustin Davis
// @match        https://calendar.google.com/calendar/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    var alrtScope;
    if (typeof unsafeWindow === "undefined") {
        alrtScope = window;
    } else {
        alrtScope = unsafeWindow;
    }

    alrtScope.alert = function(msg) {
        console.log("Intercepted alert: ", msg);

        window.name = "gcal";
        var newWin = openWindow('', 900, 600);
        var html = `
            <style>
                body {
                    background: #4185f4  }
                section {
                    background: black;
                    color: white;
                    border-radius: 1em;
                    padding: 1em;
                    position: absolute;
                    top: 50%;
                    left: 50%;
                    margin-right: -50%;
                    cursor: pointer;
                    transform: translate(-50%, -50%) }
            </style>
            <section id="go">
                <h1>${msg}</h1>
            </section>
        `
        newWin.document.write(html);
        newWin.document.write('<script/>');

        var g = newWin.document.createElement('script');
        var s = newWin.document.getElementsByTagName('script')[0];
        g.text = 'document.getElementById("go").addEventListener("click", () => { window.open("", window.opener.name); window.close();})';
        s.parentNode.insertBefore(g, s);
    };

    function openWindow(url, width, height) {
        var myWindow;
        var center_left = (screen.width / 2) - (width / 2);
        var center_top = (screen.height / 2) - (height / 2);

        myWindow = window.open(url, "Title", "scrollbars=1, width="+width+", height="+height+", left="+center_left+", top="+center_top);
        myWindow.focus();
        return myWindow;
    }
})();