Files
2026-01-05 13:06:01 -08:00

35 lines
1.4 KiB
JavaScript

import { app } from "../../scripts/app.js";
app.registerExtension({
name: "RandomWildcardLoader",
async nodeCreated(node) {
if (node.comfyClass === "RandomWildcardLoader" || node.comfyClass === "RandomWildcardLoaderAdvanced") {
// Store original onExecuted if exists
const originalOnExecuted = node.onExecuted;
node.onExecuted = function(message) {
// Call original if exists
if (originalOnExecuted) {
originalOnExecuted.apply(this, arguments);
}
// Update widgets with returned values
if (message) {
if (message.loaded_wildcards && message.loaded_wildcards[0] !== undefined) {
const widget = this.widgets.find(w => w.name === "loaded_wildcards");
if (widget) {
widget.value = message.loaded_wildcards[0];
}
}
if (message.loaded_contents && message.loaded_contents[0] !== undefined) {
const widget = this.widgets.find(w => w.name === "loaded_contents");
if (widget) {
widget.value = message.loaded_contents[0];
}
}
}
};
}
}
});