v0.14.15 - Retry gear scrape until dynjs_equip store loads
- equip-UID.js loads asynchonously after document-end, so dynjs_equip might not exist when init() first runs - Now retries up to 10 times (500ms apart, 5 seconds total) waiting for the store to populate before scraping - Added HV.gearStore() to check whether the store is loaded - If store never loads, falls back to name/ID scrape without stats
This commit is contained in:
parent
329e9403b4
commit
d95409026f
6 changed files with 57 additions and 9 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// ==UserScript==
|
||||
// @name HV Unified
|
||||
// @namespace hvunified
|
||||
// @version 0.14.14
|
||||
// @version 0.14.15
|
||||
// @description HV Unified — battle automation, guidance, and UI enhancements for HentaiVerse
|
||||
// @author GaboGG + Hermes
|
||||
// @match *://*.hentaiverse.org/*
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
// CONFIG — default settings
|
||||
// ═══════════════════════════════════════════════════════════════════════
|
||||
|
||||
const VERSION = '0.14.14';
|
||||
const VERSION = '0.14.15';
|
||||
|
||||
const CFG = {
|
||||
// — Battle automation
|
||||
|
|
@ -3805,6 +3805,7 @@ window.HV = {
|
|||
gearSummary: () => logGearSummary(),
|
||||
scrapeGear: () => autoScrapeGear(),
|
||||
gearDebug: () => debugScrapeGear(),
|
||||
gearStore: () => { const s = getHVEquipStore(); return s ? `Loaded: ${Object.keys(s).length} items` : 'Not loaded yet'; },
|
||||
};
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════
|
||||
|
|
@ -3912,9 +3913,24 @@ function initializeBattle() {
|
|||
}
|
||||
|
||||
// Auto-scrape gear data on character/armory pages (reads from HV's in-memory store)
|
||||
// Wait for dynjs_equip to load (external script, may load after document-end)
|
||||
const url = window.location.href || '';
|
||||
if (url.includes('ss=eq') || url.includes('ss=ch') || url.includes('ss=am')) {
|
||||
setTimeout(autoScrapeGear, 300);
|
||||
let attempts = 0;
|
||||
const tryScrape = () => {
|
||||
const store = getHVEquipStore();
|
||||
if (store && Object.keys(store).length > 0) {
|
||||
autoScrapeGear();
|
||||
return;
|
||||
}
|
||||
if (++attempts < 10) {
|
||||
setTimeout(tryScrape, 500); // retry every 500ms up to 5 seconds
|
||||
} else {
|
||||
// Fallback: scrape names/IDs without stats
|
||||
autoScrapeGear();
|
||||
}
|
||||
};
|
||||
setTimeout(tryScrape, 300);
|
||||
}
|
||||
|
||||
STATE.battleInitialized = true;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// ==UserScript==
|
||||
// @name HV Unified
|
||||
// @namespace hvunified
|
||||
// @version 0.14.14
|
||||
// @version 0.14.15
|
||||
// @description HV Unified — battle automation, guidance, and UI enhancements for HentaiVerse
|
||||
// @author GaboGG + Hermes
|
||||
// @match *://*.hentaiverse.org/*
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
// CONFIG — default settings
|
||||
// ═══════════════════════════════════════════════════════════════════════
|
||||
|
||||
const VERSION = '0.14.14';
|
||||
const VERSION = '0.14.15';
|
||||
|
||||
const CFG = {
|
||||
// — Battle automation
|
||||
|
|
@ -3805,6 +3805,7 @@ window.HV = {
|
|||
gearSummary: () => logGearSummary(),
|
||||
scrapeGear: () => autoScrapeGear(),
|
||||
gearDebug: () => debugScrapeGear(),
|
||||
gearStore: () => { const s = getHVEquipStore(); return s ? `Loaded: ${Object.keys(s).length} items` : 'Not loaded yet'; },
|
||||
};
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════
|
||||
|
|
@ -3912,9 +3913,24 @@ function initializeBattle() {
|
|||
}
|
||||
|
||||
// Auto-scrape gear data on character/armory pages (reads from HV's in-memory store)
|
||||
// Wait for dynjs_equip to load (external script, may load after document-end)
|
||||
const url = window.location.href || '';
|
||||
if (url.includes('ss=eq') || url.includes('ss=ch') || url.includes('ss=am')) {
|
||||
setTimeout(autoScrapeGear, 300);
|
||||
let attempts = 0;
|
||||
const tryScrape = () => {
|
||||
const store = getHVEquipStore();
|
||||
if (store && Object.keys(store).length > 0) {
|
||||
autoScrapeGear();
|
||||
return;
|
||||
}
|
||||
if (++attempts < 10) {
|
||||
setTimeout(tryScrape, 500); // retry every 500ms up to 5 seconds
|
||||
} else {
|
||||
// Fallback: scrape names/IDs without stats
|
||||
autoScrapeGear();
|
||||
}
|
||||
};
|
||||
setTimeout(tryScrape, 300);
|
||||
}
|
||||
|
||||
STATE.battleInitialized = true;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// CONFIG — default settings
|
||||
// ═══════════════════════════════════════════════════════════════════════
|
||||
|
||||
const VERSION = '0.14.14';
|
||||
const VERSION = '0.14.15';
|
||||
|
||||
const CFG = {
|
||||
// — Battle automation
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// ==UserScript==
|
||||
// @name HV Unified
|
||||
// @namespace hvunified
|
||||
// @version 0.14.14
|
||||
// @version 0.14.15
|
||||
// @description HV Unified — battle automation, guidance, and UI enhancements for HentaiVerse
|
||||
// @author GaboGG + Hermes
|
||||
// @match *://*.hentaiverse.org/*
|
||||
|
|
|
|||
17
src/init.js
17
src/init.js
|
|
@ -103,9 +103,24 @@ function initializeBattle() {
|
|||
}
|
||||
|
||||
// Auto-scrape gear data on character/armory pages (reads from HV's in-memory store)
|
||||
// Wait for dynjs_equip to load (external script, may load after document-end)
|
||||
const url = window.location.href || '';
|
||||
if (url.includes('ss=eq') || url.includes('ss=ch') || url.includes('ss=am')) {
|
||||
setTimeout(autoScrapeGear, 300);
|
||||
let attempts = 0;
|
||||
const tryScrape = () => {
|
||||
const store = getHVEquipStore();
|
||||
if (store && Object.keys(store).length > 0) {
|
||||
autoScrapeGear();
|
||||
return;
|
||||
}
|
||||
if (++attempts < 10) {
|
||||
setTimeout(tryScrape, 500); // retry every 500ms up to 5 seconds
|
||||
} else {
|
||||
// Fallback: scrape names/IDs without stats
|
||||
autoScrapeGear();
|
||||
}
|
||||
};
|
||||
setTimeout(tryScrape, 300);
|
||||
}
|
||||
|
||||
STATE.battleInitialized = true;
|
||||
|
|
|
|||
|
|
@ -25,4 +25,5 @@ window.HV = {
|
|||
gearSummary: () => logGearSummary(),
|
||||
scrapeGear: () => autoScrapeGear(),
|
||||
gearDebug: () => debugScrapeGear(),
|
||||
gearStore: () => { const s = getHVEquipStore(); return s ? `Loaded: ${Object.keys(s).length} items` : 'Not loaded yet'; },
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue