// ==UserScript== // @name 后半时间提醒 // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.4 // @description 提醒你临近中午/夜晚/凌晨 // @author Exisi // @crontab 0 11,12,15,17,18,22,23,0 * * * // @grant GM_notification // @homepage https://scriptcat.org/script-show-page/355 // @supportURL https://scriptcat.org/script-show-page/355 // ==/UserScript== function notification(type, hours){ switch (type){ case 0: GM_notification({ title: "临近中午", text: "当前时间:"+ hours + ":00", }); break; case 1: GM_notification({ title: "临近夜晚", text: "当前时间:"+ hours + ":00", }); break; case 2: GM_notification({ title: "临近凌晨", text: "当前时间:"+ hours + ":00", }); break; case -1: GM_notification({ title: "今天已经过去一半", text: "当前时间:"+ hours + ":00", }); break; case -2: GM_notification({ title: "最佳入睡时间", text: "当前时间:"+ hours + ":00", }); break; } } return new Promise((resolve, reject) => { let hours = Number(new Date().getHours()); if(hours == 15) notification(-1, hours); if(hours == 22) notification(-2, hours); if(hours == 23) notification(2, hours); if(hours == 0) notification(2, hours); if(12 >= hours && hours >= 11) notification(0, hours); if(18 >= hours && hours >= 17) notification(1, hours); resolve(); });