Files
background.js
content.js
main.js
manifest.json
styles.css
Code
5 1,757
main.js
// Haxball Enhancer - Main Script
// Runs in page context to access Haxball internals
(function() {
'use strict';
// ==================== SETTINGS MANAGER ====================
class SettingsManager {
constructor() {
this.settings = this.loadSettings();
}
loadSettings() {
const defaults = {
// Lobby
autoRefresh: false,
refreshInterval: 5,
minPlayers: 0,
maxPlayers: 30,
maxPing: 500,
filterLocked: false,
filterStadium: 'all',
favorites: [],
// In-Game
cameraZoom: 1.0,
freeCameraMode: false,
playerHighlight: false,
ballPrediction: false,
keyOverlay: false,
replayBuffer: false,
replayDuration: 30,
// Visual
theme: 'dark',
ballTrail: false,
ballTrailLength: 10,
playerTrail: false,
playerGlow: false,
glowOpacity: 0.5,
// Performance
fpsUnlock: false,
targetFPS: 60,
frameSkip: 1,
canvasScale: 1.0,
lowPerfMode: false,
showFPS: false,
// Network
showPing: true,
packetMonitor: false,
simulatedLatency: 0,
latencyJitter: 0,
// Training
aimAssistVis: false,
ballPredictionCircle: false,
movementGrid: false,
gridSize: 50,
// UI
panelPosition: { x: window.innerWidth - 440, y: 100 },
panelVisible: true,
hotkeys: {
togglePanel: 'F1',
toggleFPS: 'F2',
quickJoin: 'ctrl+j',
toggleReplay: 'F9'
}
};
try {
const saved = localStorage.getItem('haxballEnhancer');
return saved ? { ...defaults, ...JSON.parse(saved) } : defaults;
} catch (e) {
console.error('[HBE] Failed to load settings:', e);
return defaults;
}
}
saveSettings() {
try {
localStorage.setItem('haxballEnhancer', JSON.stringify(this.settings));
} catch (e) {
console.error('[HBE] Failed to save settings:', e);
}
}
get(key) {
return this.settings[key];
}
set(key, value) {
this.settings[key] = value;
this.saveSettings();
}
}
// ==================== UI MANAGER ====================
class UIManager {
constructor(settings, features) {
this.settings = settings;
this.features = features;
this.panel = null;
this.isDragging = false;
this.dragOffset = { x: 0, y: 0 };
this.currentTab = 'lobby';
this.createPanel();
this.attachEventListeners();
this.updateAllControls();
}
createPanel() {
this.panel = document.createElement('div');
this.panel.className = 'hbe-panel';
this.panel.innerHTML = `
<div class="hbe-header">
<h2>⚡ Haxball Enhancer</h2>
<div class="hbe-header-actions">
<button class="hbe-header-btn" id="hbe-minimize">−</button>
<button class="hbe-header-btn" id="hbe-close">×</button>
</div>
</div>
<div class="hbe-tabs">
<button class="hbe-tab active" data-tab="lobby">🏠 Lobby</button>
<button class="hbe-tab" data-tab="ingame">🎮 In-Game</button>
<button class="hbe-tab" data-tab="visual">🎨 Visual</button>
<button class="hbe-tab" data-tab="performance">⚡ Performance</button>
<button class="hbe-tab" data-tab="network">🌐 Network</button>
<button class="hbe-tab" data-tab="training">🎯 Training</button>
</div>
<div class="hbe-content">
${this.createLobbyTab()}
${this.createInGameTab()}
${this.createVisualTab()}
${this.createPerformanceTab()}
${this.createNetworkTab()}
${this.createTrainingTab()}
</div>
`;
document.body.appendChild(this.panel);
// Position panel
const pos = this.settings.get('panelPosition');
this.panel.style.left = pos.x + 'px';
this.panel.style.top = pos.y + 'px';
if (!this.settings.get('panelVisible')) {
this.panel.classList.add('hbe-hidden');
}
}
createLobbyTab() {
return `
<div class="hbe-tab-pane active" data-pane="lobby">
<div class="hbe-section">
<h3 class="hbe-section-title">Auto Refresh</h3>
<div class="hbe-control">
<div class="hbe-toggle-wrapper">
<span class="hbe-toggle-label">Auto Refresh Room List</span>
<div class="hbe-toggle" id="toggle-autoRefresh"></div>
</div>
</div>
<div class="hbe-control">
<div class="hbe-slider-wrapper">
<div class="hbe-label">
<span>Refresh Interval</span>
<span id="value-refreshInterval">5s</span>
</div>
<input type="range" class="hbe-slider" id="slider-refreshInterval" min="3" max="30" step="1" value="5">
</div>
</div>
</div>
<div class="hbe-divider"></div>
<div class="hbe-section">
<h3 class="hbe-section-title">Filters</h3>
<div class="hbe-control">
<div class="hbe-label">
<span>Min Players</span>
<span id="value-minPlayers">0</span>
</div>
<input type="range" class="hbe-slider" id="slider-minPlayers" min="0" max="20" step="1" value="0">
</div>
<div class="hbe-control">
<div class="hbe-label">
<span>Max Players</span>
<span id="value-maxPlayers">30</span>
</div>
<input type="range" class="hbe-slider" id="slider-maxPlayers" min="1" max="30" step="1" value="30">
</div>
<div class="hbe-control">