您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Makes chain timer bigger and sets hit count red when close to milestone
当前为
// ==UserScript== // @name Torn - Big Chain Timer // @namespace http://tampermonkey.net/ // @version 0.2 // @description Makes chain timer bigger and sets hit count red when close to milestone // @author ChuckFlorist [3135868] // @match https://www.torn.com/factions.php* // @license MIT // ==/UserScript== (function() { 'use strict'; const SPAN_TOP = "span.chain-box-top-stat"; const SPAN_COUNT = "span.chain-box-center-stat"; const SPAN_TIME = "span.chain-box-timeleft"; const HITS_WARNING = 5; // hits before milestone const ranges = [ { start: "04:00", end: "05:00", color: "#00FF00" }, // Lime { start: "03:00", end: "04:00", color: "#FFFF00" }, // Yellow { start: "02:00", end: "03:00", color: "#FF9900" }, // Orange { start: "00:00", end: "02:00", color: "#FF0000" } // Red ]; const milestones = [1000, 2500, 5000, 10000, 25000, 50000, 100000]; function toSeconds(sTime) { const [mins, secs] = sTime.split(":").map(Number); return mins * 60 + secs; } function getColorForTime(time) { const totalSecs = toSeconds(time); for (let range of ranges) { const min = toSeconds(range.start); const max = toSeconds(range.end); if (totalSecs >= min && totalSecs < max) { return range.color; } } return "#FF0000"; // default to red } function updateHitCount(cntSpan) { if (cntSpan){ let nHits = Number(cntSpan.textContent.replace(/,/g, '')); let isClose = milestones.some(ms => (nHits >= ms - HITS_WARNING && nHits < ms)); let colr = isClose ? 'red' : '#798C3D'; // red or normal torn green color let size = isClose ? '30px' : '20px'; cntSpan.style.setProperty('color', colr, 'important'); cntSpan.style.setProperty('font-size', size, 'important'); } } function updateTimer(tmrSpan) { if (tmrSpan) { let color = getColorForTime(tmrSpan.textContent); tmrSpan.style.setProperty('font-size', '40px', 'important'); tmrSpan.style.setProperty('color', color, 'important'); } } function createObservers(tmrSpan, cntSpan) { const config = { characterData: true, subtree: true }; if (cntSpan) { let hitCountObs = new MutationObserver(function(mutationsList, hitCountObs) { for (let mutation of mutationsList) { updateHitCount(); } }); hitCountObs.observe(cntSpan, config); } if (tmrSpan) { let tmrObs = new MutationObserver(function(mutationsList, tmrObs) { for (let mutation of mutationsList) { updateTimer(); } }); tmrObs.observe(tmrSpan, config); } } function runScript() { try { let topSpan = document.querySelectorAll(SPAN_TOP)[0]; if (topSpan){ topSpan.remove(); // remove this span to make more room } let tmrSpan = document.querySelectorAll(SPAN_TIME)[0]; updateTimer(tmrSpan); let cntSpan = document.querySelectorAll(SPAN_COUNT)[0]; updateHitCount(cntSpan); createObservers(tmrSpan, cntSpan); } catch (ex) { alert(ex.message); } } setTimeout(runScript, 1000); // Re-run the script every time the hash changes window.onhashchange = function() { setTimeout(runScript, 1000); }; })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址