您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Show only the total stack market value on hover in Dead Frontier Outpost.
当前为
// ==UserScript== // @name Dead Frontier Value On Hover // @namespace http://tampermonkey.net/ // @version 1.1 // @license MIT // @description Show only the total stack market value on hover in Dead Frontier Outpost. // @author Zega // @match https://fairview.deadfrontier.com/* // @grant unsafeWindow // ==/UserScript== (function () { 'use strict'; // 1) Build ID→name map from page’s globalData const pageData = unsafeWindow.globalData || {}; const itemNames = {}; for (let id in pageData) { if (pageData[id] && pageData[id].name) { itemNames[id] = pageData[id].name; } } // 2) Tooltip styling const style = document.createElement('style'); style.textContent = ` .price-tooltip { position: absolute; background: rgba(0,0,0,0.85); color: #fff; padding: 6px 10px; font-size: 12px; border-radius: 6px; pointer-events: none; z-index: 9999; display: none; } `; document.head.appendChild(style); const tooltip = document.createElement('div'); tooltip.className = 'price-tooltip'; document.body.appendChild(tooltip); // 3) Attach hover listeners function attachListeners() { document.querySelectorAll('.item:not([data-hover-added])').forEach(el => { el.setAttribute('data-hover-added', 'true'); el.addEventListener('mouseenter', async e => { const type = el.getAttribute('data-type'); const name = itemNames[type] || el.getAttribute('data-name'); const stack = parseInt(el.getAttribute('data-quantity')) || 1; if (!name || stack < 1) return; // fetch per-unit price const unit = await fetchUnitPrice(name); if (unit == null) { tooltip.textContent = 'No listings'; } else { const total = unit * stack; tooltip.textContent = `$${total.toFixed(2)} total`; } tooltip.style.left = `${e.pageX + 12}px`; tooltip.style.top = `${e.pageY + 12}px`; tooltip.style.display = 'block'; }); el.addEventListener('mouseleave', () => { tooltip.style.display = 'none'; }); }); } const observer = new MutationObserver(attachListeners); observer.observe(document.body, { childList: true, subtree: true }); attachListeners(); // 4) Fetch best per-unit price, return number or null async function fetchUnitPrice(itemName) { const rawHash = getCookie('DeadFrontierFairview') || ''; const hash = decodeURIComponent(rawHash); const pagetime = Math.floor(Date.now() / 1000); const payload = { hash, pagetime, tradezone: 21, search: 'trades', searchtype: 'buyinglistitemname', searchname: itemName }; try { const res = await fetch('https://fairview.deadfrontier.com/onlinezombiemmo/trade_search.php', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'X-Requested-With': 'XMLHttpRequest', 'Referer': location.href, 'Origin': location.origin }, body: Object.entries(payload) .map(([k,v])=>`${k}=${encodeURIComponent(v)}`) .join('&') }); const text = await res.text(); const matches = [...text.matchAll(/tradelist_\d+_price=(\d+)&.*?tradelist_\d+_quantity=(\d+)/g)] .map(m => Number(m[1]) / Number(m[2])) .sort((a,b) => a - b); return matches.length ? matches[0] : null; } catch (err) { console.error('fetchUnitPrice error', err); return null; } } function getCookie(name) { const v = `; ${document.cookie}`; const parts = v.split(`; ${name}=`); return parts.length === 2 ? parts.pop().split(';')[0] : ''; } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址