// ==UserScript== // @name Newest easy-fight (All-in-one version) // @namespace seintz.torn.easy-fight // @version 2.6 // @description move start fight, outcome and continue buttons for easy click. Includes All-in-One and specific weapon options. // @author seintz [2460991], Finaly [2060206], Anxiety [2149726], Brother [2590792] // @license GNU GPLv3 // @run-at document-end // @match https://www.torn.com/loader.php?sid=attack* // @match https://www.torn.com/page.php?sid=attack* // @grant GM_setValue // @grant GM_getValue // ==/UserScript== (function () { 'use strict'; // ---- storage: GM_* when available (Tampermonkey/Violentmonkey), else localStorage // (Greasemonkey 4 on Firefox has no synchronous GM_* functions). const store = { get(key, def) { try { if (typeof GM_getValue === 'function') return GM_getValue(key, def); } catch (e) { /* fall through */ } try { const v = localStorage.getItem('easyfight.' + key); return v === null ? def : JSON.parse(v); } catch (e) { return def; } }, set(key, val) { try { if (typeof GM_setValue === 'function') return GM_setValue(key, val); } catch (e) { /* fall through */ } try { localStorage.setItem('easyfight.' + key, JSON.stringify(val)); } catch (e) { /* ignore */ } }, }; // TornPDA can inject the same script twice into one page; only run once. if (window.__easyFightLoaded) return; window.__easyFightLoaded = true; // Validate stored values: some managers' GM shims (e.g. TornPDA) can hand back // promises or strings instead of the stored value. function pick(key, def, allowed) { let v = store.get(key, def); if (typeof def === 'boolean' && typeof v === 'string') v = v === 'true'; if (allowed ? !allowed.includes(v) : typeof v !== typeof def) return def; return v; } const isPhone = window.innerWidth <= 600; const settings = { outcome: pick('outcome', 'leave', ['leave', 'mug', 'hosp']), weapon: pick('defaultWeapon', 'all', ['all', 'primary', 'secondary', 'melee']), useTemp: pick('useTemp', true), collapsed: pick('panelCollapsed', isPhone), // start folded up on phones }; const OUTCOME_INDEX = { leave: 0, mug: 1, hosp: 2 }; const OUTCOME_TEXTS = ['leave', 'mug', 'hospitalize']; const CONTAINER = 'div[class*="dialogButtons___"]'; const MOVED = 'ef-move'; // ---- styling: one