v0.13.25 - Debounce Q key to prevent spam on held-key repeat
- Added _lastQTime debounce (300ms) to the Q key handler - Holding Q now fires at most ~3 actions per second instead of ~20, preventing duplicate actions from stale state reads - The previous issue: 6 identical Haste casts, then 8 identical Spark casts, then 12 identical Heartseeker casts — all from state not yet updated by the game
This commit is contained in:
parent
86968f531c
commit
8c21920d4b
5 changed files with 30 additions and 6 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name HV Unified
|
// @name HV Unified
|
||||||
// @namespace hvunified
|
// @namespace hvunified
|
||||||
// @version 0.13.24
|
// @version 0.13.25
|
||||||
// @description HV Unified — battle automation, guidance, and UI enhancements for HentaiVerse
|
// @description HV Unified — battle automation, guidance, and UI enhancements for HentaiVerse
|
||||||
// @author GaboGG + Hermes
|
// @author GaboGG + Hermes
|
||||||
// @match *://*.hentaiverse.org/*
|
// @match *://*.hentaiverse.org/*
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
// CONFIG — default settings
|
// CONFIG — default settings
|
||||||
// ═══════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
const VERSION = '0.13.24';
|
const VERSION = '0.13.25';
|
||||||
|
|
||||||
const CFG = {
|
const CFG = {
|
||||||
// — Battle automation
|
// — Battle automation
|
||||||
|
|
@ -1549,6 +1549,8 @@ function setupHover() {
|
||||||
// ═══════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
let keybindingsSetup = false;
|
let keybindingsSetup = false;
|
||||||
|
let _lastQTime = 0;
|
||||||
|
const Q_DEBOUNCE_MS = 300; // Ignore Q repeats faster than this
|
||||||
|
|
||||||
function setupKeybindings() {
|
function setupKeybindings() {
|
||||||
if (keybindingsSetup) return;
|
if (keybindingsSetup) return;
|
||||||
|
|
@ -1559,6 +1561,7 @@ function setupKeybindings() {
|
||||||
if (e.keyCode === KEYS.COMMA) {
|
if (e.keyCode === KEYS.COMMA) {
|
||||||
if (isBattlePage()) {
|
if (isBattlePage()) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
STATE.settingsVisible = !STATE.settingsVisible;
|
||||||
toggleSettings();
|
toggleSettings();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1567,6 +1570,11 @@ function setupKeybindings() {
|
||||||
// Main action hotkey (default: Q)
|
// Main action hotkey (default: Q)
|
||||||
if (e.code === CFG.hotkey && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
if (e.code === CFG.hotkey && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
||||||
if (!isInputFocused() && isBattlePage()) {
|
if (!isInputFocused() && isBattlePage()) {
|
||||||
|
// Debounce: ignore key-repeats until game processes the action
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - _lastQTime < Q_DEBOUNCE_MS) return;
|
||||||
|
_lastQTime = now;
|
||||||
|
|
||||||
console.log('%c[HV] Q pressed — checking action...', 'color:#888');
|
console.log('%c[HV] Q pressed — checking action...', 'color:#888');
|
||||||
parseBattleState();
|
parseBattleState();
|
||||||
// Debug: show active buffs and channeling status
|
// Debug: show active buffs and channeling status
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name HV Unified
|
// @name HV Unified
|
||||||
// @namespace hvunified
|
// @namespace hvunified
|
||||||
// @version 0.13.24
|
// @version 0.13.25
|
||||||
// @description HV Unified — battle automation, guidance, and UI enhancements for HentaiVerse
|
// @description HV Unified — battle automation, guidance, and UI enhancements for HentaiVerse
|
||||||
// @author GaboGG + Hermes
|
// @author GaboGG + Hermes
|
||||||
// @match *://*.hentaiverse.org/*
|
// @match *://*.hentaiverse.org/*
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
// CONFIG — default settings
|
// CONFIG — default settings
|
||||||
// ═══════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
const VERSION = '0.13.24';
|
const VERSION = '0.13.25';
|
||||||
|
|
||||||
const CFG = {
|
const CFG = {
|
||||||
// — Battle automation
|
// — Battle automation
|
||||||
|
|
@ -1549,6 +1549,8 @@ function setupHover() {
|
||||||
// ═══════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
let keybindingsSetup = false;
|
let keybindingsSetup = false;
|
||||||
|
let _lastQTime = 0;
|
||||||
|
const Q_DEBOUNCE_MS = 300; // Ignore Q repeats faster than this
|
||||||
|
|
||||||
function setupKeybindings() {
|
function setupKeybindings() {
|
||||||
if (keybindingsSetup) return;
|
if (keybindingsSetup) return;
|
||||||
|
|
@ -1559,6 +1561,7 @@ function setupKeybindings() {
|
||||||
if (e.keyCode === KEYS.COMMA) {
|
if (e.keyCode === KEYS.COMMA) {
|
||||||
if (isBattlePage()) {
|
if (isBattlePage()) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
STATE.settingsVisible = !STATE.settingsVisible;
|
||||||
toggleSettings();
|
toggleSettings();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1567,6 +1570,11 @@ function setupKeybindings() {
|
||||||
// Main action hotkey (default: Q)
|
// Main action hotkey (default: Q)
|
||||||
if (e.code === CFG.hotkey && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
if (e.code === CFG.hotkey && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
||||||
if (!isInputFocused() && isBattlePage()) {
|
if (!isInputFocused() && isBattlePage()) {
|
||||||
|
// Debounce: ignore key-repeats until game processes the action
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - _lastQTime < Q_DEBOUNCE_MS) return;
|
||||||
|
_lastQTime = now;
|
||||||
|
|
||||||
console.log('%c[HV] Q pressed — checking action...', 'color:#888');
|
console.log('%c[HV] Q pressed — checking action...', 'color:#888');
|
||||||
parseBattleState();
|
parseBattleState();
|
||||||
// Debug: show active buffs and channeling status
|
// Debug: show active buffs and channeling status
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// CONFIG — default settings
|
// CONFIG — default settings
|
||||||
// ═══════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
const VERSION = '0.13.24';
|
const VERSION = '0.13.25';
|
||||||
|
|
||||||
const CFG = {
|
const CFG = {
|
||||||
// — Battle automation
|
// — Battle automation
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name HV Unified
|
// @name HV Unified
|
||||||
// @namespace hvunified
|
// @namespace hvunified
|
||||||
// @version 0.13.24
|
// @version 0.13.25
|
||||||
// @description HV Unified — battle automation, guidance, and UI enhancements for HentaiVerse
|
// @description HV Unified — battle automation, guidance, and UI enhancements for HentaiVerse
|
||||||
// @author GaboGG + Hermes
|
// @author GaboGG + Hermes
|
||||||
// @match *://*.hentaiverse.org/*
|
// @match *://*.hentaiverse.org/*
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
// ═══════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
let keybindingsSetup = false;
|
let keybindingsSetup = false;
|
||||||
|
let _lastQTime = 0;
|
||||||
|
const Q_DEBOUNCE_MS = 300; // Ignore Q repeats faster than this
|
||||||
|
|
||||||
function setupKeybindings() {
|
function setupKeybindings() {
|
||||||
if (keybindingsSetup) return;
|
if (keybindingsSetup) return;
|
||||||
|
|
@ -13,6 +15,7 @@ function setupKeybindings() {
|
||||||
if (e.keyCode === KEYS.COMMA) {
|
if (e.keyCode === KEYS.COMMA) {
|
||||||
if (isBattlePage()) {
|
if (isBattlePage()) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
STATE.settingsVisible = !STATE.settingsVisible;
|
||||||
toggleSettings();
|
toggleSettings();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -21,6 +24,11 @@ function setupKeybindings() {
|
||||||
// Main action hotkey (default: Q)
|
// Main action hotkey (default: Q)
|
||||||
if (e.code === CFG.hotkey && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
if (e.code === CFG.hotkey && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
||||||
if (!isInputFocused() && isBattlePage()) {
|
if (!isInputFocused() && isBattlePage()) {
|
||||||
|
// Debounce: ignore key-repeats until game processes the action
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - _lastQTime < Q_DEBOUNCE_MS) return;
|
||||||
|
_lastQTime = now;
|
||||||
|
|
||||||
console.log('%c[HV] Q pressed — checking action...', 'color:#888');
|
console.log('%c[HV] Q pressed — checking action...', 'color:#888');
|
||||||
parseBattleState();
|
parseBattleState();
|
||||||
// Debug: show active buffs and channeling status
|
// Debug: show active buffs and channeling status
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue