2020-12-26 20:21 GMT+01:00, Edward Elliott <
ese...@gmail.com>:
> How does brython execute code? My limited understanding is the following:
>
> 1. brython.js scans for <script type='text/python'> tags in DOM
> 2. compiles found scripts to js code
> 3. calls eval (code) on the javascript
>
>
> Where "code" in the above example is just a string. I believe so, but not
> positive.
Have a look here:
https://github.com/brython-dev/brython/wiki/How-Brython-works, to
better understand what is happening behind the curtains.
>
> I ask because chrome extensions are moving from version 2 to 3 some time
> soon. In version 3, extensions are not allowed to execute arbitrary strings
>
> <
https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/#executing-arbitrary-strings>
> of
> js. All js code must reside in a file inside the extension. Which means
> no dynamic (runtime) code generation and hence no brython inside
> extensions. :(
You can include brython.js and brython stdlib and you can create your
own lib and wrap it to be included within the extension (here:
https://github.com/brython-dev/brython/tree/master/scripts, you have
scripts to do so). I think it would be possible to run brython with
manifest 3 but I'm not using chrome and maybe I'm not the most
adequate person to talk about chrome :-(
>
> It's not clear when chrome will stop running version 2 extensions.
> Probably some time in 2021.
>
> Most of you don't use brython in a browser extension. But you may use
> greasemonkey or tampermonkey, which rely on the same behavior. Regardless,
>
> it's sad to see some brython environments taken away by fiat in a browser
> monoculture.
>
> I'll explore potential workarounds. One option is to compile the brython
> code to js code outside the browser, then save the js code in a file inside
>
> the extension. This solution would require two things:
>
> 1. Brython allows output of compiled js
> 2. The entire environment must also be compiled to js, including any
> python modules or brython-specific packages used.
>
> Not sure if either of those is possible, from a quick look at the docs
> <
https://brython.info/static_doc/en/modele.html>. Anyone have experience
> with saving js code generated by brython?
>
> --
> You received this message because you are subscribed to the Google Groups
> "brython" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
brython+u...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/brython/98f194fe-4f59-48cd-a814-928bfba4eeban%40googlegroups.com.
>