Skip to content

Commit

Permalink
Merge pull request #1222 from dmportella/dice-formulas-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kakaroto authored Jan 10, 2025
2 parents 47198c9 + 0ca6be9 commit 04856bd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/dndbeyond/content-scripts/character.js
Original file line number Diff line number Diff line change
Expand Up @@ -2281,10 +2281,11 @@ function injectRollToSpellAttack() {

function injectRollToSnippets() {
const groups = $(`.ct-actions .ct-actions-list .ct-actions-list__activatable .ct-feature-snippet,
.ct-features .ct-class-detail .ct-feature-snippet,
.ct-features .ct-race-detail .ct-feature-snippet,
.ct-features .ct-feats-detail .ct-feature-snippet`);

.ct-actions div[class*='styles_activatable'] .ct-feature-snippet,
.ct-features .ct-class-detail .ct-feature-snippet, .ct-features .ct-feature-snippet--class,
.ct-features .ct-race-detail .ct-feature-snippet, .ct-features .ct-feature-snippet--racial-trait,
.ct-features .ct-feats-detail .ct-feature-snippet, .ct-features .ct-feature-snippet--feat`);

for (let group of groups.toArray()) {
const snippet = $(group);

Expand All @@ -2293,8 +2294,9 @@ function injectRollToSnippets() {
// get modified.
if (snippet.find(".ct-beyond20-custom-roll").length > 0)
continue;
const name = snippet.find(".ct-feature-snippet__heading")[0].childNodes[0].textContent.trim();
const content = snippet.find(".ct-feature-snippet__content")

const name = snippet.find(".ct-feature-snippet__heading, div[class*='styles_heading']")[0].childNodes[0].textContent.trim();
const content = snippet.find(".ct-feature-snippet__content, div[class*='styles_content']");
checkAndInjectDiceToRolls(content, name);
// DDB now displays tooltips on the modifiers, so it's not "1d4+3" it's "1d4<span>+3</span>" which causes
// Beyond20 to see it as two separate formulas, a "1d4" and a "+3" which rolls as "1d20 + 3"
Expand Down

0 comments on commit 04856bd

Please sign in to comment.