Notifier

1

Ekde 2023/12/02. Vidu La ĝisdata versio.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/478724/1289430/Notifier.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

'use strict';

if (typeof Notification !== "function") throw Error("Not Support yet!");

const notify = (() => {
    const open = (typeof GM_openInTab === "function") ?
          GM_openInTab : (uri) => window.open(uri, "_blank");

    if (typeof GM_notification === "function") {
        const ver = GM_info.version;
        const handler = GM_info.scriptHandler;
        if (handler === "Violentmonkey" && ver >= "2.15.4") {
            const V2_15_4 = (opti) => {
                const noti = GM_notification({
                    onclick: () => (open(opti.url), noti.remove()),
                    ...opti
                });
                return noti;
            };
            if (ver > "2.16.1") // v 2.16.1 has some bugs
                return (opti) => {
                    opti.zombieUrl = opti.url;
                    opti.zombieTimeout = 2147483647;
                    return V2_15_4(opti);
                };
            return V2_15_4;
        } else if (handler === "Tampermonkey" && ver >= "5.0")
            return GM_notification;
    }
    return ({text, title, image, silent, tag, url: uri, ondone}) => {
            Notification.requestPermission();
            const options = {
                body: text,
                silent, tag,
                data: uri,
                icon: image,
            };
            if (!!tag) options.renotify = true;
            const noti = new Notification(title, options);
            noti.onclick = () => (open(noti.data), noti.close());
            noti.onclose = ondone;
            return {remove: () => noti.close()};
        };
})();