From 1b8e9e00a6c97619213647e4883aea4887dd0f07 Mon Sep 17 00:00:00 2001 From: CPTN Cosmo Date: Tue, 10 Feb 2026 22:43:11 +0100 Subject: [PATCH] new version & migrate from github --- module.json | 4 ++-- scripts/dr-button.js | 45 +++++++++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/module.json b/module.json index 51f9790..fc17512 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "id": "duality-roller", "title": "Daggerheart 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.5", + "version": "0.1.6", "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.5/duality-roller.zip" + "download": "https://github.com/cptn-cosmo/DualityDiceRoller/releases/download/0.1.6/duality-roller.zip" } diff --git a/scripts/dr-button.js b/scripts/dr-button.js index ccd5c22..099b14a 100644 --- a/scripts/dr-button.js +++ b/scripts/dr-button.js @@ -15,28 +15,31 @@ Hooks.on("renderChatPopout", (_app, _html) => addDRButton()); function addDRButton() { try { - const container = document.createElement("div"); - container.className = "dr-quick-button-container"; - - // Build button - const btn = document.createElement("button"); - btn.type = "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 = `DR - `; - btn.addEventListener("click", async () => { - await runDRCommand(); - }); - - container.appendChild(btn); - - // Find all roll-privacy divs and append the button + // Find all roll-privacy divs and append one button per container, avoiding duplicates const rollPrivacyDivs = document.querySelectorAll("#roll-privacy"); - rollPrivacyDivs.forEach(div => div.appendChild(container)); + rollPrivacyDivs.forEach(div => { + // If this container already has our button, skip adding another + if (div.querySelector(".dr-quick-button-container")) return; + + const container = document.createElement("div"); + container.className = "dr-quick-button-container"; + + // Build button + const btn = document.createElement("button"); + btn.type = "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 = `DR`; + btn.addEventListener("click", async () => { + await runDRCommand(); + }); + + container.appendChild(btn); + div.appendChild(container); + }); } catch (err) { console.error("DR Quick Button | addDRButton error:", err);