// ==UserScript==
// @name GWars Space Hotkey (Battles + Log)
// @namespace http://tampermonkey.net/
// @version 2.0
// @description Space key handler for both active battles and battle logs
// @author Forbidden(mx)
// @match
https://www.gwars.io/warlog.php?bid=*
// @match
https://www.gwars.io/b0/b.php?bid=*
// @grant none
// ==/UserScript==
(function() {
'use strict';
document.addEventListener('keydown', function(e) {
// Handle Space key (keyCode 32)
if (e.keyCode === 32) {
// Check if focused on input/editable element
const activeElem = document.activeElement;
const isInput = activeElem.tagName === 'INPUT' ||
activeElem.tagName === 'TEXTAREA' ||
activeElem.isContentEditable;
if (!isInput) {
e.preventDefault();
// For battle log pages (warlog.php)
if (window.location.pathname === '/warlog.php') {
window.location.href = '/walk.php';
}
// For active battle pages (b.php)
else if (window.location.pathname === '/b0/b.php') {
const refreshButton = document.getElementById('refreshbutton');
if (refreshButton) refreshButton.click();
}
}
}
});
})();