Anki 2.1.28 Beta

Here is a pretty minimal example, when using this, and then opening e.g. the Add Cards dialog, the abovementioned error appears in the web inspector. The URL that is built seems to be correct though.

from aqt import mw
import aqt

# assuming add-on folder is named "test"
# and assuming a 'test.js' is in the same folder
addon_id = "test"
port = mw.mediaServer.getPort()
mw.addonManager.setWebExports(addon_id, ".*\\.js$")

aqt.editor._html += f"""
    <script>
        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = 'http://127.0.0.1:{port}/_addons/{addon_id}/test.js';
        document.body.appendChild(script);
    </script>"""

1 Like