NPAPI for Python - Chrome Extension

I am trying to develop a chrome extension in which I encoded all my logic in "python". Now in the browser action, I want to pass the parameters and execute this .py file and return the results to the pop-up window that opens in the browser action. To call a .py file from JavaScript, I know that I will need to encode the NPAPI plugin. But I am confused between what approach i should take. I came across several options, and I'm trying to choose the easiest way to do this.

  • Pajamas Python Javascript Compiler: This is a Python-to-Javascript compiler that works as a language translator, but for the frequently asked questions there, the last question on the site suggests that it will not work in Chrome. ( http://pyjs.org/ )

  • FireBreath: FireBreath is an environment that makes it easy to create powerful browser plugins. ( http://www.firebreath.org )

  • pyplugin is an NPAPI plugin for Python for XULRunner: it allows you to create cross-platform graphical user interfaces using XUL and Python. ( http://pyplugin.com )

Plz Direct me to the easiest way that will allow me to pass parameters and execute this .py file and get the returned results from .py.

Thanx

+4
source share
1 answer

Well, the Pajamas Python Javascript Compiler will not be complete - not all python functions are available in javascript, so it is not possible to convert all python to javascript. It may or may not do what you want, but I do not think this is happening on the fly. I think you need to write something on the desktop and run it through the "compiler" to get javascript from the other side.

FireBreath is the most amazing thing that has ever hit the Internet - I should have known since I wrote it - and this will absolutely allow you to do what you want, but you will need to know how to associate Python with C + + to do what you want. However, you can probably use boost.python, which is included in the subset of boost that comes with FireBreath, but I never used it, so I don't know. You can pretty much do whatever you want with the NPAPI plugin, but you need to be aware of security issues.

A quick look at pyplugin makes it look like pyplugin - this is basically what you write in FireBreath, but just a raw npapi plugin. If this will do what you want, this is probably the easiest way. It is intended for use with XUL, which can be a problem since Chrome does not support XUL. You can also change it (as it is GPL) to do what you want. Of course, if you do not plan to release your source, this can also be a problem.

The fastest way to solve your problem? Well, you have to decide; it will require a few more studies, but I hope this is enough to at least begin. Good luck

+5
source

Source: https://habr.com/ru/post/1340576/


All Articles