// ==UserScript== // @name Chat Font Control // @namespace https://github.com/PlayMaGame/oe2-userscripts // @author PlayMaGame // @license MIT // @version 4.1 // @description Adjust in-game chat font size and toggle bold — follows chat resize // @match https://game.dev.outerempires.net/* // @grant none // ==/UserScript== (function () { 'use strict'; const STORAGE_KEY_SIZE = 'chatFontSize'; const STORAGE_KEY_BOLD = 'chatFontBold'; const MIN_SIZE = 10; const MAX_SIZE = 40; const STEP = 2; const DEFAULT_SIZE_MINI = 12; const DEFAULT_SIZE_NORMAL = 14; let fontSize = parseInt(localStorage.getItem(STORAGE_KEY_SIZE), 10); let isBold = localStorage.getItem(STORAGE_KEY_BOLD) === 'true'; let wrap = null; // ── Detect chat size ── function isMini() { const area = document.getElementById('ui_chat_area'); return area && area.classList.contains('min'); } function getDefaultSize() { return isMini() ? DEFAULT_SIZE_MINI : DEFAULT_SIZE_NORMAL; } if (!fontSize || fontSize < MIN_SIZE || fontSize > MAX_SIZE) { fontSize = getDefaultSize(); } // ── Style injection ── function applyStyle() { let el = document.getElementById('oe-chat-font-style'); if (!el) { el = document.createElement('style'); el.id = 'oe-chat-font-style'; document.head.appendChild(el); } el.textContent = ` .ui_chat_output_message, .ui_chat_output_message * { font-size: ${fontSize}px !important; font-weight: ${isBold ? 'bold' : 'inherit'} !important; } `; } const IDS = { wrap: 'oe-font-wrap', dec: 'oe-font-dec', label: 'oe-font-label', inc: 'oe-font-inc', bold: 'oe-font-bold', }; const BTN_STYLE = 'display:flex;align-items:center;justify-content:center;' + 'width:15px;height:15px;cursor:pointer;'; const BTN_BG = 'rgba(0,0,0,0.35)'; const CLR = '#43eca1'; // ── Inject wrapper (flex row, visual order = DOM order) ── function injectControls() { const area = document.getElementById('ui_chat_area'); if (!area) return false; if (document.getElementById(IDS.wrap)) return true; wrap = document.createElement('div'); wrap.id = IDS.wrap; wrap.style.cssText = 'position:absolute;height:18px;z-index:1;' + 'display:flex;flex-direction:row;align-items:center;' + 'gap:2px;pointer-events:none;'; // DOM order = visual order: [−] [14] [+] [B] wrap.innerHTML = `