从来不想 发表于 2026-3-6 15:27

寻仙纪之BOSS脚本-2026年3月6日

这是一个专为《寻仙纪》文字游戏设计的全自动BOSS挑战脚本,具备以下核心功能:

------

#### **一、自动化流程**

1. **首页等待机制**
   - 进入首页后自动等待 **5分钟**(可配置),防止服务器session超时
   - 按钮实时显示倒计时(格式 `等待 MM:SS`),等待结束后自动点击“挑战”进入BOSS列表页。
2. **BOSS列表智能处理**
   - 自动检测页面是否包含目标BOSS(默认列表:`['赤炼蛇王', '岩魔之王']`,可任意配置)。
   - 若存在目标BOSS,优先点击第一个找到的BOSS进入战斗;
   - 若无目标BOSS,则自动点击“返回首页”,重新开始等待循环。
3. **战斗页实时决策**
   - 动态读取玩家当前气血值(通过 `$('.hpys').eq(2).text()` 获取)。
   - **血量低于阈值**(默认 `1000`):
   - 优先点击任意文本含“药剂”的链接(自动识别所有药品)。
   - 若无药品,则点击“逃跑”脱离战斗。
   - **血量安全**:点击“攻击”继续战斗。
4. **特殊页面处理**
   - **怪物被抢**:检测“怪物已经被其他人攻击”文本,立即返回首页。
   - **战斗胜利**:检测“战斗胜利!”或“你打死了”,自动返回首页。
   - **突破需求**:检测“突破”链接,以最高优先级点击突破(确保等级提升不受阻)。
   - **未知页面**:若无法识别当前页面,尝试返回首页;若无返回链接,则短间隔重试,避免脚本卡死。

------

#### **二、用户交互**

- **悬浮控制按钮**(默认右下角)
- 绿色 **`自动挂机 ON`** / 红色 **`自动挂机 OFF`**,点击切换状态。
- 状态自动保存至 `GM_setValue`,刷新页面后恢复。
- 等待期间显示动态倒计时,结束后自动恢复按钮文本。
- **屏幕常亮**(移动端专用)
- 开启挂机时自动激活屏幕常亮:
    - 优先使用 **Wake Lock API**(现代浏览器支持)。
    - 若不支持,回退到 **不可见视频保活方案**。
- 关闭挂机时自动释放常亮,恢复正常锁屏。

------

#### **三、可配置参数(脚本开头)**



```javascript
const DELAY_HOME = 300;               // 普通页面重试间隔(ms)
const DELAY_FIGHT = 300;               // 战斗页重试间隔(ms)
const HP_THRESHOLD = 1000;            // 吃药阈值
const BOSS_NAMES = ['赤炼蛇王', '岩魔之王']; // 目标BOSS列表(支持任意字符串)
const WAIT_BEFORE_CHALLENGE = 5 * 60 * 1000; // 首页等待时间(5分钟)
```



------

#### **四、适用场景**

- 长时间挂机挑战指定BOSS(如赤炼蛇王、魔之系列)。
- 自动吃药、逃跑、处理被抢,实现全程无人值守。
- 兼容手机浏览器(如Via、Kiwi)和电脑浏览器(Chrome、Firefox)。



##**脚本如下**

