Fix progress bar context menu title showing raw HTML on newer frontends

Newer ComfyUI frontends render the ContextMenu title via textContent instead of innerHTML (XSS hardening), so the HTML string passed as the progress bar menu title was displayed as raw markup. Pass a plain-text title and swap in the logo markup after the menu is created.
This commit is contained in:
hcwhan
2026-07-17 17:38:56 +08:00
parent 27b4f4cdcf
commit 56a800962d
2 changed files with 15 additions and 4 deletions
+9 -2
View File
@@ -320,11 +320,18 @@ class Rgthree extends EventTarget {
LiteGraph.closeAllContextMenus();
if (e.button == 2) {
const canvas = await waitForCanvas();
new LiteGraph.ContextMenu(this.getRgthreeIContextMenuValues(), {
title: `<div class="rgthree-contextmenu-item rgthree-contextmenu-title-rgthree-comfy">${logoRgthree} rgthree-comfy</div>`,
// Newer ComfyUI frontends render the ContextMenu title with textContent (no HTML
// parsing), which would show an HTML title as raw markup. Pass a plain-text title,
// then swap in our logo markup afterwards.
const menu = new LiteGraph.ContextMenu(this.getRgthreeIContextMenuValues(), {
title: "rgthree-comfy",
left: e.clientX,
top: 5,
});
const titleEl = query<HTMLDivElement>(".litemenu-title", menu.root);
if (titleEl) {
titleEl.innerHTML = `<div class="rgthree-contextmenu-item rgthree-contextmenu-title-rgthree-comfy">${logoRgthree} rgthree-comfy</div>`;
}
return;
}
if (e.button == 0) {
+6 -2
View File
@@ -188,11 +188,15 @@ class Rgthree extends EventTarget {
LiteGraph.closeAllContextMenus();
if (e.button == 2) {
const canvas = await waitForCanvas();
new LiteGraph.ContextMenu(this.getRgthreeIContextMenuValues(), {
title: `<div class="rgthree-contextmenu-item rgthree-contextmenu-title-rgthree-comfy">${logoRgthree} rgthree-comfy</div>`,
const menu = new LiteGraph.ContextMenu(this.getRgthreeIContextMenuValues(), {
title: "rgthree-comfy",
left: e.clientX,
top: 5,
});
const titleEl = query(".litemenu-title", menu.root);
if (titleEl) {
titleEl.innerHTML = `<div class="rgthree-contextmenu-item rgthree-contextmenu-title-rgthree-comfy">${logoRgthree} rgthree-comfy</div>`;
}
return;
}
if (e.button == 0) {