我的文字修仙全靠刷 脚本

修仙小游戏脚本

当前为 2024-08-02 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         我的文字修仙全靠刷 脚本
// @namespace    http://tampermonkey.net/
// @version      2024.8.2-3.0
// @description  修仙小游戏脚本
// @author       mj
// @match        https://*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant        none
// @license MIT
// ==/UserScript==

var myPlayer = document.querySelector('.game-container-wrapper').__vue__._data.player;
var intervalId1 = null;
var intervalId2 = null;
var intervalId3 = null;
var attackInterval = null;
var fightIntervalId = null;
var restInterval = null;
var isAttacking = true;
var isAutoSale = true;

function clearAllIntervals() {
    if (intervalId1 !== null) {
        clearInterval(intervalId1);
        intervalId1 = null;
    }
    if (intervalId2 !== null) {
        clearInterval(intervalId2);
        intervalId2 = null;
    }
    if (attackInterval !== null) {
        clearInterval(attackInterval);
        attackInterval = null;
    }
    if (fightIntervalId !== null) {
        clearInterval(fightIntervalId);
        fightIntervalId = null;
    }
    if (restInterval !== null) {
        clearInterval(restInterval);
        restInterval = null;
    }
}

function startAutoTraining() {
    var buttons = document.querySelectorAll('button');
    buttons.forEach(function(button) {
        var buttonText = button.textContent.trim();
        if (buttonText === "开始修炼" || buttonText === "继续修炼" || buttonText === "突破境界") {
            button.click();
        } else if (buttonText === "杀敌证道") {
            button.click();
            clickFightButtons();
        }
    });
}

function attackTheWorldBoss() {
    var buttons = document.querySelectorAll("button");
    buttons.forEach(function (button) {
        if (button.innerText === "世界BOSS" || button.innerText === "回到家里") {
            if (document.body.innerText.includes("被击败")||document.body.innerText.includes("你输了")||document.body.innerText.includes("BOSS还未刷新")) {
                isAttacking = false;
                button.click();
                console.log("无法战胜世界boss,5分钟后重试");
                return true;
            }
            button.click();
        }
    });
    buttons.forEach(function (button) {
        if (button.innerText === "攻击BOSS") {
            button.click();
        }
    });
    if (myPlayer.health === 0) {
        console.log("无法战胜世界boss,5分钟后重试");
        isAttacking = false;
        buttons.forEach((button) => {
            if (button.innerText === "返回家里") {
                button.click();
            }
        });
        return true;
    }
    buttons.forEach(function (button) {
        if (button.innerText === "发起战斗") {
            button.click();
        }
    });
    return false;
}

function startAttackingWorldBoss() {
    if (attackInterval !== null) return;
    attackInterval = setInterval(() => {
        if (isAttacking) {
            let stop = attackTheWorldBoss();
            if (stop) {
                clearInterval(attackInterval);
                attackInterval = null;
            }
        }
    }, 10);
}

function clickExploreButton() {
    var buttons = document.querySelectorAll("button");
    if (myPlayer.level === 40 && isAttacking) {
        console.log("攻击世界boss");
        startAttackingWorldBoss();
        return;
    }
    if (isAutoSale) {
        automaticSaleOfEquipment();
        isAutoSale = false;
    }
    buttons.forEach(function (button) {
        if (button.innerText === "继续探索" || button.innerText === "探索秘境") {
            button.click();
            clickFightButtons();
        }
        if (button.innerText === "发起战斗") {
            clickFightButtons();
        }
    });
}

function loopClickExploreButton() {
    if (intervalId2 !== null) return;
    intervalId2 = setInterval(function () {
        clickExploreButton();
    }, 10);
}

