Theresmore 自动点击建筑

Theresmore 自动点击建筑 支持手动开启关闭自动点击

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Theresmore 自动点击建筑
// @namespace    http://tampermonkey.net/
// @version      2024-03-07
// @description  Theresmore 自动点击建筑 支持手动开启关闭自动点击
// @author       You
// @match        https://www.theresmoregame.com/play/
// @match        https://theresmoregame.g8hh.com/
// @match        https://theresmoregame.g8hh.com.cn/
// @icon         https://www.theresmoregame.com/play/favicon.ico
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    const document = window.document
    const body = document.getElementsByTagName('body')[0]
    const btn = document.createElement('div')
    btn.style = `width: 110px;
      height: 30px;
      line-height: 30px;
      position: fixed;
      left: 300px;
      top: 5px;
      font-size: 12px;
      border: 1px solid #b3d8ff;
      text-align: center;
      border-radius: 4px;
      background: #ecf5ff;
      color: #409eff;
      cursor: pointer;
      z-index: 9999;`
    btn.innerText = `开启自动点击`
    function guaji(){
        var btns=document.getElementsByClassName("btn btn-dark relative");
        for(var i=0;i<btns.length;i++){
            // 获取每个按钮的文本内容
            var btnText = btns[i].textContent.trim() || btns[i].innerText.trim();
            if(btns[i].className.indexOf("btn-off")<0
               &&btns[i].className.indexOf("rounded-l-full")<0&&btns[i].className.indexOf("rounded-l-none")<0
               &&btnText.indexOf("窃魂者堡垒")<0
              ){
                btns[i].click();
            }
        }
    }
    function switchBase() {
        // 获取页面上所有具有特定属性的tablist div
        var tablists = document.querySelectorAll('div[role="tablist"][aria-orientation="horizontal"]');
        for (var i = 0; i < tablists.length; i++) {
            // 在每个tablist中寻找匹配文本的按钮
            var buttons = tablists[i].getElementsByTagName("button");
            for (var j = 0; j < buttons.length; j++) {
                if ((buttons[j].textContent === "城市" || buttons[j].textContent === "定居点") && buttons[j].getAttribute('tabindex') === "-1") {
                    buttons[j].click();
                }
            }
        }
    }
    let autoClick = null
    let togglePlace = null
    btn.onclick = function() {
        if (autoClick === null) {
            autoClick = setInterval(guaji,1000)
            togglePlace = setInterval(switchBase,60000)
            btn.innerText = `关闭自动点击`
        } else {
            clearInterval(togglePlace)
            togglePlace = null
            clearInterval(autoClick)
            autoClick = null
            btn.innerText = `开启自动点击`
        }

    }
    body.appendChild(btn)
    // Your code here...
})();