星之子 发表于 2025-2-1 02:01:03

【油猴脚本】勋章商城展示内部编号、价格、库存余量

动机
勋章商城的价格、库存余量信息,需要在鼠标悬停后显示的.mytip框中才能看到,勋章的内部编号更是要审查元素。个人感觉不够一目了然,就顺手写了这个脚本。DeepSeek真的很强,花了5分钟写提示词、等了2分钟生成、花了5分钟调试,脚本就搞定了。

功能
如图所示吧,感觉没啥可解释的。


代码
@Name@Match
// ==UserScript==
// @name         勋章:商城编号价格库存量显示
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description从mytip提取信息并显示在指定位置
// @author       You
// @match      https://www.gamemale.com/plugin.php?id=wodexunzhang%3Ashowxunzhang&fid=*
// @match      https://www.gamemale.com/wodexunzhang-showxunzhang.html
// @grant      none
// ==/UserScript==

(function() {
    'use strict';

    // 创建信息显示样式
    const style = document.createElement('style');
    style.textContent = `
      .badge-info {
            font-family: Noto Sans SC, Microsoft Yahei, Arial, sans-serif;
            color: #333;
      }
    `;
    document.head.appendChild(style);




    // 处理每个勋章块
    document.querySelectorAll('.myblok').forEach(blok => {
      blok.style.height = '140px';
      const mytip = blok.querySelector('.mytip');
      if (!mytip) return;

      // 提取编号
      const tipId = mytip.id.replace('my', '');

      // 提取价格
      const priceElement = Array.from(mytip.querySelectorAll('p.jiage')).find(p =>
            p.textContent.includes('购买价格')
      );
      const price = priceElement?.querySelector('b')?.textContent || '无价格';

      // 提取库存
      const stockElement = Array.from(mytip.querySelectorAll('p.jiage')).find(p =>
            p.textContent.includes('剩余库存')
      );
      const stock = stockElement?.querySelector('b')?.textContent || '无库存';

      // 创建信息显示元素
      const infoDiv = document.createElement('p');
      infoDiv.className = 'badge-info';
      infoDiv.innerHTML = `
            ${tipId} / ${price} / ${stock}
      `;

      // 定位插入位置
      const myimg = blok.querySelector('.myimg');
      const targetP = myimg.querySelector('p:nth-of-type(2)');

      if (targetP) {
            targetP.insertAdjacentElement('afterend', infoDiv);
      } else {
            myimg.appendChild(infoDiv);
      }
    });
})();


星象占卜

呆萌De小受受 发表于 2025-2-1 02:02:25

感谢分享惹,确实是超级有用的脚本,ds真的厉害惹

yota 发表于 2025-2-1 02:04:03

好实用的脚本,很多时候想买的勋章总是要点进去才可以看!可惜追随没次数了,感谢分享

manhuozu 发表于 2025-2-1 02:04:10

太强了!如果有大佬能做个加上勋章效果的就更好了

喋喋以喋以喋喋 发表于 2025-2-1 02:15:06

我嘞个技术大佬,不过大佬要是能预览勋章效果就好了

LostDream 发表于 2025-2-1 02:16:54

大佬牛逼!如果还能预览勋章效果就更完美了!期待后续优化!

毛茸茸的黑貓 发表于 2025-2-1 02:17:54

實用度非常高
也想不到居然是AI生成

娱乐法师火布偶 发表于 2025-2-1 02:23:22

现在的AI写代码的能力太强大了

桀桀桀 发表于 2025-2-1 02:25:55

做取舍的时候确实有用,看库存还剩多少之类的_(:з」∠)_

毛茸茸兽兽 发表于 2025-2-1 02:36:40

挺好的,简单直接看出来赠品还剩多少,可以提醒坛花提前补货咯~

莲一 发表于 2025-2-1 02:39:09

太实用了这个脚本,阿星大佬厉害了:lol

ilovepizza 发表于 2025-2-1 02:40:16

大佬牛逼 加上勋章效果那就完美了

Raven_gambler 发表于 2025-2-1 02:50:25

好厉害的脚本,这可以省很多时间了

majar 发表于 2025-2-1 03:54:58

这个真的是超级实用的脚本 有心了!

fujiji 发表于 2025-2-1 04:16:46

好厉害 我也想有这种用ai写脚本的技能

ga2006024244 发表于 2025-2-1 04:30:33

判斷勳章補貨時是不是新的有幫助!!

轮回2L 发表于 2025-2-1 04:35:50

能直接看余量也能节省一些时间噜{:6_163:}

打开柜子看彩虹 发表于 2025-2-1 06:44:27

哈哈哈都想加上勋章效果

你好再见 发表于 2025-2-1 06:52:53

看了脚本我才注意,咒术赠礼的补货数量超过999,很直观的脚本

2302594 发表于 2025-2-1 07:20:52

AI现在真的是越来越强了,很有用的脚本啊
页: [1] 2 3 4
查看完整版本: 【油猴脚本】勋章商城展示内部编号、价格、库存余量