function clickFightButtons() {
    function innerClickFightButtons() {
        if (myPlayer.health === 0) {
            clearInterval(fightIntervalId);
            fightIntervalId = null;
            document.querySelectorAll("button").forEach((button) => {
                if (button.innerText === "立马撤退") {
                    button.click();
                    if (!document.body.innerText.includes("撤退失败,请继续战斗。")) {
                        clearInterval(fightIntervalId);
                        fightIntervalId = null;
                        loopClickExploreButton();
                    }
                }
            });
        }
        if (myPlayer.health < myPlayer.maxHealth * 0.1) {
            clearInterval(fightIntervalId);
            fightIntervalId = null;
            autoRest();
            return;
        }
        var fightButtonClicked = false;
        var buttons = document.querySelectorAll("button");
        buttons.forEach(function (button) {
            if (button.innerText === "发起战斗") {
                button.click();
                fightButtonClicked = true;
            }
            if (button.innerText === "回到家里") {
                button.click();
            }
        });
        if (fightButtonClicked) {
            return;
        }
    }
    if (fightIntervalId === null) {
        fightIntervalId = setInterval(innerClickFightButtons, 10);
    }
}

function autoRest() {
    let healthValue = myPlayer.health;
    let maxHealth = myPlayer.maxHealth;
    if (restInterval !== null) return;
    restInterval = setInterval(() => {
        document.querySelectorAll("button").forEach((button) => {
            if (button.innerText === "回到家里") {
                button.click();
                clearInterval(restInterval);
                restInterval = null;
            }
        });
        healthValue = myPlayer.health;
        if (healthValue < maxHealth) {
            document.querySelectorAll("button").forEach((button) => {
                if (button.innerText === "打坐休息" || button.innerText === "继续打坐") {
                    button.click();
                }
            });
        }
        healthValue = myPlayer.health;
        if (healthValue >= maxHealth) {
            document.querySelectorAll("button").forEach((button) => {
                if (button.innerText === "继续干他") {
                    button.click();
                }
            });
            clearInterval(restInterval);
            restInterval = null;
            clickFightButtons();
        }
        if (clickButton("发起战斗")) {
            while (clickButton("发起战斗")) {
                return;
            }
            clickButton("回到家里");
        }
    }, 10);
}

function automaticSaleOfEquipment() {
    document.querySelector('.setting.el-icon-setting').click();
    setTimeout(() => {
        clickButton("出售装备");
        setTimeout(() => {
            clickButton("出售装备");
        }, 10);
    }, 10);
}

function clickButton(buttonText) {
    let buttons = document.querySelectorAll("button");
    for (let button of buttons) {
        if (button.innerText === buttonText) {
            button.click();
            return true;
        }
    }
    return false;
}

async function autoGetPet() {
    async function exploreAndCapture() {
        if (clickButton("探索秘境")) {
            await new Promise(resolve => setTimeout(resolve, 10));
            if (clickButton("收服对方")) {
                await new Promise(resolve => setTimeout(resolve, 10));
                await keepFighting();
            }
        }
    }

    async function keepFighting() {
        while (clickButton("发起战斗")) {
            await new Promise(resolve => setTimeout(resolve, 10));
            if (clickButton("回到家里")) {
                return;
            }
        }
    }
    clickButton("回到家里");
    if (isAutoSale) {
        automaticSaleOfEquipment();
        isAutoSale = false;
    }
    await exploreAndCapture();
}

function autoPutPet() {
    myPlayer.pets = [];
}

setInterval(function() {isAttacking = true;}, 300000);
setInterval(function() {isAutoSale = true;}, 20000);

