后半时间提醒
// ==UserScript==
// @name 后半时间提醒
// @namespace https://bbs.tampermonkey.net.cn/
// @version 0.5
// @description 提醒你临近中午 / 夜晚 / 凌晨
// @author Exisi
// @crontab 0 11,12,15,17,18,22,23,0 * * *
// @grant GM_notification
// @grant GM_getValue
// @homepage https://scriptcat.org/script-show-page/355
// @supportURL https://scriptcat.org/script-show-page/355
// ==/UserScript==
/* ==UserConfig==
设置:
Timeout:
title: 通知时长
description: 请输入每次通知保持的时长(毫秒),默认 3 秒
==/UserConfig== */
function notification(title, hours){
GM_notification({
title : title,
text : "当前时间:"+ hours + ":00",
timeout : GM_getValue('设置.Timeout') != '' ? GM_getValue('设置.Timeout') : 3000,
});
}
function setNotification(type, hours){
switch (type){
case 0:
notification("临近中午", hours);
break;
case 1:
notification("临近夜晚", hours);
break;
case 2:
notification("临近凌晨", hours);
break;
case -1:
notification("今天已经过去一半", hours);
break;
case -2:
notification("最佳入睡时间", hours);
break;
}
}
return new Promise((resolve, reject) => {
let hours = Number(new Date().getHours());
let model = {
11 : 0,
12 : 0,
15 : -1,
17 : 1,
18 : 1,
22 : -2,
23 : 2,
0 : 2,
}
setNotification(model[hours], hours);
resolve();
});