// ==UserScript== // @name dz论坛消息提醒 // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.1.0 // @description 每隔5分钟检测一次是否有新消息 // @author 王一之 // @crontab */5 * * * * // @grant GM_xmlhttpRequest // @grant GM_notification // @grant GM_openInTab // @connect bbs.tampermonkey.net.cn // ==/UserScript== return new Promise((resolve, reject) => { GM_xmlhttpRequest({ url: 'https://bbs.tampermonkey.net.cn/', method: 'GET', onload(xhr) { if (xhr.responseText.indexOf('') !== -1) { let result = /title="(\d+)条我的帖子"/.exec(xhr.responseText); let text = ''; if (result) { text += result[1] + '条帖子;'; } GM_notification({ title: '论坛有新的消息', text: '您有新的消息:' + text, onclick(xhr) { if (text.indexOf('帖子') !== -1) { GM_openInTab("https://bbs.tampermonkey.net.cn/home.php?mod=space&do=notice&view=mypost"); } }, ondone() { resolve(); } }); } } }); });