function initializeButtons() {
    var gameContainer = document.querySelector('.game-container');

    if (gameContainer) {
        gameContainer.style.position = "relative";

        var buttonContainer = document.createElement("div");
        buttonContainer.style.position = "absolute";
        buttonContainer.style.top = "10px";
        buttonContainer.style.left = "50%";
        buttonContainer.style.transform = "translateX(-50%)";
        buttonContainer.style.display = "flex";
        buttonContainer.style.gap = "10px";
        buttonContainer.style.zIndex = "99999";
        buttonContainer.style.backgroundColor = "rgba(255, 255, 255, 0.8)";
        buttonContainer.style.borderRadius = "10px";

        var button1 = document.createElement("button");
        button1.innerHTML = "修炼";
        styleButton(button1);

        button1.onclick = function () {
            if (intervalId1 === null) {
                if (myPlayer.level === 40) {
                    confirm("已经修炼到最高级,无法继续修炼!");
                    console.log("已经修炼到最高级,无法继续修炼");
                    return;
                }
                intervalId1 = setInterval(startAutoTraining, 10);
                button1.innerHTML = "🟥修炼";
                disableOtherButtons(button2);
                disableOtherButtons(button3);
                disableOtherButtons(button4);
                console.log("自动修炼功能正在运行");
            } else {
                clearAllIntervals();
                button1.innerHTML = "修炼";
                enableAllButtons(button2);
                enableAllButtons(button3);
                enableAllButtons(button4);
                console.log("自动修炼功能已停止");
            }
        };

        var button2 = document.createElement("button");
        button2.innerHTML = "探索";
        styleButton(button2);

        button2.onclick = function () {
            if (intervalId2 === null) {
                let userConfirmed = confirm("自动探索将自动出售装备,请提前调整出售装备设置!");
                if (userConfirmed) {
                    loopClickExploreButton();
                    button2.innerHTML = "🟥探索";
                    disableOtherButtons(button1);
                    disableOtherButtons(button3);
                    disableOtherButtons(button4);
                    console.log("自动探索功能正在运行");
                } else {
                    console.log("用户取消了自动探索");
                }
            } else {
                clearAllIntervals();
                button2.innerHTML = "探索";
                enableAllButtons(button1);
                enableAllButtons(button3);
                enableAllButtons(button4);
                console.log("自动探索功能已停止");
            }
        };

        var button3 = document.createElement("button");
        button3.innerHTML = "收宠";
        styleButton(button3);

        button3.onclick = function () {
            if (intervalId3 === null) {
                let userConfirmed = confirm("自动收宠将自动出售装备,请提前调整出售装备设置!");
                if (userConfirmed) {
                intervalId3 = setInterval(autoGetPet, 10);
                button3.innerHTML = "🟥收宠";
                disableOtherButtons(button1);
                disableOtherButtons(button2);
                disableOtherButtons(button4);
                console.log("自动收宠功能正在运行");
                }
            } else {
                clearInterval(intervalId3);
                intervalId3 = null;
                button3.innerHTML = "收宠";
                enableAllButtons(button1);
                enableAllButtons(button2);
                enableAllButtons(button4);
                console.log("自动收宠功能已停止");
            }
        }

        var button4 = document.createElement("button");
        button4.innerHTML = "放宠";
        styleButton(button4);

        button4.onclick = function () {
            let userConfirmed = confirm("你将放生所有未出战灵宠!");
            if (userConfirmed) {
                autoPutPet();
            }
        }

        buttonContainer.appendChild(button1);
        buttonContainer.appendChild(button2);
        buttonContainer.appendChild(button3);
        buttonContainer.appendChild(button4);
        gameContainer.appendChild(buttonContainer);
    } else {
        console.log("脚本初始化失败");
    }
}

function styleButton(button) {
    button.style.padding = "5px 10px";
    button.style.border = "none";
    button.style.borderRadius = "5px";
    button.style.backgroundColor = "#007bff";
    button.style.color = "white";
    button.style.fontSize = "16px";
    button.style.cursor = "pointer";
    button.style.transition = "background-color 0.3s, transform 0.3s";

    button.onmouseover = function() {
        if (!button.disabled) {
            button.style.backgroundColor = "#0056b3";
            button.style.transform = "scale(1.05)";
        }
    };

    button.onmouseout = function() {
        if (!button.disabled) {
            button.style.backgroundColor = "#007bff";
            button.style.transform = "scale(1)";
        }
    };

    button.onmousedown = function() {
        if (!button.disabled) {
            button.style.backgroundColor = "#004494";
        }
    };

    button.onmouseup = function() {
        if (!button.disabled) {
            button.style.backgroundColor = "#0056b3";
        }
    };
}

function disableOtherButtons(activeButton) {
    activeButton.disabled = true;
    activeButton.style.backgroundColor = "darkgray";
    activeButton.style.cursor = "not-allowed";
}

function enableAllButtons(activeButton) {
    activeButton.disabled = false;
    activeButton.style.backgroundColor = "#007bff";
    activeButton.style.cursor = "pointer";
}

initializeButtons();