Skip to content

Commit dc08684

Browse files
Merge pull request #22 from PanoramicPanda/bugfix/#21
Bugfix/#21
2 parents 3af6f3e + 8825e07 commit dc08684

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

fullscreen_log.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async function onStateChangeEvent(msg) {
4141
// Find the game log button and add an event listener that waits for it to be clicked
4242
for (var i = 0; i < button_arr_len; i++) {
4343
var element = button_arr[i];
44-
if (element.className == "gamelog-button") {
44+
if (element.className.includes("gamelog-button")) {
4545
element.addEventListener("mousedown", destroy_page);
4646
noisey_logs ? console.log("D&D Beyond Game Log Observer Symbiote: Game Log button event listener added") : null;
4747
break;
@@ -68,7 +68,7 @@ async function onStateChangeEvent(msg) {
6868
// Must add delay or you crash. Ask me how I know
6969
await new Promise(resolve => setTimeout(resolve, 1));
7070
getLog = document.querySelector('ol');
71-
if ((getLog != null) && (getLog.className === "GameLog_GameLogEntries__3oNPD")) {
71+
if ((getLog != null) && (getLog.className.includes("GameLogEntries"))) {
7272
noisey_logs ? console.log("D&D Beyond Game Log Observer Symbiote: Log loaded") : null;
7373
isLogLoaded = true;
7474
};

index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
</head>
6464
<body>
6565
<div id="textDiv">
66-
<sub>v1.0.9</sub>
66+
<sub>v1.0.10</sub>
6767
<h1>Utilizing the Symbiote</h1>
6868
After logging in and navigating to the My Campaigns page, you'll need to go to the campaign in question and open up the Game Log.
6969
<br/>
@@ -96,6 +96,7 @@ <h3>I keep getting stuck with the "Are you human?" prompt!</h3>
9696
<details>
9797
<summary>Changelog</summary>
9898
<ul>
99+
<li><b>v1.0.10</b> - Fixed the CSS classes the observer and fullscreen log were looking for</li>
99100
<li><b>v1.0.9</b> - Added the new support for popup logins, such as Google</li>
100101
<li><b>v1.0.8</b> - Added banner to signal when observer is working</li>
101102
<li><b>v1.0.7</b> - Added Changelog and Redid Landing Page/Readme</li>

observeGameLog.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function observeGameLog() {
99
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
1010
const addedLi = mutation.addedNodes[0];
1111
if (addedLi.tagName === 'LI') {
12-
const diceMessageElement = addedLi.querySelector('[class*="DiceMessage_Pending"]');
12+
const diceMessageElement = addedLi.querySelector('[class*="-Pending-ref"]');
1313
if (!diceMessageElement) {
1414
const roll = extractDataFromLi(addedLi);
1515
const rollTarget = roll.rollTarget.toLowerCase();
@@ -25,8 +25,8 @@ function observeGameLog() {
2525
if (diceRoll.includes('kh1') || diceRoll.includes('kl1')) { // Check if diceRoll is using Adv or DisAdv
2626
const numbersInParentheses = diceResultExpression.match(/\((\d+),\s*(\d+)\)/);
2727
if (numbersInParentheses) { //Get both numbers
28-
firstNumber = parseInt(numbersInParentheses[1],10);
29-
secondNumber = parseInt(numbersInParentheses[2],10);
28+
firstNumber = parseInt(numbersInParentheses[1], 10);
29+
secondNumber = parseInt(numbersInParentheses[2], 10);
3030

3131
if (diceRoll.includes('kh1')) { //determine which to keep
3232
selectedNumber = Math.max(firstNumber, secondNumber);
@@ -35,7 +35,7 @@ function observeGameLog() {
3535
}
3636
}
3737

38-
}else{
38+
} else {
3939
let firstNumberString = diceResultExpression.split(' ')[0]; // Split the string by space and take the first element
4040
selectedNumber = parseInt(firstNumberString, 10); // Convert the string to a number
4141
}
@@ -58,12 +58,12 @@ function observeGameLog() {
5858
});
5959
});
6060

61-
const gameLogElement = document.querySelector('[class*="GameLog_GameLogEntries"]');
61+
const gameLogElement = document.querySelector('[class*="GameLogEntries"]');
6262
if (gameLogElement) {
6363
gameLogObserver.observe(gameLogElement, {childList: true});
6464
isObservingGameLog = true;
6565
} else {
66-
console.error('GameLog_GameLogEntries not found');
66+
console.error('GameLogEntries not found');
6767
}
6868
}
6969

@@ -75,7 +75,7 @@ function stopObservingGameLog() {
7575
}
7676

7777
function checkAndObserveGameLog() {
78-
const gameLogElement = document.querySelector('[class*="GameLog_GameLogEntries"]');
78+
const gameLogElement = document.querySelector('[class*="GameLogEntries"]');
7979
if (gameLogElement) {
8080
observeGameLog();
8181
} else {
@@ -89,31 +89,31 @@ function capitalizeWords(str) {
8989

9090
function extractDataFromLi(liElement) {
9191
// Dice Roll
92-
const diceRollElement = liElement.querySelector('[class*="DiceMessage_Notation"] span');
92+
const diceRollElement = liElement.querySelector('[class*="Line-Notation"] span');
9393
const diceRoll = diceRollElement ? diceRollElement.textContent : '';
9494

9595
// Dice Result Math
96-
const diceResultMathElement = liElement.querySelector('[class*="DiceMessage_Number"]');
96+
const diceResultMathElement = liElement.querySelector('[class*="Line-Breakdown"] span');
9797
const diceResultMath = diceResultMathElement ? diceResultMathElement.textContent : '';
9898

9999
// Dice Result Total
100-
const diceResultTotalElement = liElement.querySelector('[class*="DiceMessage_Total_"] span');
100+
const diceResultTotalElement = liElement.querySelector('[class*="TotalContainer"] span');
101101
const diceResultTotal = diceResultTotalElement ? diceResultTotalElement.textContent : '';
102102

103103
// Character
104-
const characterElement = liElement.querySelector('[class*="GameLogEntry_Sender"]');
104+
const characterElement = liElement.querySelector('[class*="-Sender"]');
105105
const character = characterElement ? characterElement.textContent : '';
106106

107107
// Roll Action
108-
const rollActionElement = liElement.querySelector('[class*="DiceMessage_Action"]');
108+
const rollActionElement = liElement.querySelector('[class*="-Action"]');
109109
const rollAction = rollActionElement ? rollActionElement.textContent : '';
110110

111111
// Roll Type
112-
const rollTypeElement = liElement.querySelector('[class*="DiceMessage_RollType"]');
112+
const rollTypeElement = liElement.querySelector('[class*="-RollType"]');
113113
const rollType = rollTypeElement ? capitalizeWords(rollTypeElement.textContent) : '';
114114

115115
// Roll Target
116-
const rollTargetElement = liElement.querySelector('[class*="DiceMessage_Target"]');
116+
const rollTargetElement = liElement.querySelector('[class*="-Target-ref"]');
117117
const rollTarget = rollTargetElement ? capitalizeWords(rollTargetElement.textContent) : '';
118118

119119
return {

0 commit comments

Comments
 (0)