Feedback sobre javascript "on-discourse" para configurar JS personalizado para cada página?

I realized I was doing one foolish thing here. I’m modifying the theme and adding code to the head. If I switch to a different theme, those changes are lost. The right way is to add the code using a plugin. I used the template here: GitHub - discourse/discourse-plugin-skeleton: Template for Discourse plugins. Then, I added JavaScript code like this:

export default {
  name: 'alert',
    initialize() {
        const scripts = [
            'https://files.extrastatic.dev/community/on-discourse.js',
            'https://files.extrastatic.dev/community/index.js'
        ];
        scripts.forEach( s => {
            const script = document.createElement('script');
            script.setAttribute('src', s);
            document.head.appendChild(script);
        });

        const link = document.createElement('link');
        link.setAttribute('rel', "stylesheet");
        link.setAttribute('type', "text/css");
        link.setAttribute('href', "https://files.extrastatic.dev/community/index.css");
        document.head.appendChild(link);
    }
};

Then, I ran ./launcher rebuild app and then enabled the plugin.

Lastly, I needed to add CSP policy in the settings to permit loading those script. I went to admin->settings->security then added files.extrastatic.dev to the “content security policy script src” and clicked apply.