Feedback zu "on-discourse" Javascript für die Einrichtung von benutzerdefiniertem JS für jede Seite?

Hi @RGJ I have been trying to figure out how to do this, and have to admit I’m getting confused. It appears the plugin API has changed a bit over the years and I’m not sure how to get what’s current, or see an example.

Your code looks like it goes into an HTML page somewhere as it is wrapped by the script tags. I was using code like this which is the JS file itself.

How do I modify my plugin to use the code you provided? Is this code you suggested something that goes into a plugin, or do I put it into a theme, or otherwise add it to the pages?

I tried to use code like this:

export default {
  name: 'publicdo',
    initialize() {
     withPluginApi('0.1', api => {
                api.onPageChange(() => {
                   console.log('Run my code here.');
                });
      });
    }
}

But, this fails with Uncaught (in promise) ReferenceError: withPluginApi is not defined so it clearly isn’t something that generally loaded JS receives.