Comments (10)
Have you seen
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Examples
yet?
There are also homepage links in about:addons in your browser.
Which browser version on which OS are you using?
Also, when describing a problem it is always helpful to answer these questions, for other to get proper context:
- What did you do? (steps to reproduce)
- What happened? (actual results)
- What should have happened? (expected results)
It took few days to me to realize that when I open new Tab in Firefox, it is not html page
If I understand this correctly then you did the equvalent of
New Tab Ctrl + T
The toolbar icon appears, the menu appears when you click it, but no beast is loaded, right?
The browser console says something similar to
Unchecked lastError value: Error: No matching window
right?
from webextensions-examples.
I use FF 48 beta.
No, I did not see it, now for first time.
I was on empty page (e.g. Ctrl+Tab) or on about:debugging#addons. The previous looks like normal webpage because there is search bar and some links to my visited sites. Now I relelize the page contains DOM, so there must be document. I don't know why the beastify cannot work as expected here. I need to go to e.g. google.com .... and then I click on the footprint icon. So it works when there is html page loaded. No on the "empty" page or "about:debugging" page.
"The toolbar icon appears, the menu appears when you click it, but no beast is loaded, right?"
Exactly. Nothing happens when I click on the item on the popup. I can click as many times as I want.
No change in browser window (is this is what you mean by console).
I found one more bug when I am working with popup (similar to Beastify). I can add it here later.
from webextensions-examples.
So it works when there is html page loaded. No on the "empty" page or "about:debugging" page.
Yes, it seems like tabs.executeScript doesn't work for about: pages (the empty page is an about: page as well - about:newtab) - that's where the "No matching window" error comes from.
I can see how this would be confusing to a lot of people. I'm not sure what the best solution is though. The only thing I can think of is to catch the error and log something more understandable, like "Can't beastify this page - try using a normal HTTP(S) page". And update the README to be more explicit about this.
"The toolbar icon appears, the menu appears when you click it, but no beast is loaded, right?"
Exactly. Nothing happens when I click on the item on the popup. I can click as many times as I want.
No change in browser window (is this is what you mean by console).
No, the console is a debugging tool that displays error messages and messages logged by the add-on: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Debugging#Viewing_log_output.
from webextensions-examples.
Anaran used term "Browser console" not Addons Debugger Console. That's why my reaction was in that way. I know what is Addons Debugger Console. But I don't know what is browser console. That's that. There is also Developers tool Console. Which does not work for addons.
May I add here some another information related to popup "strange behaviour"? I created a project from Beastify & Favourite Color. Instead Frog, Snake and Turtle I used 4 icons with decription. First time when I click a button, popup appears with 4 items. Everything looks nice. But sometimes it seems that it does not react, so I click and nothing happens. Nexttime I click and I must wait - I guess some 200-300ms delay to open a single popup with 4 divs and 4 images... Next time I click and new set of icons is set to the same popup. So now there are 8 icons instead 4. Next time I click and nothing happens. Next time I click and I must wait about 900-1200ms to appear the popup but this time 12 icons there.. And so on. Then after hours - just now - I am clicking many times and no popup appears (just arrow up). I wait few seconds and click again and it appears 4 icons (but ). Click again, nothing. Click again 4 icons. So I could upload my extension if I find suitable location and you could check it if it does the same thing for you. Maybe there is some bug in the Addons API. I think it should work but doesn't.
Edit:
Yet I copied the Addon to new folder, I removed most of icons and images which where not used, and then I added the addon do Addon::Debugger and now no problems. So it is not clear to me why it could happen previously.
from webextensions-examples.
So I could upload my extension if I find suitable location and you could check it if it does the same thing for you.
Yes, please do.
from webextensions-examples.
I would do but I cannot find how to create directory. Should I upload zip file? I tried to upload files here to my first Repository but it did not uploaded directories.
from webextensions-examples.
Yes, you could upload a zip of the entire add-on.
from webextensions-examples.
I think there should be more explanation about the Beastify addon. Esspecially about activeTab permission. I mean help people to find relations between the things which are there but are not obvious untill you read the docs completely. I think you could add the text as a comment before the line where Content Script is executed:
activeTab permission
This permission is specified as "activeTab". If an extension has the activeTab permission, then when the user interacts with the extension (for example: clicks its browser action or page action, or selects its context menu item), the extension is granted extra privileges for the active tab only.
The extra privileges are:
- the ability to inject JavaScript or CSS into the tab programmatically, using chrome.tabs.executeScript and chrome.tabs.insertCSS
- access to the privileged parts of the tabs API for the current tab: Tab.url, Tab.title, and Tab.faviconUrl.
Also, I would like to see some example how to open new tab from the popup. It is definitevly not clear how to do it when you don't have permission and when a single browser action "options_ui" is not enough. I have a list of icons and want to open tabs when I click a icon, just like in Favourite color example but in non-addons tab. But that example is fixed only with a button and the Beastify popup does not open any tab, just executes a script in current tab. So where can I learn it when it is not there?
from webextensions-examples.
When I am sending a message
browser.tabs.sendMessage(
tabId, // integer
message, // any
options, // optional object
function(response) {...} // optional function
)
How can I find tabId? In examples you use tab[0]. But when I open page, I don't know what is the tab's id. I wish not to open new page every time when I click on the same item in popup. So when I open "Advanced settings" and click again, there should not be opened new tab with advanced setting form because it is already opened. I can imagine sending a message to ask the ID which I need in main script which opened new tab. But here is the part which is not clear to me. I do not know the tabId so what should I use. Is it valid to use null instead tab[n]? What will happen? I expect that if tab[n] present, it sends message to particular window, right? Are the messages kept separated for every window or are they in one container? If they are in one container, then why should I could not to use null? All windows which have listener needs to check message container, don't they? So would be something wrong if I would send message to all tabs and only the window which url is equal to the url in the parameter options.url will respond to the message.
The reason why I want to do this messaging is because need to know the Id of th new tab which was created to prevent the same tab to be opened several times in separated tabs.
from webextensions-examples.
tabs.create takes a callback parameter, that's called with the new tab's ID. Please check the documentation: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/Tabs/create.
This issue tracker is for bugs in the examples repo, not for general support with WebExtensions. If you need general support, please try:
https://discourse.mozilla-community.org/c/add-ons
or
https://mail.mozilla.org/listinfo/dev-addons
from webextensions-examples.
Related Issues (20)
- 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
- Can't get response in Ubuntu HOT 10
- 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
- zip does not contain a valid manifest HOT 2
- Examples disabled when run via web-ext or from folder (applyCSS, borderify) HOT 9
- minor bug with native messaging example HOT 2
- native messaging example: port disconnects without an error HOT 14
- devtools-panels example broken with manifest v3 HOT 1
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.