Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome extension in python?

I would like to create a google chrome extension. Specifically, I'd like to make a packaged app, but not a hosted app. Am I correct in thinking this limits me to JavaScript (and HTML/CSS)?

My problem is that I need to do some complex math (singular value decomposition, factor analysis) and I don't want to write algorithms for this in javascript. Python already has libraries for the functions I need (SciPy), but I can't find any indication that I can make a Chrome extension using python.

Is this correct? Do I have any other options?

like image 375
Jeff Avatar asked Feb 19 '11 02:02

Jeff


People also ask

Can I write a Chrome extension in Python?

Python Bindings for Google Chrome API might provide what you are looking for. Those bindings are for CEF, which is explicitly not compatible with Chrome extensions, so it definitely can't be used to make them.

Can I make my own Chrome extension?

A chrome extension is a program that is installed in the Chrome browser that enhances the functionality of the browser. You can build one easily using web technologies like HTML, CSS, and JavaScript. Creating a chrome extension is similar to creating a web application, but it requires a manifest.

What language is a Chrome extension written in?

Chrome extensions extend Chrome's capabilities. You write them using HTML, CSS, and JavaScript.

How to create Chrome extension using Python?

You can find your extension in /compiledpythonextension/. Load it in chrome as unpackaged extension and see it working :-) Chrome plugins are created using HTML, JavaScript and CSS. We can use Python to create normal Chrome extensions using a Python to Javascript compiler (Rapydscript).

Is it possible to run a python script on Google Chrome?

A Python script compiled with Rapydscript works like any other Chrome plugin. Pyjamas scripts does not work well with Google Chrome (needs a special parameter when Chrome starts or server). Show activity on this post. Although you mentioned you don't want it to be a hosted app, but this is one typical scenario where a hosted app can do.

How to install Chrome extensions?

Drag and drop the directory where your extension files live onto chrome://extensions in your browser to load it. If the extension is valid, it’ll be loaded up and active right away! Open the chrome://extensions page. Drag the folder to the chrome://extensions page. Installation Successful! Click on the icon & the message will get displayed!

How do I compile Python to JavaScript?

There are several tools to compile Python to Javascript. Rapydscript works fine, Pyjs does not work well with chrome (requires special parameter on start). You can find your extension in /compiledpythonextension/. Load it in chrome as unpackaged extension and see it working :-) Chrome plugins are created using HTML, JavaScript and CSS.


2 Answers

There is no Python built into Chrome but I am wondering whether pyjs can help you.

like image 187
chx Avatar answered Sep 23 '22 17:09

chx


You can make a standard Google Chrome extension with Python (server-less) https://pythonspot.com/en/create-a-chrome-plugin-with-python/

The idea is to compile Python to Javascript (technically a JS pre-compiler) using Rapydscript. Then include the generated script in the Chrome extension. The site above has a zip file with all the stuff inside.

I recommend using Rapydscript instead of Pyjamas. A Python script compiled with Rapydscript works like any other Chrome plugin.

Pyjamas scripts does not work well with Google Chrome (needs a special parameter when Chrome starts or server).

like image 27
zxvn Avatar answered Sep 24 '22 17:09

zxvn