From 7b9332bac9ed479958608f9781c24aac07400812 Mon Sep 17 00:00:00 2001 From: Azmoria <65363489+Azmoria@users.noreply.github.com> Date: Sun, 16 Feb 2025 11:35:45 -0500 Subject: [PATCH] Fix - grab spell tooltip data from monster page since it's incorrect in encounter tool/MAPS --- EncounterHandler.js | 2 ++ MonsterStatBlock.js | 26 +++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/EncounterHandler.js b/EncounterHandler.js index fa9932d0c..d60de0082 100644 --- a/EncounterHandler.js +++ b/EncounterHandler.js @@ -106,6 +106,8 @@ async function fetch_monsters(monsterIds, callback, open5e=false) { monsterData[i].treasure = treasure; monsterData[i].gear = gear; } + let spellTooltips = $(moreInfo)?.find('[class*="mon-stat-block-2024"] .spell-tooltip') + monsterData[i].spellTooltips = spellTooltips; resolve(); })) diff --git a/MonsterStatBlock.js b/MonsterStatBlock.js index ef47496c0..9fad42772 100644 --- a/MonsterStatBlock.js +++ b/MonsterStatBlock.js @@ -182,9 +182,9 @@ function build_monster_stat_block(statBlock, token) { if (!statBlock.userHasAccess) { return `
You do not have access to this content on DndBeyond.
`; } - + let statblockData = ''; if(get_avtt_setting_value('statBlockStyle') == 0 && statBlock.data.initiativeMod != undefined || get_avtt_setting_value('statBlockStyle') == 2){ - return ` + statblockData = `
@@ -478,7 +478,7 @@ function build_monster_stat_block(statBlock, token) { ` } else{ - return ` + statblockData = `
@@ -768,15 +768,20 @@ function build_monster_stat_block(statBlock, token) {
`; } - - + let $stat = $(statblockData); //spell tooltip data is incorrect in 2024 monsters - grab from monster page until fixed in monster api for encounter tool/MAPS + $stat.find('.spell-tooltip').each((index, tooltip) =>{ + $(tooltip).attr('data-tooltip-href', $(statBlock.data.spellTooltips[index]).attr('data-tooltip-href')) + $(tooltip).attr('href', $(statBlock.data.spellTooltips[index]).attr('href')) + }) + return $stat[0].outerHTML; } function build_monster_copy_stat_block(statBlock) { if (!statBlock.userHasAccess) { return `
You do not have access to this content on DndBeyond.
`; } + let statblockData = ''; if(get_avtt_setting_value('statBlockStyle') == 0 && statBlock.data.initiativeMod != undefined || get_avtt_setting_value('statBlockStyle') == 2){ - return ` + statblockData = `
@@ -1032,7 +1037,7 @@ function build_monster_copy_stat_block(statBlock) { ` } else{ - return ` + statblockData = `
@@ -1286,6 +1291,13 @@ function build_monster_copy_stat_block(statBlock) {
`; } + + let $stat = $(statblockData); //spell tooltip data is incorrect in 2024 monsters - grab from monster page until fixed in monster api for encounter tool/MAPS + $stat.find('.spell-tooltip').each((index, tooltip) =>{ + $(tooltip).attr('data-tooltip-href', $(statBlock.data.spellTooltips[index]).attr('data-tooltip-href')) + $(tooltip).attr('href', $(statBlock.data.spellTooltips[index]).attr('href')) + }) + return $stat[0].outerHTML; } class MonsterStatBlock { constructor(data) {