There are existing solutions to loading the Kongregate API already, like using Execute Javascript calls and loading the API from an exported HTML file, but it would be much more convenient to load the API directly from JavaScript.
I've done two things to try and make this work. I have this code as a separate main.js file:
runOnStartup(async runtime => {
kongregateAPI.loadAPI(() => {
globalThis.kongregate = kongregateAPI.getAPI();
alert("Kongregate API successfully loaded!");
});
});
And I've also tried loading the Kongregate API by copying the contents of that file into a new script. However, this causes a syntax error, if I understand correctly this is because of the automatic strict mode.
Is there a way to achieve this with JavaScript alone?