```javascript
// ==UserScript==
// @name         寻仙纪自动刷BOSS
// @namespace    http://tampermonkey.net/
// @version      2.26
// @description自动挑战BOSS,首页等待5分钟(显示倒计时),智能战斗,屏幕常亮
// @AuThor       YourName
// @match      https://eebess.com/xxj/*
// @require      https://eebess.com/xxj/js/jquery-1.6.2.min.js
// @grant      GM_setValue
// @grant      GM_getValue
// ==/UserScript==

(function() {
    'use strict';
    if (typeof $ === 'undefined') return;

    // ========== 配置参数 ==========
    const DELAY_HOME = 300;               // 普通页面重试间隔(ms)
    const DELAY_FIGHT = 300;               // 战斗页重试间隔(ms)
    const HP_THRESHOLD = 1000;            // 吃药阈值
    const BOSS_NAMES = ['赤炼蛇王', '岩魔之王']; // 目标BOSS
    const WAIT_BEFORE_CHALLENGE = 5 * 60 * 1000; // 首页等待5分钟(适应session超时)
    // =============================

    const STORAGE_KEY = 'autoFightEnabled';
    let enabled = GM_getValue(STORAGE_KEY, true);

    // 定时器管理
    let actionTimer = null;       // 普通循环定时器
    let challengeTimer = null;    // 5分钟等待定时器
    let countdownInterval = null; // 倒计时更新定时器

    // 屏幕常亮相关
    let wakeLock = null;
    let keepAwakeVideo = null;
    const wakeLockSupported = 'wakeLock' in navigator;

    // --- 屏幕常亮控制 ---
    function requestWakeLock() {
      if (!enabled) return;
      if (wakeLockSupported) {
            if (wakeLock) return;
            navigator.wakeLock.request('screen')
                .then(lock => {
                  wakeLock = lock;
                  lock.addEventListener('release', () => {
                        wakeLock = null;
                        if (enabled) requestWakeLock();
                  });
                })
                .catch(() => {});
      } else if (!keepAwakeVideo) {
            keepAwakeVideo = $('<video loop muted playsinline style="width:1px;height:1px;opacity:0;position:fixed;top:0;left:0;pointer-events:none;z-index:-1">')
                .appendTo('body');
            keepAwakeVideo.src = 'data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZLiKta4M9R0gEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
            keepAwakeVideo.play().catch(() => {});
      }
    }

    function releaseWakeLock() {
      if (wakeLockSupported && wakeLock) {
            wakeLock.release().then(() => wakeLock = null);
      } else if (keepAwakeVideo) {
            keepAwakeVideo.pause();
            keepAwakeVideo.remove();
            keepAwakeVideo = null;
      }
    }

    // --- 按钮创建与交互 ---
    const $btn = $('<div id="autoFightSwitch" style="position:fixed;bottom:20px;right:20px;z-index:9999;padding:10px 15px;border-radius:30px;font-size:14px;font-weight:bold;cursor:pointer;box-shadow:0 2px 10px rgba(0,0,0,0.3);user-select:none;background:' + (enabled ? '#4CAF50' : '#f44336') + ';color:white;border:2px solid white;">' + (enabled ? '自动挂机 ON' : '自动挂机 OFF') + '</div>').appendTo('body');

    function updateButtonText() {
      $btn.css('background', enabled ? '#4CAF50' : '#f44336')
             .text(enabled ? '自动挂机 ON' : '自动挂机 OFF');
    }

    // 清除所有定时器
    function clearAllTimers() {
      if (actionTimer) { clearTimeout(actionTimer); actionTimer = null; }
      if (challengeTimer) { clearTimeout(challengeTimer); challengeTimer = null; }
      if (countdownInterval) { clearInterval(countdownInterval); countdownInterval = null; }
    }

    $btn.on('click', () => {
      clearAllTimers();
      enabled = !enabled;
      GM_setValue(STORAGE_KEY, enabled);
      updateButtonText();
      if (enabled) {
            requestWakeLock();
            autoAction();
      } else {
            releaseWakeLock();
      }
    });

    // --- 辅助函数 ---
    function clickReturnHome() {
      const $link = $('a:contains("返回首页")').first();
      if ($link.length) { $link.click(); return true; }
      let found = false;
      $('a').each(function() {
            if (this.innerText.includes('返回首页')) {
                this.click();
                found = true;
                return false;
            }
      });
      return found;
    }

    function hasTargetBoss() {
      return BOSS_NAMES.some(name => $(`a:contains("${name}")`).length > 0);
    }

    function clickTargetBoss() {
      for (const name of BOSS_NAMES) {
            const $boss = $(`a:contains("${name}")`).first();
            if ($boss.length) {
                $boss.click();
                return true;
            }
      }
      return false;
    }

    function startCountdown(durationMs) {
      const endTime = Date.now() + durationMs;
      countdownInterval = setInterval(() => {
            const remaining = endTime - Date.now();
            if (remaining <= 0) {
                clearInterval(countdownInterval);
                countdownInterval = null;
                return;
            }
            const minutes = Math.floor(remaining / 60000);
            const seconds = Math.floor((remaining % 60000) / 1000);
            $btn.text(`等待 ${minutes}:${seconds.toString().padStart(2, '0')}`);
      }, 1000);
    }

    // --- 核心循环 ---
    function autoAction() {
      if (!enabled) return;

      // 1. 突破检测(最高优先级)
      const breakLink = $('a:contains("突破")').first();
      if (breakLink.length) {
            breakLink.click();
            return;
      }

      const bodyText = document.body.innerText;
      const isFight = bodyText.includes('========战斗========') && $('a:contains("攻击")').length && $('.hpys').length;
      const hasDrop = bodyText.includes('掉落:');
      const hasVictory = bodyText.includes('战斗胜利!') || bodyText.includes('你打死了');
      const isHome = bodyText.includes('你看到:') && !isFight && !hasDrop && !hasVictory;
      const isBossList = bodyText.includes('BOSS挑战:');

      // 2. 怪物被抢
      if (bodyText.includes('怪物已经被其他人攻击')) {
            if (clickReturnHome()) return;
      }

      // 3. 胜利页
      if (hasVictory) {
            if (clickReturnHome()) return;
      }

      // 4. 战斗页
      if (isFight) {
            const hp = parseInt($('.hpys').eq(2).text());
            if (isNaN(hp)) { scheduleAction(DELAY_FIGHT); return; }
            if (hp < HP_THRESHOLD) {
                const potion = $('a:contains("药剂")').first();
                if (potion.length) {
                  potion.click();
                  return;
                }
                const escape = $('a:contains("逃跑")').first();
                if (escape.length) {
                  escape.click();
                  return;
                }
            } else {
                const attack = $('a:contains("攻击")').first();
                if (attack.length) {
                  attack.click();
                  return;
                }
            }
            scheduleAction(DELAY_FIGHT);
            return;
      }

      // 5. 首领详情页
      if (hasDrop) {
            const attack = $('a:contains("攻击")').first();
            if (attack.length) {
                attack.click();
                return;
            }
            scheduleAction(DELAY_HOME);
            return;
      }

      // 6. BOSS列表页
      if (isBossList) {
            if (hasTargetBoss()) {
                if (clickTargetBoss()) return;
            }
            if (clickReturnHome()) return;
            scheduleAction(DELAY_HOME);
            return;
      }

      // 7. 首页:等待5分钟后点击“挑战”
      if (isHome) {
            if (challengeTimer) return; // 已在等待

            // 清除普通循环,避免干扰
            if (actionTimer) {
                clearTimeout(actionTimer);
                actionTimer = null;
            }

            startCountdown(WAIT_BEFORE_CHALLENGE);

            challengeTimer = setTimeout(() => {
                challengeTimer = null;
                if (countdownInterval) {
                  clearInterval(countdownInterval);
                  countdownInterval = null;
                }
                updateButtonText(); // 恢复按钮文本

                const challengeLink = $('a:contains("挑战")').first();
                if (challengeLink.length) {
                  challengeLink.click();
                } else {
                  // 异常情况,重新调度
                  if (enabled) autoAction();
                }
            }, WAIT_BEFORE_CHALLENGE);

            return;
      }

      // 8. 兜底返回首页
      if ($('a:contains("返回首页")').length) {
            if (clickReturnHome()) return;
      }

      // 9. 未知页面
      scheduleAction(DELAY_HOME);
    }

    function scheduleAction(delay) {
      if (actionTimer) clearTimeout(actionTimer);
      if (enabled) {
            actionTimer = setTimeout(autoAction, delay);
      }
    }

    // 启动
    $(document).ready(() => {
      if (enabled) requestWakeLock();
      autoAction();
    });
})();
```

