Chinaz Auto Pager 站长之家自动翻页器

站长之家自动翻页脚本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Chinaz Auto Pager 站长之家自动翻页器
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  站长之家自动翻页脚本
// @author       Your Name
// @match        *://*.chinaz.com/*
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

(function() {
    'use strict';
    
    // 添加开关样式
    GM_addStyle(`
        .auto-pager-switch {
            position: fixed;
            left: 20px;
            top: 20px;
            z-index: 9999;
            padding: 8px 15px;
            background: #f0f0f0;
            border: 1px solid #ccc;
            border-radius: 4px;
            cursor: pointer;
            user-select: none;
        }
        .active {
            background: #4CAF50 !important;
            color: white;
        }
    `);

    // 创建开关元素
    const switchElement = document.createElement('div');
    switchElement.className = 'auto-pager-switch';
    switchElement.textContent = '自动翻页:关闭';
    document.body.appendChild(switchElement);

    let intervalId = null;
    const clickNextPage = () => {
        // 查找包含 > 符号的下一页按钮
        const nextButton = [...document.querySelectorAll('a, button')].find(el => 
            el.textContent.trim() === '>' || 
            el.textContent.trim() === '下一页'
        );

        if (nextButton) {
            nextButton.click();
            console.log('已点击下一页');
        }
    };

    // 从存储获取初始状态
    let isEnabled = GM_getValue('autoPagerEnabled', false);
    
    // 创建开关元素
    switchElement.textContent = isEnabled ? '自动翻页:开启' : '自动翻页:关闭';
    if (isEnabled) {
        switchElement.classList.add('active');
        intervalId = setInterval(clickNextPage, 1000);
    }

    // 切换点击事件
    switchElement.addEventListener('click', () => {
        isEnabled = !isEnabled;
        GM_setValue('autoPagerEnabled', isEnabled);
        
        if (isEnabled) {
            intervalId = setInterval(clickNextPage, 1000);
            switchElement.textContent = '自动翻页:开启';
            switchElement.classList.add('active');
        } else {
            clearInterval(intervalId);
            intervalId = null;
            switchElement.textContent = '自动翻页:关闭';
            switchElement.classList.remove('active');
        }
    });
})();