Notifier

1

Verze ze dne 31. 10. 2023. Zobrazit nejnovější verzi.

Tento skript by neměl být instalován přímo. Jedná se o knihovnu, kterou by měly jiné skripty využívat pomocí meta příkazu // @require https://update.greasyfork.org/scripts/478724/1273300/Notifier.js

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

'use strict';

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

const notify = (() => {
    const open = (typeof GM_openInTab === "function") ?
          GM_openInTab : (uri) => window.open(uri, "_blank");
    const classic = (() => {
        return ({text, title, image, silent, tag, url: uri, ondone}) => {
            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.uri), noti.close());
            noti.onclose = ondone;
            return {remove: () => noti.close()};
        }
    })();
    const ver = GM_info.version;
    const handler = GM_info.scriptHandler;
    const V2_15_4 = (opti) => {
        const noti = GM_notification({
            onclick: () => (open(opti.url), noti.remove()),
            ...opti
        });
        return noti;
    };
    if (handler === "Violentmonkey")
        if (ver > "2.16") return (opti) => {
            opti.zombieUrl = opti.url;
            opti.zombieTimeout = Number.MAX_SAFE_INTEGER;
            return V2_15_4(opti);
        };
        else if (ver >= "2.15.4") return V2_15_4;
        else return classic;
    else if (handler === "Tampermonkey" && ver >= "5.0") return GM_notification;
    else return classic;
})();