您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Tracks Keno number frequency during a session and displays the top 10 hottest numbers. Waits for dynamic content.
当前为
// ==UserScript== // @name Torn Keno Hot Numbers // @namespace torn.keno.hotnumbers.tracker // @version 2.6 // @description Tracks Keno number frequency during a session and displays the top 10 hottest numbers. Waits for dynamic content. // @author Torn City Userscript Development Assistant // @match https://www.torn.com/page.php?sid=keno // @icon https://www.google.com/s2/favicons?sz=64&domain=torn.com // @grant none // @run-at document-start // @license MIT // ==/UserScript== (function() { 'use strict'; // --- CONFIGURATION & STATE --- const KENO_DATA_URL_FRAGMENT = 'page.php?rfcv='; let numberFrequency = {}; let isInitialized = false; // Flag to prevent the script from running multiple times // --- CORE LOGIC --- function addCustomStyles() { const style = document.createElement('style'); style.innerHTML = ` #keno-hot-numbers-container { background-color: #f2f2f2; border-radius: 5px; margin-bottom: 10px; border: 1px solid #ccc; } .dark-mode #keno-hot-numbers-container { background-color: #3d3d3d; border-color: #444; } .keno-hot-numbers-header { padding: 10px; background-color: #e8e8e8; border-top-left-radius: 5px; border-top-right-radius: 5px; font-weight: bold; color: #333; border-bottom: 1px solid #ddd; } .dark-mode .keno-hot-numbers-header { background-color: #2e2e2e; border-color: #444; color: #ccc; } #keno-hot-numbers-body { padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 40px; align-items: center; color: #666; } .dark-mode #keno-hot-numbers-body { color: #999; } .hot-number-pill { background-color: #fff; border: 1px solid #ccc; border-radius: 20px; padding: 5px 10px; font-size: 14px; display: flex; align-items: center; gap: 5px; box-shadow: 0 1px 1px rgba(0,0,0,0.05); } .dark-mode .hot-number-pill { background-color: #222; border-color: #555; box-shadow: none; } .hot-number-pill strong { color: #000; } .dark-mode .hot-number-pill strong { color: #eee; } .hot-number-pill span { font-size: 12px; color: #555; } .dark-mode .hot-number-pill span { color: #888; } `; document.head.appendChild(style); } function createHotNumbersUI() { const kenoBoard = document.getElementById('boardContainer'); if (!kenoBoard) return; if (document.getElementById('keno-hot-numbers-container')) return; const container = document.createElement('div'); container.id = 'keno-hot-numbers-container'; container.innerHTML = `<div class="keno-hot-numbers-header">Hot Numbers (Session)</div><div id="keno-hot-numbers-body">Play a round to start tracking numbers...</div>`; // Inserts our new container right before the Keno board element kenoBoard.parentNode.insertBefore(container, kenoBoard); } function updateHotNumbersDisplay(drawnNumbers) { drawnNumbers.forEach(num => { numberFrequency[num] = (numberFrequency[num] || 0) + 1; }); const sortedNumbers = Object.entries(numberFrequency) .sort(([, aCount], [, bCount]) => bCount - aCount) .slice(0, 10); const displayBody = document.getElementById('keno-hot-numbers-body'); if (!displayBody) return; displayBody.innerHTML = sortedNumbers.length === 0 ? 'Waiting for results...' : sortedNumbers.map(([number, count]) => `<div class="hot-number-pill"><strong>${number}</strong><span>(x${count})</span></div>`).join(''); } function interceptFetch() { const originalFetch = window.fetch; if (originalFetch.name === 'hotNumbersFetch') return; // Avoid re-wrapping window.fetch = async function hotNumbersFetch(...args) { const response = await originalFetch(...args); const url = args[0]; if (typeof url === 'string' && url.includes(KENO_DATA_URL_FRAGMENT)) { response.clone().json() .then(data => data && data.randomNumbers && updateHotNumbersDisplay(data.randomNumbers)) .catch(err => console.error("[Keno Tracker] Error parsing game JSON:", err)); } return response; }; } // --- INITIALIZATION --- /** * This is the main payload of our script. It adds the UI and functionality. */ function initializeScript() { if (isInitialized) return; // Don't run twice isInitialized = true; console.log("[Keno Tracker] Keno board found. Initializing..."); addCustomStyles(); createHotNumbersUI(); interceptFetch(); console.log("[Keno Tracker] Script fully active."); } /** * Watches the DOM for when the '#boardContainer' element is added to the page. * This is necessary because Torn loads game content dynamically with JavaScript. */ const observer = new MutationObserver((mutationsList, obs) => { if (document.getElementById('boardContainer')) { initializeScript(); obs.disconnect(); // Stop observing once we've found our target and initialized } }); // Start observing the entire document body for additions of new elements. // This is the most reliable way to catch content injected by frameworks. observer.observe(document.body, { childList: true, subtree: true }); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址