Contents [Hide]
SoNiC_enchère — v1.0.2
Added
- Added
+as a keyboard shortcut for the existing +1000 resources auction controls. - The
+shortcut follows the last resource used for the auction. The selected resource is remembered whether it was selected with a keyboard shortcut or manually through the normal OGame auctioneer control.
Fixed
- Fixed keyboard shortcuts becoming unavailable after navigating from Import/Export back to the Auctioneer within the Merchant interface.
- Fixed incorrect targeting when elements from dynamically loaded Merchant views remain present in the page.
Data / Requests / Automation
- The script only interacts with existing OGame interface elements in the user's browser.
- No OGame API is used.
- No external requests, external services, databases, polling or background data collection were added.
- No user or game data is collected, stored or transmitted.
- All actions are triggered directly by the user's keyboard or mouse interaction.
- No automatic bidding, scheduled actions, timers or background gameplay automation are introduced.
- The script only shortcuts the existing resource selection and bid controls already provided by the OGame Auctioneer interface.
Source Code
The complete, unminified source code for v1.0.2 is provided below.
Code
- // ==UserScript==
- // @name SoNiC_enchère
- // @namespace SoNiC
- // @version 1.0.2
- // @description Raccourcis clavier personnalisables pour le Marchand et le commissaire-priseur OGame
- // @author SoNiC
- // @license MIT
- // @match https://*.ogame.gameforge.com/game/index.php*
- // @grant none
- // @run-at document-start
- // ==/UserScript==
- (function () { 'use strict';
- const HOTKEYS = { metal: ['1', 'q'], crystal: ['2', 'w'], deuterium: ['3', 'e'], bid: ['Enter', 'r'], more: ['+'] };
- // Métal par défaut let lastResource = 'metal';
- const ACTIONS = { metal: 'a.js_sliderMetalMax', crystal: 'a.js_sliderCrystalMax', deuterium: 'a.js_sliderDeuteriumMax', bid: 'a.pay' };
- const MORE_ACTIONS = { metal: 'a.js_sliderMetalMore', crystal: 'a.js_sliderCrystalMore', deuterium: 'a.js_sliderDeuteriumMore' };
- function normalizeKey(key) { if (!key) { return ''; }
- return key.length === 1 ? key.toLowerCase() : key; }
- function matchesHotkey(hotkeys, key) { return hotkeys.some(function (hotkey) { return normalizeKey(hotkey) === key; }); }
- function isEditable(element) { if (!element || !(element instanceof Element)) { return false; }
- if (element.isContentEditable) { return true; }
- if (element.tagName === 'TEXTAREA') { return true; }
- if (element.tagName !== 'INPUT') { return false; }
- const type = (element.type || '').toLowerCase();
- return ( type === 'text' || type === 'search' || type === 'email' || type === 'password' || type === 'number' || type === 'tel' || type === 'url' ); }
- function findVisible(selector) { const elements = document.querySelectorAll(selector);
- for (const element of elements) { if (!element.isConnected) { continue; }
- const style = window.getComputedStyle(element);
- if ( style.display === 'none' || style.visibility === 'hidden' || style.opacity === '0' ) { continue; }
- if ( element.offsetWidth === 0 && element.offsetHeight === 0 ) { continue; }
- return element; }
- return null; }
- function clickAction(selector) { const element = findVisible(selector);
- if (!element) { return false; }
- element.click(); return true; }
- function handleKeydown(event) { if ( event.ctrlKey || event.altKey || event.metaKey ) { return; }
- if (isEditable(event.target)) { return; }
- if (event.repeat) { return; }
- const key = normalizeKey(event.key);
- // MÉTAL if (matchesHotkey(HOTKEYS.metal, key)) { if (clickAction(ACTIONS.metal)) { lastResource = 'metal'; event.preventDefault(); } return; }
- // CRISTAL if (matchesHotkey(HOTKEYS.crystal, key)) { if (clickAction(ACTIONS.crystal)) { lastResource = 'crystal'; event.preventDefault(); } return; }
- // DEUTÉRIUM if (matchesHotkey(HOTKEYS.deuterium, key)) { if (clickAction(ACTIONS.deuterium)) { lastResource = 'deuterium'; event.preventDefault(); } return; }
- // +1000 if (matchesHotkey(HOTKEYS.more, key)) { if (clickAction(MORE_ACTIONS[lastResource])) { event.preventDefault(); } return; }
- // ENCHÈRE if (matchesHotkey(HOTKEYS.bid, key)) { if (clickAction(ACTIONS.bid)) { event.preventDefault(); } } }
- // Mémorise également la ressource lorsqu'elle est // sélectionnée manuellement avec la souris. document.addEventListener( 'click', function (event) { const target = event.target;
- if (!target || !(target instanceof Element)) { return; }
- if (target.closest('a.js_sliderMetalMax')) { lastResource = 'metal'; return; }
- if (target.closest('a.js_sliderCrystalMax')) { lastResource = 'crystal'; return; }
- if (target.closest('a.js_sliderDeuteriumMax')) { lastResource = 'deuterium'; } }, true );
- document.addEventListener( 'keydown', handleKeydown, false );
- })();