天之牙2012 发表于 2026-3-12 17:15

系统自带的挂机太慢了,直接手搓一个浏览器扩展插件,刷怪速度飞起,一共4个文件放在一个目录里面,然后浏览器打开扩展 ”加载解压缩的扩展”选择好代码保存的文件夹,4个文件如下manifest.jsonoptions.htmlcontent.jsoptions.js 搞定开始挂机修仙~~

manifest.json
{
"manifest_version": 2,
"name": "自动战斗辅助",
"version": "1.0",
"description": "自动战斗辅助,支持配置目标地图、嗑药阈值和药剂名称",
"browser_action": {
    "default_popup": "options.html",
    "default_title": "自动战斗设置"
},
"permissions": [
    "storage",
    "tabs",
    "*://*.eebess.com/*"
],
"content_scripts": [
    {
      "matches": ["*://*.eebess.com/*"],
      "js": ["content.js"],
      "run_at": "document_idle"
    }
],
"options_ui": {
    "page": "options.html",
    "open_in_tab": false
}
}

options.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>自动战斗设置</title>
<style>
    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }
    body {
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      background: linear-gradient(135deg, #fff1e0 0%, #ffdec2 100%);
      display: flex;
      justify-content: center;
      align-items: center;
      min-height: 400px;
      width: 340px;
      padding: 16px;
    }
    .card {
      background: #fffaf5;
      border-radius: 20px;
      box-shadow: 0 15px 40px rgba(255, 140, 0, 0.15);
      width: 100%;
      padding: 24px 20px;
      transition: transform 0.2s;
    }
    .card:hover {
      transform: translateY(-2px);
    }
    h2 {
      color: #b45f06;
      font-size: 1.5rem;
      font-weight: 600;
      margin-bottom: 24px;
      text-align: center;
      letter-spacing: 0.5px;
      border-bottom: 2px solid #ffd2a8;
      padding-bottom: 12px;
    }
    .input-group {
      margin-bottom: 20px;
    }
    .input-group label {
      display: block;
      font-size: 0.9rem;
      font-weight: 500;
      color: #a0522d;
      margin-bottom: 6px;
    }
    .input-group input {
      width: 100%;
      padding: 12px 14px;
      font-size: 1rem;
      border: 2px solid #ffd2a8;
      border-radius: 12px;
      outline: none;
      transition: border-color 0.2s, box-shadow 0.2s;
      background: #ffffff;
    }
    .input-group input:focus {
      border-color: #ff8c00;
      box-shadow: 0 0 0 3px rgba(255, 140, 0, 0.1);
      background: white;
    }
    /* 开关样式 */
    .switch-group {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin: 24px 0 20px;
      padding: 8px 0;
    }
    .switch-group label {
      font-size: 1rem;
      font-weight: 600;
      color: #b45f06;
    }
    .switch {
      position: relative;
      display: inline-block;
      width: 52px;
      height: 28px;
    }
    .switch input {
      opacity: 0;
      width: 0;
      height: 0;
    }
    .slider {
      position: absolute;
      cursor: pointer;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: #ffd2a8;
      transition: 0.3s;
      border-radius: 34px;
    }
    .slider:before {
      position: absolute;
      content: "";
      height: 22px;
      width: 22px;
      left: 3px;
      bottom: 3px;
      background-color: white;
      transition: 0.3s;
      border-radius: 50%;
      box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }
    input:checked + .slider {
      background: linear-gradient(135deg, #ffb347, #ff8c00);
    }
    input:checked + .slider:before {
      transform: translateX(24px);
    }
    .status {
      text-align: center;
      margin-top: 16px;
      font-size: 0.9rem;
      color: #b45f06;
      font-weight: 500;
      min-height: 24px;
    }
</style>
</head>
<body>
<div class="card">
    <h2>⚙️ 自动战斗设置</h2>

    <div class="input-group">
      <label>&#127919; 刷怪地图(需要手动去这个地方)</label>
      <input type="text" id="targetMap" placeholder="例如:城西郊">
    </div>

    <div class="input-group">
      <label>❤️ 气血阈值 (低于此值嗑药)</label>
      <input type="number" id="hpThreshold" placeholder="例如:100">
    </div>

    <div class="input-group">
      <label>&#129514; 药剂名称 (药剂需要放在快捷栏内)</label>
      <input type="text" id="potionText" placeholder="例如:初级药剂">
    </div>

    <div class="switch-group">
      <label>&#128283; 启用自动战斗</label>
      <label class="switch">
      <input type="checkbox" id="enabled">
      <span class="slider"></span>
      </label>
       
    </div>
       <label>作者·吾爱破解·天之牙2012</label>

    <div id="status" class="status"></div>
</div>

<script src="options.js"></script>
</body>
</html>

content.js
(function() {
'use strict';

// 默认配置
const DEFAULT_CONFIG = {
    targetMap: "城西郊",
    hpThreshold: 100,
    potionText: "初级药剂",
    enabled: false   // 修改为默认关闭
};

let config = { ...DEFAULT_CONFIG };

// 从 storage 加载配置,然后启动脚本
chrome.storage.sync.get(['targetMap', 'hpThreshold', 'potionText', 'enabled'], (result) => {
    config.targetMap = result.targetMap || DEFAULT_CONFIG.targetMap;
    config.hpThreshold = result.hpThreshold || DEFAULT_CONFIG.hpThreshold;
    config.potionText = result.potionText || DEFAULT_CONFIG.potionText;
    config.enabled = result.enabled !== false;

    console.log('自动战斗配置已加载:', config);
    initScript();
});

// ---------- 核心功能 ----------
function initScript() {
    // 获取当前地图名称
    function getCurrentMap() {
      const walker = document.createTreeWalker(
      document.body,
      NodeFilter.SHOW_TEXT,
      {
          acceptNode: function(node) {
            return node.textContent.includes('当前地图:') ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
          }
      }
      );
      const textNode = walker.nextNode();
      if (!textNode) return null;
      const fullText = textNode.textContent;
      const match = fullText.match(/当前地图:([^\[]+)(?:\[[^\]]+\])?/);
      return match ? match.trim() : null;
    }

    // 获取虾仁当前气血(使用第三个 .hpys)
    function getMyCurrentHP() {
      const hpDivs = document.querySelectorAll('.hpys');
      if (hpDivs.length >= 3) {
      const hp = parseInt(hpDivs.innerText.trim(), 10);
      if (!isNaN(hp)) return hp;
      }
      console.warn('无法定位虾仁当前气血(第三个 .hpys 不存在或无效)');
      return null;
    }

    function hasAttackButton() {
      return Array.from(document.querySelectorAll('a')).some(a => a.textContent.trim() === '攻击');
    }

    function isBattleResultPage() {
      return document.body.innerText.includes('战斗结果:');
    }

    // 新增:判断是否怪物被抢页面
    function isMonsterTakenPage() {
      return document.body.innerText.includes('怪物已经被其他人攻击了');
    }

    function isHealerPage() {
      return Array.from(document.querySelectorAll('a')).some(a => a.textContent.includes('生命恢复需要'));
    }

    function isPostHealPage() {
      const hasReturnHome = Array.from(document.querySelectorAll('a')).some(a => a.textContent.trim() === '返回首页');
      const hasLife = document.body.innerText.includes('生命:');
      return hasReturnHome && hasLife;
    }

    // 点击动作
    function clickHomeButton() {
      if (!isBattleResultPage()) return false;
      const homeLinks = Array.from(document.querySelectorAll('a')).filter(a => a.textContent.trim() === '返回首页');
      if (homeLinks.length > 0) {
      homeLinks.click();
      console.log('战斗结果界面,返回首页已点击');
      return true;
      }
      return false;
    }

    // 新增:怪物被抢页面点击返回首页
    function clickReturnHomeOnMonsterTaken() {
      if (!isMonsterTakenPage()) return false;
      const homeLinks = Array.from(document.querySelectorAll('a')).filter(a => a.textContent.trim() === '返回首页');
      if (homeLinks.length > 0) {
      homeLinks.click();
      console.log('怪物被抢页面,返回首页已点击');
      return true;
      }
      return false;
    }

    function clickHealerLink() {
      const healerLinks = Array.from(document.querySelectorAll('a')).filter(a => a.textContent.trim() === '云游仙医');
      if (healerLinks.length > 0) {
      healerLinks.click();
      console.log('村广场:点击云游仙医');
      return true;
      }
      return false;
    }

    function clickHealRecoveryLink() {
      const recoveryLinks = Array.from(document.querySelectorAll('a')).filter(a => a.textContent.includes('生命恢复需要'));
      if (recoveryLinks.length > 0) {
      recoveryLinks.click();
      console.log('云游仙医页面:点击生命恢复');
      return true;
      }
      return false;
    }

    function clickReturnHomeInHealPage() {
      if (!isPostHealPage()) return false;
      const homeLinks = Array.from(document.querySelectorAll('a')).filter(a => a.textContent.trim() === '返回首页');
      if (homeLinks.length > 0) {
      homeLinks.click();
      console.log('恢复后页面:点击返回首页');
      return true;
      }
      return false;
    }

    function usePotionIfNeeded() {
      if (!hasAttackButton()) return false;

      const hp = getMyCurrentHP();
      console.log(`检测到虾仁当前气血: ${hp}`);

      if (hp === null) {
      console.log('无法检测到气血值,跳过嗑药检测');
      return false;
      }

      if (hp < config.hpThreshold) {
      const potionLinks = Array.from(document.querySelectorAll('a')).filter(a => a.textContent.includes(config.potionText));
      if (potionLinks.length > 0) {
          potionLinks.click();
          console.log(`气血值 ${hp} 低于 ${config.hpThreshold},使用 ${config.potionText}`);
          return true;
      } else {
          console.log(`气血值 ${hp} 低于阈值,但未找到药剂链接`);
      }
      }
      return false;
    }

    function clickMonsterLinks() {
      const currentMap = getCurrentMap();
      if (currentMap !== config.targetMap) return false;

      const walker = document.createTreeWalker(
      document.body,
      NodeFilter.SHOW_TEXT,
      { acceptNode: node => node.textContent.includes('你看到:') ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP }
      );

      let textNode;
      while (textNode = walker.nextNode()) {
      let sibling = textNode.nextSibling;
      const monsterLinks = [];
      while (sibling && !(sibling.nodeType === Node.ELEMENT_NODE && sibling.tagName === 'BR')) {
          if (sibling.nodeType === Node.ELEMENT_NODE && sibling.tagName === 'A') {
            monsterLinks.push(sibling);
          }
          sibling = sibling.nextSibling;
      }
      if (monsterLinks.length > 0) {
          monsterLinks.click();
          console.log(`【目标地图 ${config.targetMap}】点击怪物链接:`, monsterLinks.textContent);
          return true;
      }
      }
      return false;
    }

    function clickAttackButton() {
      const attackLinks = Array.from(document.querySelectorAll('a')).filter(a => a.textContent.trim() === '攻击');
      if (attackLinks.length > 0) {
      attackLinks.click();
      console.log('攻击按钮已点击');
      return true;
      }
      return false;
    }

    // 主逻辑:每次执行前检查开关状态
    function performActions() {
      if (!config.enabled) return;

      // 1. 战斗结果页面优先返回首页
      if (clickHomeButton()) return;

      // 2. 怪物被抢页面返回首页
      if (clickReturnHomeOnMonsterTaken()) return;

      // 3. 云游仙医页面:点击恢复链接
      if (clickHealRecoveryLink()) return;

      // 4. 恢复后页面:点击返回首页
      if (clickReturnHomeInHealPage()) return;

      // 5. 如果当前地图是村广场,则点击云游仙医(死亡回血)
      const currentMap = getCurrentMap();
      if (currentMap === '村广场') {
      if (clickHealerLink()) return;
      }

      // 6. 战斗页面:先检查是否需嗑药
      if (usePotionIfNeeded()) return;

      // 7. 尝试点击怪物链接(仅限目标地图)
      if (clickMonsterLinks()) return;

      // 8. 否则尝试点击攻击按钮
      clickAttackButton();
    }

    // 监听 DOM 变化
    const observer = new MutationObserver(() => performActions());
    observer.observe(document.body, {
      childList: true,
      subtree: true,
      characterData: true,
      attributes: false
    });

    // 立即执行一次
    performActions();

    console.log(`自动战斗脚本已启动,目标地图:${config.targetMap},自动回血地图:村广场,战斗中自动嗑药(气血<${config.hpThreshold}),开关状态:${config.enabled ? '开启' : '关闭'},已增加怪物被抢处理,正在监控 eebess.com...`);
}
})();

options.js
document.addEventListener('DOMContentLoaded', () => {
let previousEnabled = false; // 初始化上次状态为关闭

// 加载配置
chrome.storage.sync.get(['targetMap', 'hpThreshold', 'potionText', 'enabled'], (result) => {
    document.getElementById('targetMap').value = result.targetMap || '城西郊';
    document.getElementById('hpThreshold').value = result.hpThreshold || 100;
    document.getElementById('potionText').value = result.potionText || '初级药剂';
    // 关键修改:只有存储中 enabled === true 时才开启,否则关闭(包括未设置时)
    const enabled = result.enabled === true;
    document.getElementById('enabled').checked = enabled;
    previousEnabled = enabled;
});

// 自动保存函数
const saveConfig = () => {
    const targetMap = document.getElementById('targetMap').value.trim();
    const hpThreshold = parseInt(document.getElementById('hpThreshold').value, 10);
    const potionText = document.getElementById('potionText').value.trim();
    const enabled = document.getElementById('enabled').checked;

    chrome.storage.sync.set({
      targetMap: targetMap,
      hpThreshold: hpThreshold,
      potionText: potionText,
      enabled: enabled
    }, () => {
      const status = document.getElementById('status');
      status.textContent = '✓ 已自动保存';
      setTimeout(() => status.textContent = '', 1500);
    });
};

// 监听输入变化
document.getElementById('targetMap').addEventListener('input', saveConfig);
document.getElementById('hpThreshold').addEventListener('input', saveConfig);
document.getElementById('potionText').addEventListener('input', saveConfig);

// 监听开关变化:保存 + 从关到开时刷新页面
document.getElementById('enabled').addEventListener('change', function() {
    const newEnabled = this.checked;
    saveConfig();

    if (newEnabled && !previousEnabled) {
      chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
      if (tabs.length > 0) {
          const tab = tabs;
          if (tab.url && tab.url.includes('eebess.com')) {
            chrome.tabs.reload(tab.id);
            console.log('已刷新 eebess.com 页面,新配置生效');
          }
      }
      });
    }
    previousEnabled = newEnabled;
});
});

