CPP摊位状态监控

每60秒检测摊位状态变化并触发通知

当前为 2025-04-23 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         CPP摊位状态监控
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  每60秒检测摊位状态变化并触发通知
// @match        https://www.allcpp.cn/mng/apply.do?t=1&pageNo=1
// @grant        none
// @license      MIT
// @author       liyasan
// ==/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;

        // 每60秒刷新
        setTimeout(() => {
            console.log("🔁 正在刷新页面...");
            location.reload(true);
        }, 60000);
    }

    // 页面加载后开始监控流程
    window.addEventListener('load', () => {
        setTimeout(checkForChanges, 2000); // 等待页面加载稳定后再抓取内容
    });
})();