Notifier

1

当前为 2023-11-23 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/478724/1284835/Notifier.js

  1. 'use strict';
  2.  
  3. if (typeof Notification !== "function") throw Error("Not Support yet!");
  4.  
  5. const notify = (() => {
  6. const open = (typeof GM_openInTab === "function") ?
  7. GM_openInTab : (uri) => window.open(uri, "_blank");
  8. const classic = (() => {
  9. return ({text, title, image, silent, tag, url: uri, ondone}) => {
  10. Notification.requestPermission();
  11. const options = {
  12. body: text,
  13. silent, tag,
  14. data: uri,
  15. icon: image,
  16. };
  17. if (!!tag) options.renotify = true;
  18. const noti = new Notification(title, options);
  19. noti.onclick = () => (open(noti.data), noti.close());
  20. noti.onclose = ondone;
  21. return {remove: () => noti.close()};
  22. }
  23. })();
  24.  
  25. const ver = GM_info.version;
  26. const handler = GM_info.scriptHandler;
  27.  
  28. if (handler === "Violentmonkey") {
  29. if (ver < "2.15.4") return classic;
  30. const V2_15_4 = (opti) => {
  31. const noti = GM_notification({
  32. onclick: () => (open(opti.url), noti.remove()),
  33. ...opti
  34. });
  35. return noti;
  36. };
  37. if (ver > "2.16.1") // v 2.16.1 has some bugs
  38. return (opti) => {
  39. opti.zombieUrl = opti.url;
  40. opti.zombieTimeout = 2147483647;
  41. return V2_15_4(opti);
  42. };
  43. return V2_15_4;
  44. } else if (handler === "Tampermonkey" && ver >= "5.0")
  45. return GM_notification;
  46. else return classic;
  47. })();

QingJ © 2025

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