Comments (10)
- Include error handling in background.js (and optionally just log the port) so you know what is going on
let port = browser.runtime.connectNative("ping_pong");
console.log(port);
// Include error handling so we know what is going on
port.onDisconnect.addListener((err) => {
if (browser.runtime.lastError) {
console.warn(browser.runtime.lastError);
}
console.error(err.name, err.message);
});
- Create the directory
native-messaging-hosts
in~/.mozilla
; - Open the file
ping_pong.json
, write the full path on the filesystem toping_pong.py
at"path"
value, e.g.,
{
"name": "ping_pong",
"description": "Example host for native messaging",
"path": "/home/user/native-messaging/app/ping_pong.py",
"type": "stdio",
"allowed_extensions": [ "[email protected]" ]
}
- Open
ping_pong.py
and substitute the following shebang for the one in the file, to avoid any ambiguity as to which executable is being called; the-S
passed toenv
enables passing options to the executable called
-S, --split-string=S process and split S into separate arguments;
used to pass multiple arguments on shebang lines
in this case -u
, for `
-u : force the stdout and stderr streams to be unbuffered;
this option has no effect on stdin; also PYTHONUNBUFFERED=x
#!/usr/bin/env -S python3 -u
because I do not have the executable python
is installed on my machine. If you have the executable python
installed on your machine; then omit step 4.;
5. cd
to the app
directory and make sure ping_pong.py
is marked executable $ chmod u+x ping_pong.py
;
6. On Firefox or Nightly navigate to about:debugging
, click "This Nightly" or "This Firefox", select the "Load Temporary Add-on...", select manifest.json
;
7. Click "Inspect";
8. Pin the icon to the toolbar if not already automatically pinned, then click the icon.
from webextensions-examples.
I am having the same issue but I am running MacOS Monterey 12.6. Mozilla Firefox version 108.0. There is no error, the extension is sending but no response from the application.
from webextensions-examples.
python
alone is not an executable in Ubuntu.
$ find /usr/bin/python
find: ‘/usr/bin/python’: No such file or directory
I filed #490 to fix that issue.
Try substituting
#!/usr/bin/env -S python3 -u
for
#!/usr/bin/env python
from webextensions-examples.
Nope. Still not working.
Also
$ find /usr/bin/python
returns
/usr/bin/python
And yes, i checked the permissions and they all have execute permission.
I think, this is not about Python. Somehow, Firefox is not reading the .json files and can't communicate each other.
from webextensions-examples.
The last time I tested on Nightly it worked. I'll test again later today or tomorrow.
from webextensions-examples.
Okey. I'll wait the test result but i want to ask where do you put manifest file? I am asking this question because
/usr/lib/mozilla/native-messaging-hosts/.json
and
/usr/lib64/mozilla/native-messaging-hosts/.json
the mozilla folder didn't exist. So, manually created by myself. I think, this issue related to this configuration. Briefly, how to configure this environment? Can you provide ur configurement verbosely?
from webextensions-examples.
Neither. I removed the snap Firefox installation. Then removed snap altogether and fetched Nightly and created the file in ~/.mozilla.
from webextensions-examples.
I created this
~/.mozilla/native-messaging-hosts/<name>.json
per https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_manifests#linux.
from webextensions-examples.
Yeah. Finally make it! Thanks.
The causing problem is
#!/usr/bin/env -S python3 -u
with
~/.mozilla
path.
I tried
/usr/lib...
path which is firstly specified in docs. I also created file before ops in
~/.mozilla
too but i think i made typo errors.
Thanks again :)
from webextensions-examples.
I am having the same issue but I am running MacOS Monterey 12.6. Mozilla Firefox version 108.0. There is no error, the extension is sending but no response from the application.
If you are able to solve your problem, i think we close this issue.
from webextensions-examples.
Related Issues (20)
- Colors !?
- Manifest v3 examples needed HOT 6
- Favourite Color bug manifest HOT 11
- Native messaging example doesn't pong after a while HOT 3
- browser is not defined in firefox HOT 3
- Python Native Messaging host does not process 1MB input HOT 11
- Image is not loading by innerHTML in the content-script-register HOT 3
- Create an example of getting select text to a variable HOT 2
- Please add example for "Paste text from clipboard" HOT 5
- examples.json should include a way to list significant manifest keys
- Update eslint, fix linting errors and integrate in CI
- MV3 example for getting data from page/content script/activeTab context into action / popup HOT 3
- Broken root-cert-stats due to var -> let change HOT 6
- Firefox Load temporary addon not working HOT 12
- native-messaging app example: provide non-contrived example for each platform HOT 1
- Update root-cert-stats to use runtime.sendMessage HOT 3
- Update execCommand use in context-menu-copy-link-with-types HOT 2
- beastify beasts-48.png image is 60x60 not 48x48 HOT 1
- zip does not contain a valid manifest HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webextensions-examples.