CPP摊位状态监控

每30秒检测摊位状态变化并通知

目前為 2025-04-23 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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);
    });
})();