少污污 发表于 2026-3-7 16:34

从来不想 发表于 2026-3-7 12:16
最简单是把之前的删掉,或者把油猴脚本设置中的勾选框去掉

你不懂,还是我教你吧。
    // --- 按钮创建与交互 ---
    const $btn = $('<div id="autoFightSwitch" style="position:fixed;bottom:20px;……
//把bottom:20px修改成bottom:70px   就行了。不用你的这么麻烦~
    // --- 按钮创建与交互 ---
    const $btn = $('<div id="autoFightSwitch" style="position:fixed;bottom:70px;……

gufangkai 发表于 2026-3-6 18:27

膜拜大佬···· 这个游戏我没找到{:301_973:}

从来不想 发表于 2026-3-6 18:32

gufangkai 发表于 2026-3-6 18:27
膜拜大佬···· 这个游戏我没找到

脚本里面有网址{:301_1001:}

gufangkai 发表于 2026-3-6 18:50

哦 找到了 是文字类游戏

会瘦的胖子 发表于 2026-3-6 19:38

gufangkai 发表于 2026-3-6 18:27
膜拜大佬···· 这个游戏我没找到

https://eebess.com/xxj/login.php

_达圣 发表于 2026-3-6 20:12

会瘦的胖子 发表于 2026-3-6 19:38
https://eebess.com/xxj/login.php

久仰《寻仙纪》大名,今天终于是玩到了

少污污 发表于 2026-3-6 20:38

下面的按钮图标 跟之前的脚本按钮 重叠了。要改改。

从来不想 发表于 2026-3-6 21:35

少污污 发表于 2026-3-6 20:38
下面的按钮图标 跟之前的脚本按钮 重叠了。要改改。

可以把之前的脚本取消,用这个脚本

少污污 发表于 2026-3-6 22:12

从来不想 发表于 2026-3-6 21:35
可以把之前的脚本取消,用这个脚本

在那里修改。我修改修改。这样方便。要用那个点一下按钮就行。

从来不想 发表于 2026-3-7 12:16

少污污 发表于 2026-3-6 22:12
在那里修改。我修改修改。这样方便。要用那个点一下按钮就行。

最简单是把之前的删掉,或者把油猴脚本设置中的勾选框去掉
页: [1] 2
查看完整版本: 寻仙纪之BOSS脚本-2026年3月6日