星之子 发表于 2025-6-9 11:12:26

【油猴脚本】给世界BOSS添加血量条

动机
打世界BOSS这种活动,如果没有一个显眼的血量条岂不是太无聊了!而且感觉如果再不做出来的话BOSS都快被砸死了,截至发帖为止11个小时,血量砸没了五分之一,周年的活跃度还是太有实力了。

功能
脚本会在页面上方添加一个血量指示条,每30秒更新一次BOSS的当前血量,并实时显示剩余时间。
点击血量指示条会跳转到BOSS的所有回复页面,可以结合一键暴打世界BOSS脚本轻松对BOSS发动偷吸(


代码
@Name@Match@icon
// ==UserScript==
// @name         狄文卡德我们走了喔~
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description在GameMale论坛顶部添加悬浮的世界BOSS血量指示条和倒计时
// @author       Étoiles
// @match      https://www.gamemale.com/*
// @grant      GM_xmlhttpRequest
// @grant      GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // 总血量
    const TOTAL_HP = 5000;
    // 活动结束时间 (2025年6月16日0点)
    const END_TIME = new Date('2025-06-16T00:00:00').getTime();
    // 血量检查间隔 (30s)
    const CHECK_INTERVAL = 1 * 30 * 1000;

    // 添加自定义样式
    GM_addStyle(`
      .boss-health-container {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            width: auto;
            min-width: 1200px;
            background-color: rgba(34, 34, 34, 0.95);
            padding: 8px 20px;
            z-index: 9999;
            box-shadow: 0 4px 15px rgba(0,0,0,0.5);
            backdrop-filter: blur(5px);
            border: 1px solid #ff3333;
            border-radius: 30px;
            transition: all 0.3s ease;
            cursor: pointer;
      }

      .boss-health-container:hover {
            box-shadow: 0 4px 20px rgba(255, 50, 50, 0.4);
            border-color: #ffffff;
      }

      .boss-content {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 15px;
      }

      .boss-header {
            color: #fff;
            font-size: 24px;
            font-weight: bold;
            text-shadow: 0 0 8px #ff0000;
            white-space: nowrap;
            display: flex;
            align-items: center;
      }

      .boss-health-bar {
            flex-grow: 1;
            height: 28px;
            background-color: #111;
            border-radius: 14px;
            overflow: hidden;
            position: relative;
            box-shadow: inset 0 0 8px rgba(0,0,0,0.8);
            min-width: 150px;
      }

      .boss-health {
            height: 100%;
            background: linear-gradient(to right, #ff0000, #ff6666);
            width: 100%;
            transition: width 0.5s ease, background 0.3s ease;
            position: relative;
      }

      .boss-health::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(to bottom, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 50%);
      }

      .boss-health-text {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: white;
            font-size: 18px;
            font-weight: bold;
            text-shadow: 1px 1px 2px black;
            white-space: nowrap;
      }

      .boss-timer {
            color: #fff;
            font-size: 18px;
            font-weight: bold;
            white-space: nowrap;
            text-shadow: 0 0 5px #ff0000;
            text-align: center;
            width: 200px;
            text-align: center;
            flex-shrink: 0;
      }


      @keyframes pulse {
            0% { opacity: 0.6; }
            50% { opacity: 1; }
            100% { opacity: 0.6; }
      }

      /* 响应式调整 */
      @media (max-width: 768px) {
            .boss-health-container {
                width: 90%;
                top: 10px;
                padding: 8px 15px;
            }

            .boss-content {
                flex-direction: column;
                gap: 8px;
            }

            .boss-health-bar {
                width: 100%;
            }

            .boss-header, .boss-timer {
                width: 100%;
                text-align: center;
            }
      }
    `);

    // 创建BOSS血量指示条
    function createBossHealthBar() {
      const container = document.createElement('div');
      container.className = 'boss-health-container';

      const content = document.createElement('div');
      content.className = 'boss-content';

      container.addEventListener('click', function() {
      window.location.href = 'https://www.gamemale.com/home.php?mod=space&do=thread&view=me&type=reply&uid=736182&from=space';
      });

      const header = document.createElement('div');
      header.className = 'boss-header';
      header.innerHTML = '<svg t="1749436666733" width="28" height="28" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="12776" width="200" height="200"><path d="M910.222222 654.222222s199.111111 0 28.444445-227.555555c0 0 170.666667-56.888889-56.888889-199.111111 0 0 170.666667-171.150222-199.111111-85.333334 0 0 0-142.222222-56.888889-142.222222s-113.777778 113.777778-113.777778 113.777778-56.888889-113.777778-113.777778-113.777778-56.888889 142.222222-56.888889 142.222222C-28.444444 54.840889 142.222222 227.555556 142.222222 227.555556c-227.555556 142.222222-56.888889 199.111111-56.888889 199.111111-170.666667 227.555556 28.444444 227.555556 28.444445 227.555555s-113.777778 56.888889-113.777778 142.222222 85.333333 56.888889 170.666667 56.888889c-199.111111 256 341.333333 28.444444 341.333333 28.444445s540.444444 227.555556 341.333333-28.444445c85.333333 0 170.666667 28.444444 170.666667-56.888889s-113.777778-142.222222-113.777778-142.222222z" fill="#292F33" p-id="12777"></path><path d="M823.836444 455.111111s-7.395556-185.429333-113.265777-256C625.265778 142.222222 568.888889 142.222222 512 142.222222c-59.420444 0-113.777778 0-199.111111 56.888889-105.841778 70.570667-113.777778 256-113.777778 256-28.444444 0-64.597333 65.166222-56.888889 142.222222 8.220444 82.176 56.888889 113.777778 56.888889 113.777778 0 113.777778 85.333333 199.111111 85.333333 199.111111 0 56.888889 0 85.333333 113.777778 85.333334h226.503111c114.830222 0 113.777778-28.444444 113.777778-85.333334 0 0 85.333333-85.333333 85.333333-199.111111 0 0 48.668444-31.601778 56.888889-113.777778 7.708444-77.056-28.444444-142.222222-56.888889-142.222222z" fill="#DD2E44" p-id="12778"></path><path d="M716.174222 728.803556c-24.035556 12.657778-124.529778 41.728-204.174222 41.728-85.333333 0-185.116444-29.070222-209.152-41.728-24.007111-12.629333-50.517333 9.784889-42.951111 53.105777 10.325333 58.993778 35.640889 133.233778 96.341333 119.324445C376.149333 896.682667 426.666667 853.333333 512 853.333333c85.959111 0 132.124444 43.349333 152.035556 47.900445 60.672 13.909333 82.289778-60.359111 92.586666-119.324445 7.594667-43.320889-16.440889-65.735111-40.448-53.105777z" fill="#292F33" p-id="12779"></path><path d="M731.619556 817.521778l-22.897778-85.333334c-32.853333 13.795556-123.534222 38.343111-196.750222 38.343112-80.64 0-174.08-25.941333-204.401778-39.480889l-23.182222 86.471111a28.558222 28.558222 0 0 0 20.110222 34.844444 28.558222 28.558222 0 0 0 34.844444-20.110222l21.276445-66.304c25.372444 9.784889 88.576 18.887111 151.381333 18.773333 61.468444-0.113778 122.538667-9.216 147.342222-18.773333l17.521778 66.304a28.387556 28.387556 0 0 0 34.702222 20.110222 28.444444 28.444444 0 0 0 20.053334-34.844444z" fill="#FFFFFF" p-id="12780"></path><path d="M652.202667 850.659556a21.361778 21.361778 0 0 0-16.440889-25.287112 21.361778 21.361778 0 0 0-25.287111 16.440889l-3.384889 18.289778c-9.984-5.404444-52.309333-18.375111-95.089778-18.460444-44.174222-0.085333-88.888889 12.913778-99.100444 18.460444l-5.632-18.289778c-2.446222-11.491556-14.705778-18.887111-26.168889-16.440889-11.463111 2.446222-19.313778 13.824-16.867556 25.287112l9.045333 43.064888C399.303111 880.099556 444.643556 853.333333 512 853.333333c64.142222 0 106.069333 24.092444 131.527111 38.257778l8.675556-40.931555z" fill="#FFFFFF" p-id="12781"></path><path d="M383.886222 426.211556l-67.697778-14.392889a86.755556 86.755556 0 0 0-102.599111 66.616889 86.755556 86.755556 0 0 0 66.616889 102.599111l67.697778 14.392889a86.755556 86.755556 0 0 0 102.599111-66.616889 86.755556 86.755556 0 0 0-66.616889-102.599111z m256.227556-6.798223l67.697778-14.392889a86.755556 86.755556 0 0 1 102.599111 66.616889 86.755556 86.755556 0 0 1-66.616889 102.599111l-67.697778 14.392889a86.755556 86.755556 0 0 1-102.599111-66.616889 86.755556 86.755556 0 0 1 66.616889-102.599111z" fill="#55ACEE" p-id="12782"></path><path d="M390.741333 440.035556l-55.637333-11.832889a71.310222 71.310222 0 0 0-84.337778 54.784 71.310222 71.310222 0 0 0 54.784 84.337777l55.637334 11.832889a71.310222 71.310222 0 0 0 84.337777-54.784 71.367111 71.367111 0 0 0-54.784-84.337777z" fill="#FFCC4D" p-id="12783"></path><path d="M362.353778 503.694222m-42.666667 0a42.666667 42.666667 0 1 0 85.333333 0 42.666667 42.666667 0 1 0-85.333333 0Z" fill="#292F33" p-id="12784"></path><path d="M633.258667 440.035556l55.637333-11.832889a71.310222 71.310222 0 0 1 84.337778 54.784 71.310222 71.310222 0 0 1-54.755556 84.337777l-55.637333 11.832889a71.310222 71.310222 0 0 1-84.337778-54.784 71.310222 71.310222 0 0 1 54.755556-84.337777z" fill="#FFCC4D" p-id="12785"></path><path d="M661.646222 503.694222m-42.666666 0a42.666667 42.666667 0 1 0 85.333333 0 42.666667 42.666667 0 1 0-85.333333 0Z" fill="#292F33" p-id="12786"></path><path d="M512 753.777778c-52.906667 0-75.292444-28.586667-82.517333-52.764445-15.445333 3.640889-38.257778 5.944889-54.869334-5.319111-8.675556-5.888-19.057778-17.863111-19.057777-41.472a14.222222 14.222222 0 0 1 28.444444 0c0 13.482667 4.920889 16.810667 6.570667 17.92 10.609778 7.224889 34.958222 1.308444 45.084444-2.702222A14.222222 14.222222 0 0 1 455.111111 682.666667c0.085333 4.238222 2.360889 42.666667 56.888889 42.666666 56.263111 0 56.888889-40.903111 56.888889-42.666666 0-4.721778 2.332444-9.102222 6.257778-11.747556a14.108444 14.108444 0 0 1 13.226666-1.479111c10.126222 4.039111 34.446222 9.955556 45.084445 2.702222 1.621333-1.109333 6.542222-4.437333 6.542222-17.92a14.222222 14.222222 0 0 1 28.444444 0c0 23.608889-10.353778 35.584-19.086222 41.472-16.611556 11.264-39.424 8.931556-54.869333 5.319111-7.196444 24.177778-29.610667 52.764444-82.488889 52.764445z" fill="#A0041E" p-id="12787"></path><path d="M673.080889 969.813333c-17.92 0-36.750222-7.765333-56.177778-23.210666-27.306667-21.76-53.020444-42.211556-104.903111-42.211556s-77.624889 20.48-104.874667 42.183111c-33.735111 26.88-69.376 26.851556-103.082666 0.056889a14.222222 14.222222 0 0 1 17.720889-22.272c23.352889 18.602667 44.259556 18.602667 67.612444 0 28.529778-22.698667 60.814222-48.384 122.624-48.384 61.838222 0 94.122667 25.685333 122.595556 48.355556 16.440889 13.084444 31.175111 18.602667 43.548444 16.696889 13.568-2.133333 20.736-12.771556 20.992-13.226667a14.279111 14.279111 0 0 1 19.626667-4.181333c6.513778 4.209778 8.533333 12.856889 4.380444 19.456a61.155556 61.155556 0 0 1-39.907555 25.941333 67.271111 67.271111 0 0 1-10.154667 0.796444z" fill="#BE1931" p-id="12788"></path><path d="M170.723556 27.022222c0.739556-14.136889 12.373333-25.486222 26.168888-26.624 17.976889-1.507556 25.941333 12.714667 32.597334 27.107556 20.764444 44.771556 42.894222 88.775111 72.362666 128.568889 20.48 27.676444 45.198222 57.287111 76.686223 72.931555 16.753778 5.603556 24.519111 25.912889 15.644444 41.216 14.933333 25.912889-14.592 50.915556-38.855111 38.798222-32.995556 19.057778-87.552-43.946667-106.183111-66.389333A333.653333 333.653333 0 0 1 193.564444 145.066667c-13.340444-36.124444-25.116444-79.047111-22.840888-118.044445z m682.325333 0a28.672 28.672 0 0 0-26.168889-26.624c-17.976889-1.507556-25.941333 12.714667-32.597333 27.107556-20.764444 44.771556-42.894222 88.775111-72.362667 128.568889-20.48 27.676444-45.198222 57.287111-76.686222 72.931555a28.785778 28.785778 0 0 0-15.644445 41.216c-14.933333 25.912889 14.592 50.915556 38.855111 38.798222 32.995556 19.057778 87.552-43.946667 106.183112-66.389333a333.112889 333.112889 0 0 0 55.580444-97.536c13.340444-36.152889 25.116444-79.075556 22.840889-118.072889z" fill="#F4900C" p-id="12789"></path><path d="M426.666667 455.111111c-121.002667 0-211.114667-59.164444-214.897778-61.667555a28.444444 28.444444 0 0 1 31.516444-47.388445C244.081778 346.595556 323.470222 398.222222 426.666667 398.222222a28.444444 28.444444 0 0 1 0 56.888889z m170.666666 0a28.444444 28.444444 0 1 1 0-56.888889c103.964444 0 182.556444-51.598222 183.324445-52.110222a28.444444 28.444444 0 1 1 31.573333 47.331556C808.448 395.946667 718.336 455.111111 597.333333 455.111111z" fill="#292F33" p-id="12790"></path></svg>&nbsp;Deus Cadens 狄文卡德';

      const healthBar = document.createElement('div');
      healthBar.className = 'boss-health-bar';

      const health = document.createElement('div');
      health.className = 'boss-health';

      const healthText = document.createElement('div');
      healthText.className = 'boss-health-text';

      const timer = document.createElement('div');
      timer.className = 'boss-timer';

      health.appendChild(healthText);
      healthBar.appendChild(health);
      content.appendChild(header);
      content.appendChild(healthBar);
      content.appendChild(timer);
      container.appendChild(content);

      // 插入到body最前面
      document.body.insertBefore(container, document.body.firstChild);

      return { health, healthText, timer };
    }

    // 获取BOSS当前血量
    function getBossHealth(callback) {
      GM_xmlhttpRequest({
            method: 'GET',
            url: 'https://www.gamemale.com/home.php?mod=space&uid=736182&do=profile',
            onload: function(response) {
                const parser = new DOMParser();
                const doc = parser.parseFromString(response.responseText, 'text/html');
                const element = doc.querySelector('#psts > ul > li:nth-child(6)');

                if (element) {
                  const text = element.textContent || element.innerText;
                  const matches = text.match(/\d+/);
                  const damage = matches ? parseInt(matches) : 0;
                  callback(TOTAL_HP - damage);
                } else {
                  console.error('无法找到BOSS血量元素');
                  callback(TOTAL_HP); // 默认显示满血
                }
            },
            onerror: function() {
                console.error('获取BOSS血量失败');
                callback(TOTAL_HP); // 默认显示满血
            }
      });
    }

    // 更新倒计时
    function updateTimer(timerElement) {
      const now = new Date().getTime();
      const distance = END_TIME - now;

      if (distance < 0) {
            timerElement.innerHTML = '活动已结束!';
            return;
      }

      const days = Math.floor(distance / (1000 * 60 * 60 * 24));
      const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
      const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
      const seconds = Math.floor((distance % (1000 * 60)) / 1000);

      timerElement.innerHTML = `剩余: ${days}d ${hours}h ${minutes}m ${seconds}s`;
    }

    // 主函数
    function main() {
      const { health, healthText, timer } = createBossHealthBar();

      // 初始更新
      updateHealth();
      updateTimer(timer);

      // 定时更新血量
      setInterval(updateHealth, CHECK_INTERVAL);
      // 每秒更新倒计时
      setInterval(() => updateTimer(timer), 1000);

      function updateHealth() {
            getBossHealth(function(currentHp) {
                const percentage = (currentHp / TOTAL_HP) * 100;
                health.style.width = `${percentage}%`;
                healthText.textContent = `${currentHp}/${TOTAL_HP} (${Math.round(percentage)}%)`;

                // 根据血量改变颜色
                if (percentage < 20) {
                  health.style.background = 'linear-gradient(to right, #ff0000, #ff3333)';
                  healthText.style.color = '#ffcccc';
                } else if (percentage < 50) {
                  health.style.background = 'linear-gradient(to right, #ff3333, #ff6666)';
                  healthText.style.color = '#fff';
                } else {
                  health.style.background = 'linear-gradient(to right, #ff0000, #ff6666)';
                  healthText.style.color = '#fff';
                }
            });
      }
    }

    // 等待页面加载完成
    if (document.readyState === 'loading') {
      document.addEventListener('DOMContentLoaded', main);
    } else {
      main();
    }
})();


