kakaroto / Beyond20

D&D Beyond Character Sheet Integration in Roll20
GNU General Public License v3.0
489 stars 144 forks source link

Classes page handler should limit its roll button check to the contents and ignore comments section #1091

Open jdelder opened 10 months ago

jdelder commented 10 months ago

Describe the bug When accessing the web page: https://www.dndbeyond.com/classes/rogue The web page will repeatedly refresh preventing proper access to the content. This occurs for Beyond 20 2.9.1 on either Chrome or Firefox. Uninstalling the extension stops the issue and the web page can be viewed normally.

This has been reported by others on the D&D Beyond forums. Oct 30, 2023: https://www.dndbeyond.com/forums/d-d-beyond-general/bugs-support/183887-rogue-class-page-constantly-reloading Similar problem in much older thread: https://www.dndbeyond.com/forums/d-d-beyond-general/bugs-support/127633-wizard-page-constantly-refreshing

Following comments in the previous thread: "Aha. The most recent comment on the Wizard page has Alertify tags in it. Beyond20 uses Alertify for interactive things. The commenter must've been using Beyond20, and since you (I assume) also use Beyond20, it's interacting with it, causing the page refreshing."

Looking at the page source for comment #1096 on the Rogue page posted on Oct 29, 2023. It does appear to contain Beyond20 code but not an Alertify tag.

Sneak Attack

--   |

Beginning at 1st level, you know how to strike subtly and exploit a foe’s distraction. Once per turn, you can deal an extra 1d6 damage to one creature you hit with an attack if you have advantage on the attack roll. The attack must use a finesse or a ranged weapon.

  |

You don’t need advantage on the attack roll if another enemy of the target is within 5 feet of it, that enemy isn’t incapacitated, and you don’t have disadvantage on the attack roll."

And from the section on "Unseen Attackers and Targets", PHB p.194

  |

Combatants often try to escape their foes’ notice by hiding, casting the invisibility spell, or lurking in darkness.

  |

When you attack a target that you can’t see, you have disadvantage on the attack roll. This is true whether you’re guessing the target’s location or you’re targeting a creature you can hear but not see. If the target isn’t in the location you targeted, you automatically miss, but the DM typically just says that the attack missed, not whether you guessed the target’s location correctly. When a creature can’t see you, you have advantage on attack rolls against it.

  |

If you are hidden—both unseen and unheard—when you make an attack, you give away your location when the attack hits or misses.

  |  

The code posted in the comment contains Beyond20 code: Removing the mark up: u class="ct-beyond20-custom-roll" strong 1d6 /strong img class="ct-beyond20-custom-icon" src="" alt="" /u

Producing the following: 1d6

Considering that this problem did not develop until recently, it seems likely that the Beyond20 code in the comment may be causing the problem with Beyond20 reloading the page

This also appears to be possibly related to the following issue that was reported as closed though the code doesn't look to be the same. https://github.com/kakaroto/Beyond20/issues/889

To Reproduce Steps to reproduce the behavior:

  1. Go to https://www.dndbeyond.com/classes/rogue
  2. See error (web page constantly refreshes)

Expected behavior Web page should load once instead of constantly reloading. (The reload button on the browser keeps flashing).

Screenshots To help explain your problem, add screenshots of where you clicked in D&D Beyond, a screenshot of your Beyond20 character settings if applicable and the result you saw in the VTT.

Browser Info (please complete the following information):

Additional context Add any other context about the problem here, such as a link to the character sheet or D&D Beyond page that shows the problem.

kakaroto commented 10 months ago

Thanks. I can confirm the issue was happening 4 days ago when you reported it, but it's not happening anymore. What happened is that the page had a user's comment which included probably some copy/pasted html code from the page which included Beyond20 roll buttons. The extension sees them and thinks it was reloaded on a page that already got injected roll buttons into it, so it refreshes the page to clear them and re-add the buttons on a fresh page, only to find the buttons again (because they're in the comments section).

My guess is that it was this comment, and we can see it got edited by a moderator 2 days ago: image

I'm leaving this issue open because the extension needs to be smarter and exclude the comments section like we've done in other pages.

jdelder commented 10 months ago

Yes. I reported that comment since the issue was Beyond20 roll markup around the d6. The moderator removed it so the page worked again with the plugin still installed. Thanks for updating the bug name and it would be great if the issue can be addressed so it doesn't come up again :)