This one works for what you wanted?
https://perchance.org/u5w7waum4s
If so, allo was on the money, this is was done by placing the following in the script side of the HTML:
- An array containing objects which hold the name of the enemy and the reference image (lines 12 to 101).
- A function to fetch the image web link using the name as an input (lines 103 to 106).
- A function to render the image from a string (lines 108 to 114).
- A function in the form of a promise to execute the Perchance randomizer and change the displayed text (lines 121 to 128).
- A function to extract the text from the HTML to pass it as an input later to the image rendering function (lines 130 to 133).
- And a chain function with timeouts to run first the randomizer and then the image generation after pressing the button (lines 135 to 147).
The reason for this spaghetti code, is mainly due to me not knowing the fine tricks of the custom Perchance notation, so the solution here is just treat this as a table matching exercise, where you have a "dictionary" where you can relate what the randomizer gives you to a link. Keep in mind that for this to work, in the Perchance code side of things there are only the enemies that have a link in the dictionary. You'd need to update both to make this work as intended.
Also, the reason for using promises here is because there is a delay from the execution of the randomized output with the generation of the image. If you try to execute them in normal succession, the code will fail. It's a dirty solution, but it seems to work.
But probably there is a more elegant way to do this, because strictly speaking, this required a lot of trickery and working around with the particularities from the randomizer, so I hope there is indeed a better answer! 😅