tieba.score_egg.click

自动点击福利彩蛋

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        tieba.score_egg.click
// @namespace   clumsyman
// @description 自动点击福利彩蛋
// @include     http://tieba.baidu.com/p/*
// @include     http://tieba.baidu.com/p?*
// @include     http://tieba.baidu.com/f/*
// @include     http://tieba.baidu.com/f?*
// @version     1
// ==/UserScript==

var selector = "a.score_egg:not(.j_VIP_score)";
var name = "福利彩蛋";
var unit = "枚";

function detect() {
    var nodes = document.querySelectorAll(selector);
    if (nodes) {
        switch(nodes.length) {
            case 0:
                console.log("未能在页面上找到"+name);
                break;
            case 1:
                console.log("自动点击找到的1"+unit+name+"……");
                nodes[0].click();
                break;
            default:
				var error = "在页面上找到"+nodes.length+unit+name+"。";
                console.error(error);
                alert(error);
                break;
        }
    }
}

detect();
var container = document.querySelector('.score_show');
var observer = new MutationObserver(detect);
observer.observe(container, { childList: true, subtree: true });