大善人数据统计接力

前情提要:突发奇想 让shared chat通过编写代码计算大善人榜数据总量

下载网页再离线统计号池数量也太慢了,苦一苦油猴哥,帮我们来个一键统计

效果:

image

代码:

// ==UserScript==
// @name         号池真实数量统计
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  自动统计contributors下的数量之和
// @author       Your Name
// @match        https://shared.oaifree.com/dashboard
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 创建按钮并添加到页面的 header 中,放在原有按钮的左侧
    function addButton() {
        const header = document.querySelector('.header'); // 找到 header 元素
        if (header) {
            const button = document.createElement('button');
            button.textContent = '号池真实数量';
            button.id = 'chat-btn'; // 使用和现有按钮相同的ID样式
            button.className = 'login-btn'; // 应用相同的类

            const existingButton = document.getElementById('chat-btn'); // 查找现有的按钮
            if (existingButton) {
                header.insertBefore(button, existingButton); // 在现有按钮前插入新按钮
            } else {
                header.appendChild(button); // 如果没有找到现有按钮,就添加到 header 最后
            }

            button.addEventListener('click', calculateTotal);
        }
    }

    // 定义一个函数用于提取和计算所有数量
    function calculateTotal() {
        const numbers = document.querySelectorAll('#contributors .list-item span:nth-child(2)');
        let sum = 0;
        numbers.forEach(num => {
            const value = parseInt(num.textContent.trim(), 10);
            if (!isNaN(value)) {
                sum += value;
            }
        });
        alert(`大善人总贡献号池: ${sum}`);
    }

    // 页面加载完成后添加按钮
    window.addEventListener('load', addButton);
})();


6 个赞

泄露军情 :tieba_025:

2 个赞

加个限制,以防外一

2 个赞

榜一捐赠数量我已经加过料了,算不准的 :laughing:

10 个赞

数据也是展开统计来的,没有抓什么接口,谈不上什么利不利用,始皇如果不想公开就只公示前十就好了

合理,应该做些保护的 :laughing:

支持

对对对,就这么迷惑敌军

不准的

加上一层迷雾

你们想把始皇底裤都测干净啊