diff --git a/web-plugin/index.js b/web-plugin/index.js
index c2a5337..71ec125 100644
--- a/web-plugin/index.js
+++ b/web-plugin/index.js
@@ -742,6 +742,8 @@ const ext = {
sendEventToCD("cd_plugin_onQueuePrompt", prompt);
} else if (message.type === "configure_queue_buttons") {
addQueueButtons(message.data);
+ } else if (message.type === "configure_menu_right_buttons") {
+ addMenuRightButtons(message.data);
} else if (message.type === "get_prompt") {
const prompt = await app.graphToPrompt();
sendEventToCD("cd_plugin_onGetPrompt", prompt);
@@ -2115,3 +2117,41 @@ function addQueueButtons(buttonConfigs = DEFAULT_BUTTONS) {
queueButtonGroup.appendChild(button);
});
}
+
+// Function to add butons to the menu right
+function addMenuRightButtons(buttonConfigs) {
+ const menuRightButtons = document.querySelector('.comfyui-menu-right')
+
+ if (!menuRightButtons) return
+
+ // Remove any existing CD buttons
+ const existingButtons = document.querySelectorAll('.comfyui-menu-right [id^="cd-button-"]')
+ for (const button of existingButtons) {
+ button.remove()
+ }
+
+ if (!menuRightButtons) return
+
+ for (const config of buttonConfigs) {
+ const button = createMenuRightButton(config)
+ menuRightButtons.appendChild(button)
+ }
+}
+
+function createMenuRightButton(config) {
+ const button = document.createElement('button')
+ button.id = `cd-button-${config.id}`
+ button.className = 'p-button p-component p-button-secondary p-button-md'
+ button.innerHTML = `
+
+ ${config.label}
+ `
+ button.onclick = () => {
+ const eventData = typeof config.eventData === 'function' ?
+ config.eventData() :
+ config.eventData || {}
+ sendEventToCD(config.event, eventData)
+ }
+ button.setAttribute('data-pd-tooltip', config.tooltip)
+ return button
+}
\ No newline at end of file