35 lines
1.4 KiB
JavaScript
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];
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
}
|
|
});
|