Skip to content

Commit

Permalink
Enable right-click menu on monster pages
Browse files Browse the repository at this point in the history
  • Loading branch information
haste committed Jan 20, 2025
1 parent b8ec074 commit 0b688a4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Enhancements

* Enabled right-click menu on monster pages.

## 0.17.0 (2024-12-19)

### Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion src/clients/browser/manifest.shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"matches": ["*://*.dndbeyond.com/monsters*"],
"run_at": "document_end",
"js": ["monsters.js"],
"css": ["css/styles.css"]
"css": ["css/styles.css", "css/contextmenu.css"]
}
]
}
7 changes: 6 additions & 1 deletion src/monsters.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { injectContextMenu } from "~/contextmenu";
import { processBlockAbilities, processBlockTidbits } from "~/utils/dndbeyond";
import { namedObserver } from "~/utils/observer";
import { talespireLink } from "~/utils/talespire";
Expand Down Expand Up @@ -44,15 +45,19 @@ export const monsterWatcher = () => {
updateMonsters(document.querySelector(".detail-content"));

// Search list
const callback = (mutationList, observer) => {
const callback = async (mutationList, observer) => {
observer.disconnect();

await injectContextMenu();

for (const mutation of mutationList) {
for (const node of mutation.addedNodes) {
if (node.nodeType === 1 && node.classList.contains("more-info")) {
updateMonsters(node);
}
}
}

observer.observe(document.querySelector("section.primary-content"), {
childList: true,
subtree: true,
Expand Down

0 comments on commit 0b688a4

Please sign in to comment.