+39
-5
@@ -280,18 +280,52 @@ Hooks.on("updateCombat", async (combat, change, _options, _userId) => {
|
||||
})
|
||||
|
||||
/**
|
||||
* Inject a visual separator between Afflictions and Imbuements in the Token HUD status tray
|
||||
* Inject a visual separator between Afflictions and Imbuements in the Token HUD status tray.
|
||||
* Supports V11 (jQuery html, .palette.status-effects), V12 (.token-hud .status-effects),
|
||||
* and V14+ (ApplicationV2, possible restructured DOM).
|
||||
*/
|
||||
Hooks.on("renderTokenHUD", (_app, html) => {
|
||||
const tray = html.querySelector(".status-effects")
|
||||
if (!tray) return
|
||||
function _injectStatusSeparator(root) {
|
||||
const tray = (
|
||||
root.querySelector(".status-effects")
|
||||
|| root.querySelector(".palette.status-effects")
|
||||
|| root.querySelector("[data-application-part='status-effects']")
|
||||
|| root.querySelector("section.status-effects")
|
||||
|| (root.id === "token-hud" && root.querySelector(".status-effects"))
|
||||
)
|
||||
if (!tray) return false
|
||||
const firstImb = tray.querySelector("[data-status-id^='imb-']")
|
||||
if (!firstImb) return
|
||||
if (!firstImb) return false
|
||||
if (tray.querySelector(".status-separator")) return true
|
||||
const sep = document.createElement("div")
|
||||
sep.className = "status-separator"
|
||||
firstImb.before(sep)
|
||||
return true
|
||||
}
|
||||
|
||||
Hooks.on("renderTokenHUD", (app, html) => {
|
||||
const root = html instanceof jQuery ? html[0] : html
|
||||
console.log("PRISM HUD hook", {id: root?.id, class: root?.className, trayFound: !!root?.querySelector?.(".status-effects")})
|
||||
_injectStatusSeparator(root)
|
||||
})
|
||||
|
||||
// V14 may render effects asynchronously / swap them without re-triggering
|
||||
// renderTokenHUD; use a MutationObserver on #token-hud as safety net
|
||||
{
|
||||
let observed = false
|
||||
const obs = new MutationObserver((mutations, self) => {
|
||||
const hud = document.getElementById("token-hud")
|
||||
if (!hud) return
|
||||
if (!observed) {
|
||||
observed = true
|
||||
// once the HUD exists, watch its subtree for dynamic effect swaps
|
||||
const inner = new MutationObserver(() => _injectStatusSeparator(hud))
|
||||
inner.observe(hud, { childList: true, subtree: true })
|
||||
_injectStatusSeparator(hud)
|
||||
}
|
||||
})
|
||||
obs.observe(document.body, { childList: true, subtree: true })
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a macro when dropping an entity on the hotbar
|
||||
* Item - open roll dialog
|
||||
|
||||
Reference in New Issue
Block a user