星象占卜

辰翊 发表于 2025-6-9 11:15:03

大佬厉害啊,已经针对BOSS出了好几个脚本了,开发速度令人汗颜。
BOSS的血条亮起起来,瞬间就有压迫感了呢{:6_167:}

Ethan2077 发表于 2025-6-9 11:17:28

大佬的脚本好强,这样群体打boss的氛围感更足了,就像是柱子战

近原尊 发表于 2025-6-9 11:20:09

好厉害,这样感觉更有一种打BOSS的感觉,很沉浸式呢

墨燝 发表于 2025-6-9 11:24:43

我命令你速速修改打boss脚本,要求在boss所有回复界面生效(这样都不用点进去了

KurisuV 发表于 2025-6-9 11:25:42

这个脚本有点梦回fgo柱子战了hhh

夏漏光微 发表于 2025-6-9 11:27:09

沉浸感十足
有想法,又有动力

boss会有二阶段吗,比如转阶段,全体掉血什么的
可以临时封掉几个等级的人员评分,达到“沉默”效果

莲一 发表于 2025-6-9 11:27:39

哇,大大得脚本用起来好带感了,真就跟副本攻略boss一样{:6_167:}

野生阿努厨 发表于 2025-6-9 11:28:34

真的很有一起打世界boss的气氛感了,梦回fgo冠位时间神殿,以及大佬的脚本能力依旧强如鬼神

aboab 发表于 2025-6-9 11:31:11

昨天才看到问有没有的帖子,今天就做出来了啊,效率好高

jiuuy123 发表于 2025-6-9 11:34:22

大佬tql{:6_200:}一根大血条杵在界面顶端更会激发村民们嘟热情{:6_188:}

莫空山 发表于 2025-6-9 11:40:25

哇这个效果看起来真的很不错欸,而且也方便打boss了。

娱乐法师火布偶 发表于 2025-6-9 11:46:43

在最上面刷新血量显示还真有推BOSS的感觉了

dilloner 发表于 2025-6-9 11:48:32

好棒的脚本!现在那种集体打boss的感觉越来越强了!

柿请夏 发表于 2025-6-9 11:56:39

真的有全论坛一起打世界boss的感觉了,喜欢RPG的有福了

金苹果 发表于 2025-6-9 11:57:31

非常强大的脚本惹,把各种属性值统一很不错惹

chenfeng6 发表于 2025-6-9 11:58:02

有血条了真的有种在打boss的感觉

Kogenta 发表于 2025-6-9 11:59:47

支持,试了一下确实参与感爆棚hhh

Brine 发表于 2025-6-9 12:03:21

非常有下副本打boss的感觉了;P
超带感

DaiDoong 发表于 2025-6-9 12:06:59

重生之我在GM论坛打世界BOSS,这给我干哪来了,这还是泥潭吗
页: [1] 2 3 4
查看完整版本: 【油猴脚本】给世界BOSS添加血量条