CC98查询粉丝的变动

to find out how my fans change

目前為 2024-09-13 提交的版本,檢視 最新版本

// ==UserScript==
// @name         CC98查询粉丝的变动
// @namespace    http://tampermonkey.net/
// @version      v1.7
// @description  to find out how my fans change
// @author       Lay
// @match        https://www.cc98.org/usercenter/myfans
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @license      AGPL -3.0 
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    let currentPage = 1;
    const totalPages = 5; // 根据实际情况设置总页数

    function fetchFans(page) {
        const url = `https://www.cc98.org/usercenter/myfans/?page=${page}`;
        
        GM_xmlhttpRequest({
            method: "GET",
            url: url,
            onload: function(response) {
                const parser = new DOMParser();
                const doc = parser.parseFromString(response.responseText, 'text/html');
                const fansElements = doc.querySelectorAll('.user-center-myfans .fan-name');

                const currentFans = new Set();
                fansElements.forEach(element => {
                    currentFans.add(element.textContent.trim());
                });

                const previousFans = new Set(JSON.parse(localStorage.getItem('fansList') || '[]'));
                checkForChanges(currentFans, previousFans);

                // 更新存储的粉丝列表
                localStorage.setItem('fansList', JSON.stringify([...currentFans]));

                // 翻页
                if (currentPage < totalPages) {
                    currentPage++;
                    fetchFans(currentPage);
                }
            }
        });
    }

    function checkForChanges(currentFans, previousFans) {
        const addedFans = [...currentFans].filter(fan => !previousFans.has(fan));
        const removedFans = [...previousFans].filter(fan => !currentFans.has(fan));

        if (addedFans.length > 0) {
            alert('新增加的粉丝: ' + addedFans.join(', \n'));
        }

        if (removedFans.length > 0) {
            alert('减少的粉丝: ' + removedFans.join(', \n'));
        }
    }

    // 页面加载时检查粉丝变化
    fetchFans();

    // 每隔5分钟检查一次(300000毫秒)
    setInterval(fetchFans, 3000);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址