cynicaloptimist / send-to-improved-initiative

A cross browser extension that imports D&D Beyond StatBlocks into Improved Initiative
MIT License
5 stars 7 forks source link

Monster statblock with Beyond20 installed strips dice formulae #20

Open xathien opened 4 years ago

xathien commented 4 years ago

When the Beyond20 extension is installed, the JSON importer can no longer parse dice formulae, since the extension injects some extra HTML:

<p>
  <div class="ct-beyond20-roll" id="de23c2df-d104-4590-a83e-760d4ec5d580" style="display: block;"><button class="ct-beyond20-roll-button ct-theme-button ct-theme-button--filled ct-theme-button--interactive ct-button character-button character-button-small"><img class="ct-beyond20-icon" src="chrome-extension://gnblbpbepfbfmoobegdogkglpbhcjofh/images/dice16.png" style="margin-right: 6px;"><span class="ct-button__content">Royal Spear</span></button></div>
  <em><strong>Royal Spear.</strong> Melee or Ranged Weapon Attack:</em>
  <u class="ct-beyond20-custom-roll"><strong>+5</strong><img class="ct-beyond20-custom-icon" x-beyond20-name="Royal Spear" x-beyond20-roll="1d20+5" src="chrome-extension://gnblbpbepfbfmoobegdogkglpbhcjofh/images/icons/icon16.png" style="margin-right: 3px; margin-left: 3px;"></u> to hit, reach 10 ft. or range 20/60 ft., one target. <em>Hit:</em> 10 (<u class="ct-beyond20-custom-roll"><strong>2d6 + 3</strong><img class="ct-beyond20-custom-icon" x-beyond20-name="Royal Spear" x-beyond20-roll="2d6 + 3" src="chrome-extension://gnblbpbepfbfmoobegdogkglpbhcjofh/images/icons/icon16.png" style="margin-right: 3px; margin-left: 3px;"></u>) piercing damage, or 12 (<u class="ct-beyond20-custom-roll"><strong>2d8 + 3</strong><img class="ct-beyond20-custom-icon" x-beyond20-name="Royal Spear" x-beyond20-roll="2d8 + 3" src="chrome-extension://gnblbpbepfbfmoobegdogkglpbhcjofh/images/icons/icon16.png" style="margin-right: 3px; margin-left: 3px;"></u>) piercing damage if used with two hands to make a melee attack. If the target is a Medium or smaller creature, it must succeed on a DC 13 Strength saving throw or be knocked <a class="tooltip-hover condition-tooltip" href="/compendium/rules/basic-rules/appendix-a-conditions#Prone" data-tooltip-href="//www.dndbeyond.com/conditions/12-tooltip?disable-webm=1&amp;disable-webm=1">prone</a>.
</p>

This results in a JSON string like:

"Hit: 10 () piercing damage, or 12 () piercing damage if used with two hands"

A bit of tweaking on whatever is scraping the HTML might be able to overcome the extra injected HTML for this rather common exception.

xathien commented 4 years ago

Fixed in #22