// ==UserScript== // @name 下班倒计时 ScriptCat Demo // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.1.1 // @description 一个提醒你准时下班的demo,请使用ScriptCat运行 // @author wyz // @crontab 59 17 * * 1,2,3,4,5 // @grant GM_notification // @grant GM_updateNotification // @debug // ==/UserScript== return new Promise(resolve => { let i; GM_notification({ title: '下班60s倒计时', text: '准时下班,美好生活', ondone: (user) => { console.log('done user:', user); clearInterval(i); resolve(); }, onclick: () => { console.log('click'); }, oncreate: (id) => { let t = 1; i = setInterval(() => { GM_updateNotification(id, { title: '下班' + (60 - t) + 's倒计时', progress: 100 / 60 * t }); if (t == 60) { clearInterval(i); GM_updateNotification(id, { title: '下班啦!', progress: 100 }); resolve(); } t++; }, 1000); }, // 开启进度条模式 progress: 0, }); });