// ── Settings page: auto-sell/salvage defaults ── function enhanceSettings() { if (document.getElementById('hv-settings-enh')) return; const autoTable = document.getElementById('settings_autosalvage'); if (!autoTable) return; // Check current state const rows = []; $$('tr', autoTable).forEach(tr => { const sellSelect = tr.querySelector('select[name^="as_c_"]'); const salvSelect = tr.querySelector('select[name^="as_s_"]'); if (!sellSelect || !salvSelect) return; const itemName = (tr.querySelector('td:first-child')?.textContent || '').trim(); rows.push({ name: itemName, sell: sellSelect, salv: salvSelect, sellVal: parseInt(sellSelect.value), salvVal: parseInt(salvSelect.value), }); }); if (rows.length === 0) return; // Build toolbar const bar = document.createElement('div'); bar.id = 'hv-settings-enh'; bar.style.cssText = css({ margin: '8px 0', padding: '6px 8px', background: '#1a1a2e', borderRadius: '4px', fontSize: '10px', fontFamily: 'monospace', display: 'flex', gap: '4px', flexWrap: 'wrap', alignItems: 'center', border: '1px solid #374151', }); const label = document.createElement('span'); label.style.cssText = 'color:#fdcb00;font-weight:bold;margin-right:6px'; label.textContent = '⚙ Auto-Sell/Salvage'; bar.appendChild(label); // Preset: Sell Fair (2), Salvage Average (3) const preset1 = document.createElement('input'); preset1.type = 'button'; preset1.value = '💰 Sell ≤Fair / ♻ Salvage ≤Average'; preset1.style.cssText = 'padding:3px 8px;cursor:pointer;background:#2a5a2a;color:#fff;border:none;border-radius:3px;font-size:10px'; preset1.onclick = () => applyPreset(rows, 2, 3); bar.appendChild(preset1); // Preset: Sell Crude (1), Salvage Fair (2) — more conservative const preset2 = document.createElement('input'); preset2.type = 'button'; preset2.value = '💰 Sell ≤Crude / ♻ Salvage ≤Fair'; preset2.style.cssText = 'padding:3px 8px;cursor:pointer;background:#5a3a2a;color:#fff;border:none;border-radius:3px;font-size:10px'; preset2.onclick = () => applyPreset(rows, 1, 2); bar.appendChild(preset2); // Reset to No Auto-Sell/Salvage const resetBtn = document.createElement('input'); resetBtn.type = 'button'; resetBtn.value = '✗ Disable All'; resetBtn.style.cssText = 'padding:3px 8px;cursor:pointer;background:#555;color:#fff;border:none;border-radius:3px;font-size:10px'; resetBtn.onclick = () => applyPreset(rows, 0, 0); bar.appendChild(resetBtn); // Summary of current state const summary = document.createElement('span'); summary.style.cssText = 'color:#888;margin-left:6px'; const sellVals = rows.map(r => r.sellVal); const salvVals = rows.map(r => r.salvVal); const minSell = Math.min(...sellVals); const minSalv = Math.min(...salvVals); const maxSell = Math.max(...sellVals); const maxSalv = Math.max(...salvVals); const sellLabel = minSell === maxSell ? VAL_LABELS_SELL[minSell] : 'mixed'; const salvLabel = minSalv === maxSalv ? VAL_LABELS_SALV[minSalv] : 'mixed'; summary.textContent = `Current: Sell ${sellLabel} | Salvage ${salvLabel}`; bar.appendChild(summary); // Insert above the auto-salvage table autoTable.parentNode.insertBefore(bar, autoTable); function applyPreset(rows, sellVal, salvVal) { rows.forEach(r => { r.sell.value = sellVal; r.salv.value = salvVal; }); // Update summary summary.textContent = `Current: Sell ${VAL_LABELS_SELL[sellVal]} | Salvage ${VAL_LABELS_SALV[salvVal]}`; } } const VAL_LABELS_SELL = ['Off', 'Crude', 'Fair', 'Average', 'Superior', 'Exquisite', 'Magnificent', 'Legendary']; const VAL_LABELS_SALV = ['Off', 'Crude', 'Fair', 'Average', 'Superior', 'Exquisite', 'Magnificent', 'Legendary'];