Greasy Fork镜像 支持简体中文。

Notifier

1

目前為 2023-10-31 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/478724/1273287/Notifier.js

'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.close()),
            ...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;
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址