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
|
// Sidebar chat
|
||||||
Hooks.on("renderChatLog", (app, html) => addDRButton(html));
|
Hooks.on("renderChatLog", (_app, _html) => addDRButton());
|
||||||
|
|
||||||
// Mini/Popout chat
|
// Mini/Popout chat
|
||||||
Hooks.on("renderChatPopout", (app, html) => addDRButton(html));
|
Hooks.on("renderChatPopout", (_app, _html) => addDRButton());
|
||||||
|
|
||||||
function addDRButton() {
|
function addDRButton() {
|
||||||
try {
|
try {
|
||||||
// Avoid duplicates
|
const container = document.createElement("div");
|
||||||
//if (document.querySelector(".dr-quick-button")) return;
|
container.className = "dr-quick-button-container";
|
||||||
|
|
||||||
// Build button
|
// Build button
|
||||||
const btn = document.createElement("button");
|
const btn = document.createElement("button");
|
||||||
|
|
@ -51,13 +51,14 @@ function addDRButton() {
|
||||||
</svg>
|
</svg>
|
||||||
`;
|
`;
|
||||||
btn.addEventListener("click", async () => {
|
btn.addEventListener("click", async () => {
|
||||||
console.log("clicked the button");
|
|
||||||
await runDRCommand();
|
await runDRCommand();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
container.appendChild(btn);
|
||||||
|
|
||||||
// Find all roll-privacy divs and append the button
|
// Find all roll-privacy divs and append the button
|
||||||
const rollPrivacyDivs = document.querySelectorAll("#roll-privacy");
|
const rollPrivacyDivs = document.querySelectorAll("#roll-privacy");
|
||||||
rollPrivacyDivs.forEach(div => div.appendChild(btn.cloneNode(true)));
|
rollPrivacyDivs.forEach(div => div.appendChild(container));
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("DR Quick Button | addDRButton error:", err);
|
console.error("DR Quick Button | addDRButton error:", err);
|
||||||
|
|
@ -69,7 +70,7 @@ function addDRButton() {
|
||||||
/** Run `/dr` as if typed into chat */
|
/** Run `/dr` as if typed into chat */
|
||||||
async function runDRCommand() {
|
async function runDRCommand() {
|
||||||
try {
|
try {
|
||||||
await ChatMessage.create({ content: "/dr" });
|
await ui?.chat?.processMessage("/dr");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("DR Quick Button | Failed to send /dr command:", 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.");
|
ui.notifications?.warn("Couldn't run /dr automatically. Try typing /dr in chat.");
|
||||||
|
|
|
||||||
|
|
@ -3,22 +3,13 @@
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 28px;
|
padding: 7px;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dr-quick-button:hover {
|
.dr-quick-button-container {
|
||||||
filter: brightness(1.15);
|
margin: 0px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dr-quick-button img {
|
.vertical .dr-quick-button-container {
|
||||||
width: 18px;
|
margin: 10px 0px;
|
||||||
height: 18px;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue