mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
Added Windows support (in theory)
This commit is contained in:
@@ -4,9 +4,28 @@ The WebExtension, which can be found under "add-on", connects to the native appl
|
||||
|
||||
The native application, which can be found under "app", listens for messages from the WebExtension. When it receives a message, the native application sends a response message whose payload is just "pong". The native application is written in Python.
|
||||
|
||||
To get this working, there's a little setup to do:
|
||||
## Setup ##
|
||||
|
||||
* edit the "path" property of "app/ping_pong.json" to point to the location of "app/ping_pong.py" on your computer
|
||||
* copy "app/ping_pong.json" to the correct location on your computer. See [host manifest locations]() to find the correct location for your OS.
|
||||
To get this working, there's a little setup to do.
|
||||
|
||||
### Mac OS/Linux setup ###
|
||||
|
||||
* Check that the [file permissions](https://en.wikipedia.org/wiki/File_system_permissions) for "ping_pong.py" include the `execute` permission.
|
||||
* Edit the "path" property of "ping_pong.json" to point to the location of "ping_pong.py" on your computer.
|
||||
* copy "ping_pong.json" to the correct location on your computer. See [Host Manifests ](https://wiki.mozilla.org/WebExtensions/Native_Messaging#Host_Manifests) to find the correct location for your OS.
|
||||
|
||||
### Windows setup ###
|
||||
|
||||
* Check you have Python installed.
|
||||
* Edit "ping_pong_win.bat" so it contains the path to "ping_pong.py" on your computer.
|
||||
* Edit the "path" property of "ping_pong_win.json" to point to the location of "ping_pong_win.bat" on your computer.
|
||||
* Add a registry key containing the path to "ping_pong_win.json" on your computer. See [Host Manifests ](https://wiki.mozilla.org/WebExtensions/Native_Messaging#Host_Manifests) to find details of the registry key to add.
|
||||
|
||||
## Testing the example ##
|
||||
|
||||
Then just install the add-on as usual, by visiting about:debugging, clicking "Load Temporary Add-on", and selecting the add-on's "manifest.json".
|
||||
|
||||
You should see a new browser action icon in the toolbar. Open the console ("Tools/Web Developer/Browser Console" in Firefox), and click the browser action icon. You should see output like this in the console:
|
||||
|
||||
Sending: ping
|
||||
Received: pong
|
||||
|
||||
3
native-messaging/app/ping_pong_win.bat
Normal file
3
native-messaging/app/ping_pong_win.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
|
||||
python "path\to\your\ping_pong.py"
|
||||
7
native-messaging/app/ping_pong_win.json
Normal file
7
native-messaging/app/ping_pong_win.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "ping_pong",
|
||||
"description": "Example host for native messaging",
|
||||
"path": "ping_pong_win.bat",
|
||||
"type": "stdio",
|
||||
"allowed_extensions": [ "ping_pong@example.org" ]
|
||||
}
|
||||
Reference in New Issue
Block a user