Fix everything
This commit is contained in:
parent
2c73c49b0b
commit
e7138d25fc
2 changed files with 14 additions and 22 deletions
|
|
@ -8,15 +8,15 @@ 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() {
|
||||
try {
|
||||
// Avoid duplicates
|
||||
//if (document.querySelector(".dr-quick-button")) return;
|
||||
const container = document.createElement("div");
|
||||
container.className = "dr-quick-button-container";
|
||||
|
||||
// Build button
|
||||
const btn = document.createElement("button");
|
||||
|
|
@ -51,13 +51,14 @@ function addDRButton() {
|
|||
</svg>
|
||||
`;
|
||||
btn.addEventListener("click", async () => {
|
||||
console.log("clicked the button");
|
||||
await runDRCommand();
|
||||
});
|
||||
|
||||
container.appendChild(btn);
|
||||
|
||||
// Find all roll-privacy divs and append the button
|
||||
const rollPrivacyDivs = document.querySelectorAll("#roll-privacy");
|
||||
rollPrivacyDivs.forEach(div => div.appendChild(btn.cloneNode(true)));
|
||||
rollPrivacyDivs.forEach(div => div.appendChild(container));
|
||||
|
||||
} catch (err) {
|
||||
console.error("DR Quick Button | addDRButton error:", err);
|
||||
|
|
@ -69,7 +70,7 @@ function addDRButton() {
|
|||
/** Run `/dr` as if typed into chat */
|
||||
async function runDRCommand() {
|
||||
try {
|
||||
await ChatMessage.create({ content: "/dr" });
|
||||
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.");
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue