Write Chrome Extensions in Python (Part 1)

In Python?!! That’s right, and it’s pretty painless with PyScript…

Pete Fison
PythonIQ

--

Screenshot by author: Chrome in dark mode with an extension written in Python/PyScript

PyScript has been around for a while now and provides a remarkably easy way to embed Python code directly into HTML pages. But until now, the creation of browser extensions in Python has been something of a closed door — a private members’ club exclusively for JavaScript developers. Well, not any more!

I was lucky enough to enlist the help of PyScript’s Engineering Manager and finally worked out how to run a Python script as a Chrome Extension, displaying output and providing interaction via a Popup box (see the screenshot above). This throws the doors wide open to all sorts of other Python/PyScript possibilities, building on the foundations which I’m about to share…

Create Your Extension Files

Create a new folder for your Extension and download or clone the following repository into it:

  1. Add your own Python code in between the <py-script> tags and/or <py-repl>in popup.html .

--

--

Pete Fison
PythonIQ

Experienced Python developer with a special interest in web scraping, data wrangling, ETL, NLP, and AI Prompt Engineering. Former IT Director & Video Producer.