Git Product home page Git Product logo

Comments (7)

wbamberg avatar wbamberg commented on August 19, 2024

Yes, beastify does not currently work in Firefox due to some bugs, so I omitted the "applications" key (otherwise, since Google Chrome doesn't like the "applications" key, it would not be installable anywhere!). I should have noted this, but I hadn't really expected anyone to stumble on this one. I have now updated the README: https://github.com/mdn/webextensions-examples/blob/master/README.md.

Once the Firefox bugs are fixed, I'll add the "applications" key back and close this bug.

Thanks for trying it out!

from webextensions-examples.

Mottie avatar Mottie commented on August 19, 2024

The documentation should also explicitly mention that the "id" needs to be in an email format.

"applications": {
  "gecko": {
    "id": "[email protected]"
  }
}

I did find a reference here, but it took a lot of link clicking to get there.

Also, on this page, the following comment should mention that the key is mandatory and again, that the id should be in an email format:

The next key, "applications", contains Firefox-specific information.

Thanks!

from webextensions-examples.

ncalexan avatar ncalexan commented on August 19, 2024

Beastify now installs, but it doesn't work. I get

TypeError: tab is null (ext-tabs.js:442:13)

Is this expected?

from webextensions-examples.

wbamberg avatar wbamberg commented on August 19, 2024

@ncalexan

Is this expected?

Yes! There are at least 2 issues that stop it from working in current Nightlies. This is noted in my comment upthread and in the docs for these examples: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Examples.

from webextensions-examples.

Omar-Asumani avatar Omar-Asumani commented on August 19, 2024

'tab' problem could easily be fixed if you replace 'currentWindow' key in 'chrome.tabs.query' method with 'lastFocusedWindow'. Also you should add 'tabs' permissions in manifest. Nevertheless I still couldn't successfully run it. I believe there are still problems with obtaining web accessible resources. I am developing extension of my own and I face problems with 'chrome.extension.getURL'. I simply can't find workaround to access extension resources from content.

from webextensions-examples.

wbamberg avatar wbamberg commented on August 19, 2024

'tab' problem could easily be fixed if you replace 'currentWindow' key
in 'chrome.tabs.query' method with 'lastFocusedWindow'.

I don't think so. I think this "tab is null" error is because we were omitting the first argument to "tabs.executeScript" [1]. According to the Chrome docs, if you omit this, you execute the script in the current tab [2]. This does not work on Firefox [3]. The workaround is to pass null instead of just omitting that argument. Since the workaround is a simple one, and the code seems less magical that way anyway, I just updated the example to do that.

However, the next bug is that Firefox doesn't support the "callback" argument to executeScript [4]. I'm using this so I know that the content script has executed (and therefore that message listeners have been added) before I try to send a message to the content script.

Actually, I don't know if this is needed, or if I can just send messages right after calling executeScript. I have tried sending messages right after executeScript, and it works, but I don't know if it just happens to work in my case, or if it is generally a safe thing to do (for example: if the API queues messages until the script has executed. But that sounds kind of unlikely). If it is needed, then it's hard to fix this example without bug 1210583 being fixed, so the example is kind of in limbo.

I believe there are still problems with obtaining web accessible resources.

One problem that would affect this example is that wildcards in web_accessible_resources don't work [5]. If you list all the resources explicitly, then it should work. But that would not be a natural way to write an add-on like this, so I don't want to make that change, and would prefer to wait for the bug fix.

Also you should add 'tabs' permissions in manifest.

Are you sure about that? It works fine in Chrome as it is, without "tabs". And I don't see any permission problems in Firefox either. I thought specifying a host (or every host, in this case :) ) gave you permission to use executeScript? What I really ought to do here is use "activeTab" instead of requesting access to every host in the world, but I can't, because Firefox does not yet support the activeTab permission[6].

I am developing extension of my own and I face problems with 'chrome.extension.getURL'

What problem? It works for me. It didn't work a few weeks ago, but seems to be fixed in current Nightlies.

[1] https://github.com/mdn/webextensions-examples/blob/master/beastify/popup/choose_beast.js#L22 - but note that I've just updated this to pass "null".
[2] https://developer.chrome.com/extensions/tabs#method-executeScript
[3] https://bugzilla.mozilla.org/show_bug.cgi?id=1208257
[4] https://bugzilla.mozilla.org/show_bug.cgi?id=1210583
[5] https://bugzilla.mozilla.org/show_bug.cgi?id=1217944
[6] https://bugzilla.mozilla.org/show_bug.cgi?id=1190688

from webextensions-examples.

wbamberg avatar wbamberg commented on August 19, 2024

OK, so I've had it confirmed that the callback stuff is not needed, so I made the other changes and this add-on ought to work in Firefox Nightly now.

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.