// ==UserScript== // @name A Dark Room(小黑屋/暗室/黑暗房间) 游戏资源辅助优化版(立即生效) // @namespace http://tampermonkey.net/ // @gameLink01 https://adarkroom.doublespeakgames.com/index.html // @gameLink01 https://game.ur1.fun/adarkroom/?lang=cn // @version 1.6.0.3 // @description 点击加满资源并立即刷新界面(小于999999才修改),新增一键刷木头、陷阱、开关自动攻击、取消探险冷却 (由于版本不同刷木头和陷阱需要先手动点一下) // @match *://*/* // @grant none // ==/UserScript== (function() { 'use strict'; function injectButton() { if (document.getElementById("buttonContainer")) return; let state; try { state = JSON.parse(localStorage.getItem("gameState")); } catch(e){} let resourceContainers = [ window.game && window.game.resources, window.room && window.room.resources, window.resources ]; // 检查是否存在可修改资源 let hasResources = (state && state.stores && "wood" in state.stores) || resourceContainers.some(c => c && "wood" in c); if (!hasResources) return; // === 按钮样式函数 === function styleButton(btn, color="#28a745") { btn.style.margin = "5px 0"; btn.style.padding = "6px 10px"; btn.style.border = "none"; btn.style.borderRadius = "6px"; btn.style.cursor = "pointer"; btn.style.background = color; btn.style.color = "white"; btn.style.fontSize = "14px"; btn.style.boxShadow = "0 2px 6px rgba(0,0,0,0.3)"; } // === 按钮容器 === const container = document.createElement("div"); container.id = "buttonContainer"; container.style.display = "flex"; container.style.flexDirection = "row"; container.style.position = "fixed"; container.style.top = "10px"; container.style.right = "10px"; container.style.zIndex = 9999; container.style.gap = "10px"; document.body.appendChild(container); // === 左列功能 === const leftColumn = document.createElement("div"); leftColumn.style.display = "flex"; leftColumn.style.flexDirection = "column"; container.appendChild(leftColumn); // 一键加满资源 const maxBtn = document.createElement("button"); maxBtn.innerText = "💰 一键加满资源"; styleButton(maxBtn); leftColumn.appendChild(maxBtn); maxBtn.onclick = function() { if(state && state.stores){ Object.keys(state.stores).forEach(k => { if(state.stores[k]<999999){ state.stores[k]=999999; } }); localStorage.setItem("gameState", JSON.stringify(state)); } resourceContainers.forEach(c=>{ if(c){ Object.keys(c).forEach(k=>{ if(c[k] && typeof c[k]==='object' && 'value' in c[k]){ if(c[k].value<999999){ c[k].value=999999; }}});} }); location.reload(); }; // 重置资源 const resetBtn = document.createElement("button"); resetBtn.innerText = "♻️ 重置资源"; styleButton(resetBtn, "#fd7e14"); leftColumn.appendChild(resetBtn); resetBtn.onclick = function() { if(state && state.stores){ Object.keys(state.stores).forEach(k => { state.stores[k] = 1; }); localStorage.setItem("gameState", JSON.stringify(state)); } resourceContainers.forEach(c=>{ if(c){ Object.keys(c).forEach(k=>{ if(c[k] && typeof c[k]==='object' && 'value' in c[k]){ c[k].value=1; }});} }); location.reload(); }; // 快速收集木头 let gatherBtn = document.createElement("button"); gatherBtn.innerText = "🪵 开始收集木头"; styleButton(gatherBtn, "#007bff"); leftColumn.appendChild(gatherBtn); let gatherTimer = null, isGathering = false; gatherBtn.onclick = function() { if (!isGathering) { gatherBtn.innerText = "🪵 结束收集木头"; isGathering = true; gatherTimer = setInterval(()=>{ $('#gatherButton').removeClass('disabled').click(); },100); } else { gatherBtn.innerText = "🪵 开始收集木头"; isGathering = false; clearInterval(gatherTimer); } }; // 快速查看陷阱 let trapBtn = document.createElement("button"); trapBtn.innerText = "🪤 开始查看陷阱"; styleButton(trapBtn, "#17a2b8"); leftColumn.appendChild(trapBtn); let trapTimer = null, isTrapping = false; trapBtn.onclick = function() { if (!isTrapping) { trapBtn.innerText = "🪤 结束查看陷阱"; isTrapping = true; trapTimer = setInterval(()=>{ $('#trapsButton').removeClass('disabled').click(); },100); } else { trapBtn.innerText = "🪤 开始查看陷阱"; isTrapping = false; clearInterval(trapTimer); } }; // === 右列探险 === const rightColumn = document.createElement("div"); rightColumn.style.display = "flex"; rightColumn.style.flexDirection = "column"; container.appendChild(rightColumn); // 自动击杀 let attackBtn = document.createElement("button"); attackBtn.id = "attackButton"; attackBtn.innerText = "👊 关闭自动击杀"; styleButton(attackBtn, "#dc3545"); rightColumn.appendChild(attackBtn); let attackFlag = true; attackBtn.onclick = function () { attackFlag = !attackFlag; attackBtn.innerText = attackFlag ? "👊 关闭自动击杀" : "👊 开启自动击杀"; }; setInterval(() => { if(attackFlag){ $('#attack_fists').removeClass('disabled').click(); $('#attack_steel-sword').removeClass('disabled').click(); } },100); // 自动取消冷却 let cooldownBtn = document.createElement("button"); cooldownBtn.id = "cooldownButton"; cooldownBtn.innerText = "🧌 探险冷却(有)"; styleButton(cooldownBtn, "#6f42c1"); rightColumn.appendChild(cooldownBtn); let cooldownFlag = false, cooldownInterval = null; cooldownBtn.onclick = function(){ if(!cooldownFlag){ cooldownFlag = true; cooldownBtn.innerText = "🧌 探险冷却(无)"; cooldownInterval = setInterval(()=>{ let embarkButton = document.querySelector("#embarkButton"); if(embarkButton){ embarkButton.classList.remove("disabled"); } $('#liftoffButton').removeClass('disabled'); },500); } else { cooldownFlag = false; cooldownBtn.innerText = "🧌 探险冷却(有)"; clearInterval(cooldownInterval); cooldownInterval = null; } }; } const interval = setInterval(() => { injectButton(); }, 500); })();