diff --git a/module.json b/module.json
index 5900e46..f0402af 100644
--- a/module.json
+++ b/module.json
@@ -2,7 +2,7 @@
"id": "duality-roller",
"title": "Duality Dice Roller",
"description": "Adds a button next to the chat dice/controls that triggers the /dr command for the Foundryborne Daggerheart system.",
- "version": "0.1.3",
+ "version": "0.1.4",
"compatibility": {
"minimum": "13",
"verified": "13"
@@ -16,5 +16,5 @@
"languages": [],
"url": "https://github.com/cptn-cosmo/DualityDiceRoller",
"manifest": "https://github.com/cptn-cosmo/DualityDiceRoller/releases/latest/download/module.json",
- "download": "https://github.com/cptn-cosmo/DualityDiceRoller/releases/download/0.1.3/duality-roller.zip"
+ "download": "https://github.com/cptn-cosmo/DualityDiceRoller/releases/download/0.1.4/duality-roller.zip"
}
diff --git a/scripts/dr-button.js b/scripts/dr-button.js
index 60ab202..ccd5c22 100644
--- a/scripts/dr-button.js
+++ b/scripts/dr-button.js
@@ -8,66 +8,35 @@ Hooks.once("init", () => {
});
// Sidebar chat
-Hooks.on("renderChatLog", (app, html) => addDRButton(html));
+Hooks.on("renderChatLog", (_app, _html) => addDRButton());
// Mini/Popout chat
-Hooks.on("renderChatPopout", (app, html) => addDRButton(html));
+Hooks.on("renderChatPopout", (_app, _html) => addDRButton());
-function addDRButton(html) {
+function addDRButton() {
try {
- // Avoid duplicates
- if (html.querySelector(".dr-quick-button")) return;
-
- const container =
- html.querySelector(".dice-tray") ||
- html.querySelector(".chat-controls .control-buttons") ||
- html.querySelector(".chat-controls") ||
- html;
+ const container = document.createElement("div");
+ container.className = "dr-quick-button-container";
// Build button
const btn = document.createElement("button");
btn.type = "button";
- btn.className = "dr-quick-button";
+ btn.className = "ui-control icon fas-solid dr-quick-button";
btn.title = "Duality Dice Roll";
btn.setAttribute("aria-label", "Duality Dice Roll");
// Inline SVG (or use icon.src = "modules/dr-quick-button/icons/dr.svg"; if external)
- btn.innerHTML = `
-
+ btn.innerHTML = `
`;
-
btn.addEventListener("click", async () => {
await runDRCommand();
});
- // Append the button at the end of the roll-privacy div
- const rollPrivacyDiv = container.querySelector("#roll-privacy");
- if (rollPrivacyDiv) {
- rollPrivacyDiv.appendChild(btn);
- } else {
- container.appendChild(btn); // fallback if the div doesn't exist
- }
+ container.appendChild(btn);
+
+ // Find all roll-privacy divs and append the button
+ const rollPrivacyDivs = document.querySelectorAll("#roll-privacy");
+ rollPrivacyDivs.forEach(div => div.appendChild(container));
} catch (err) {
console.error("DR Quick Button | addDRButton error:", err);
@@ -75,37 +44,14 @@ function addDRButton(html) {
}
+
/** Run `/dr` as if typed into chat */
async function runDRCommand() {
- const cmd = "/dr";
-
try {
- if (ui?.chat?.processMessage) return await ui.chat.processMessage(cmd);
- } catch (e) {
- console.warn("DR Quick Button | ui.chat.processMessage failed:", e);
+ await ui?.chat?.processMessage("/dr");
+ } catch (err) {
+ console.error("DR Quick Button | Failed to send /dr command:", err);
+ ui.notifications?.warn("Couldn't run /dr automatically. Try typing /dr in chat.");
}
-
- try {
- if (globalThis.ChatLog?.instance?.processMessage) {
- return await globalThis.ChatLog.instance.processMessage(cmd);
- }
- } catch (e) {
- console.warn("DR Quick Button | ChatLog.instance.processMessage failed:", e);
- }
-
- try {
- const form = ui.chat?.element?.querySelector?.("form#chat-form");
- const textarea = form?.querySelector?.("textarea[name='message']");
- if (form && textarea) {
- const prev = textarea.value;
- textarea.value = cmd;
- form.dispatchEvent(new Event("submit", { bubbles: true, cancelable: true }));
- setTimeout(() => (textarea.value = prev ?? ""), 0);
- return;
- }
- } catch (e) {
- console.warn("DR Quick Button | Fallback submit failed:", e);
- }
-
- ui.notifications?.warn?.("Couldn't run /dr automatically. Try typing /dr in chat.");
}
+
diff --git a/styles/dr-button.css b/styles/dr-button.css
index dabe6d5..885c42d 100644
--- a/styles/dr-button.css
+++ b/styles/dr-button.css
@@ -3,22 +3,13 @@
display: inline-flex;
align-items: center;
justify-content: center;
- width: 28px;
- height: 28px;
- margin-left: 4px;
- border: 1px solid var(--color-border-light-2, #8882);
- border-radius: 4px;
- background: var(--color-bg, #222e);
- cursor: pointer;
- padding: 1;
+ padding: 7px;
}
-.dr-quick-button:hover {
- filter: brightness(1.15);
+.dr-quick-button-container {
+ margin: 0px 10px;
}
-.dr-quick-button img {
- width: 18px;
- height: 18px;
- pointer-events: none;
-}
+.vertical .dr-quick-button-container {
+ margin: 10px 0px;
+}
\ No newline at end of file