Files
Bjornulf_custom_nodes/web/js/API_civitai.js
justumen 50ee5779c0 0.62
2024-12-17 14:38:57 +01:00

29 lines
1.1 KiB
JavaScript

import { app } from "../../../scripts/app.js";
app.registerExtension({
name: "Bjornulf.CivitAIModelSelector",
async nodeCreated(node) {
if (node.comfyClass === "Bjornulf_CivitAIModelSelector") {
// Find all upload widgets
const uploadWidgets = node.widgets.filter(w => w.type === "file");
uploadWidgets.forEach(widget => {
// Store the original draw function
const originalDraw = widget.draw;
// Override the draw function
widget.draw = function(ctx, node, width, pos, height) {
const result = originalDraw.call(this, ctx, node, width, pos, height);
// Hide all file inputs for this widget
const fileInputs = document.querySelectorAll(`input[type="file"][data-widget="${this.name}"]`);
fileInputs.forEach(input => {
input.style.display = 'none';
});
return result;
};
});
}
}
});