Giter Site home page Giter Site logo

Comments (10)

guest271314 avatar guest271314 commented on July 17, 2024 1
  1. 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);
});
  1. Create the directory native-messaging-hosts in ~/.mozilla;
  2. Open the file ping_pong.json, write the full path on the filesystem to ping_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]" ]
}
  1. 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 to env 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.

Screenshot_2023-01-02_21-18-59

from webextensions-examples.

higba avatar higba commented on July 17, 2024

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.

guest271314 avatar guest271314 commented on July 17, 2024

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.

yigitcanustek avatar yigitcanustek commented on July 17, 2024

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.

guest271314 avatar guest271314 commented on July 17, 2024

The last time I tested on Nightly it worked. I'll test again later today or tomorrow.

from webextensions-examples.

yigitcanustek avatar yigitcanustek commented on July 17, 2024

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.

guest271314 avatar guest271314 commented on July 17, 2024

Neither. I removed the snap Firefox installation. Then removed snap altogether and fetched Nightly and created the file in ~/.mozilla.

from webextensions-examples.

guest271314 avatar guest271314 commented on July 17, 2024

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.

yigitcanustek avatar yigitcanustek commented on July 17, 2024

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.

yigitcanustek avatar yigitcanustek commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.