SimonXming / Autoreload and Alert on some condition!

// ==UserScript==
// @name         Autoreload and Alert on some condition!
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Autoreload and Alert on some condition!
// @author       You
// @match        https://stackoverflow.com/questions/36779883/userscript-notifications-work-on-chrome-but-not-firefox
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var autoReloadDelay = 5 * 1000;

    console.log ('This Autoreload and Alert on some condition run one time.');

    function statusCheck () {
        // Quick and dirty
        var status = document.getElementsByClassName("info")[1].getElementsByClassName("value")[0].textContent;
        if (status != "Pending") {
            return true;
        } else {
            return false;
        }
    }

    if (statusCheck()){
        shim_GM_notification();
        var notificationDetails = {
            text:       'notification for something.',
            title:      'something happend',
            timeout:    6000,
            onclick:    function () {
                console.log ("Notice clicked.");
                window.focus ();
            }
        };
        GM_notification (notificationDetails);
    }

    /*--- Cross-browser Shim code follows:*/
    function shim_GM_notification () {
        if (typeof GM_notification === "function") {
            return;
        }
        window.GM_notification = function (ntcOptions) {
            checkPermission ();

            function checkPermission () {
                if (Notification.permission === "granted") {
                    fireNotice ();
                }
                else if (Notification.permission === "denied") {
                    alert ("User has denied notifications for this page/site!");
                    return;
                }
                else {
                    Notification.requestPermission ( function (permission) {
                        console.log ("New permission: ", permission);
                        checkPermission ();
                    } );
                }
            }

            function fireNotice () {
                if ( ! ntcOptions.title) {
                    console.log ("Title is required for notification");
                    return;
                }
                if (ntcOptions.text  &&  ! ntcOptions.body) {
                    ntcOptions.body = ntcOptions.text;
                }
                var ntfctn  = new Notification (ntcOptions.title, ntcOptions);

                if (ntcOptions.onclick) {
                    ntfctn.onclick = ntcOptions.onclick;
                }
                if (ntcOptions.timeout) {
                    setTimeout ( function() {
                        ntfctn.close ();
                    }, ntcOptions.timeout);
                }
            }
        };
    }
    setTimeout(function(){ location.reload(); }, autoReloadDelay);
    // Your code here...
})();