Please check out my YouTube video Create a library of your downloaded icons with Excalidraw Automate in Obsidian, it provides a detailed walkthrough of this code.
To save these files into your Vault, either download them, or switch to RAW mode to copy/paste them into your Obsidian Vault. You may need to use CTRL+SHIFT+V to paste.
Icons created by the script are locked in the scene, you can right click them to select and copy them. Locking the eleemnts avoids the need for switching to view mode and ensures the file does not get accidently modified, thus the images in the image library are not actually saved to the image library causing unwanted links in your Vault.
I use the script with LOCK_ICONS=true; because in this case I won't accidently move items in the image library causing it to save the icons in the file and creating unwanted links in Excalibrain pointing back to the icon library. If you lock icons then you need to right click the selected icon to copy it to the clipboard, however, when you paste the icon to your drawing it will be locked - which is not convenient. For this reason I've also configured an onPaste event handler via the Excalidraw startup script. This automatically unlocks all elements on paste.
ea.onPasteHook = (data) => {
if(data?.payload?.elements) {
data.payload.elements.filter(el=>el.locked).forEach(el=>{el.locked = false;});
}
};


so in both cases you see an Excalidraw drawing, but one has 18 images and the other 90?
did you modify the filter at the beginning of the code?
regarding learning Obsidian.js, I think small projects like this one are the best way.
one easy way to debug is to insert
console.log(variable_name);at key points to see the value of variables.another approach is to insert
debugger;command in the code. doing this the script execution will stop when the program gets to that point (but only if developer console is open).