Notifier

1

Tính đến 23-11-2023. Xem phiên bản mới nhất.

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://update.greasyforks.org/scripts/478724/1284835/Notifier.js

'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");
    const classic = (() => {
        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()};
        }
    })();

    const ver = GM_info.version;
    const handler = GM_info.scriptHandler;

    if (handler === "Violentmonkey") {
        if (ver < "2.15.4") return classic;
        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;
    else return classic;
})();
长期地址
遇到问题?请前往 GitHub 提 Issues。