每30秒检测摊位状态变化并通知
目前為
// ==UserScript==
// @name CPP摊位状态监控
// @namespace http://tampermonkey.net/
// @author @liyasan
// @version 1.1
// @description 每30秒检测摊位状态变化并通知
// @match https://www.allcpp.cn/mng/apply.do?t=1&pageNo=1
// @grant none
// @license MIT
// ==/UserScript==
(function () {
'use strict';
let lastStatusText = '';
if (Notification.permission !== "granted") {
Notification.requestPermission();
}
function extractStatusText() {
const nodes = Array.from(document.querySelectorAll("div"))
.filter(div => div.textContent.includes("摊位审核状态"));
return nodes.map(div => div.textContent.trim()).join("\n");
}
function notifyChange(message) {
if (Notification.permission === "granted") {
new Notification("摊位审核状态发生变化!", {
body: message,
icon: "https://www.allcpp.cn/favicon.ico"
});
}
}
function checkForChanges() {
const currentStatusText = extractStatusText();
if (lastStatusText && currentStatusText !== lastStatusText) {
console.log("检测到摊位状态变化!");
notifyChange("页面上的摊位审核状态可能已经更新。快来看看吧!");
} else {
console.log("暂无变化");
}
lastStatusText = currentStatusText;
setTimeout(() => location.reload(), 30000);
}
window.addEventListener('load', () => {
setTimeout(checkForChanges, 1000);
});
})();