|
|
本帖最后由 Makima 于 2025-12-23 16:28 编辑
统计二手市场勋章数量,支持一键购买最低价
很早就写了,一直没发 @Name @Match
- // ==UserScript==
- // @name 二手市场优化显示
- // @version 0.2
- // @description 显示每类勋章的最低售价和数量
- // @author MKM
- // @match https://www.gamemale.com/wodexunzhang-showxunzhang.html?action=showjishou
- // ==/UserScript==
- (function() {
- 'use strict';
- const container = document.querySelector('.myfldiv');
- if (!container) return;
- const items = Array.from(container.querySelectorAll('.myblok'));
- const grouped = {};
- items.forEach(item => {
- const name = item.querySelector('p[title]').title;
- const priceText = item.querySelector('.mytip .jiage:last-child b').textContent;
- const price = parseInt(priceText.match(/\d+/)[0]);
- const id = item.querySelector('.mytip').id.replace('er', '');
- if (!grouped[name]) {
- grouped[name] = [];
- }
- grouped[name].push({
- element: item,
- price: price,
- id: id
- });
- });
- const result = [];
- for (const name in grouped) {
- const items = grouped[name];
- const minPriceItem = items.reduce((min, item) => item.price < min.price ? item : min);
- const count = items.length;
- result.push({
- name: name,
- element: minPriceItem.element,
- price: minPriceItem.price,
- count: count,
- id: minPriceItem.id
- });
- }
- result.sort((a, b) => b.count - a.count);
- container.innerHTML = '';
- result.forEach(item => {
- const countSpan = document.createElement('span');
- countSpan.textContent = ` (${item.count})`;
- countSpan.style.color = '#ff6b6b';
- countSpan.style.fontWeight = 'bold';
- countSpan.style.marginLeft = '5px';
- const nameElement = item.element.querySelector('p[title]');
- nameElement.appendChild(countSpan);
- container.appendChild(item.element);
- });
- })();
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
评分
-
查看全部评分
|