popups have the same privileges as the background page. The only limitation is that they stop running when theyâre closed. So if you do something async (promises) and close the popup while thatâs still running thereâs no guarantee itâll complete.
What would be the best solution to make a settings page then?
I activated the option âDisable Popup auto-hideâ. My entries did not appear in the storage manager while my console output with .then was working fine.
I am developing the whole thing for a subject paper in computer science for my Abitur (Germany) and it will be open-source, so you can just find my code here: https://github.com/Th3Ph4nt0m/Pius-Addon
I would be really grateful if we could find a reasonable solution together.
The best way to do a settings page is probably options ui.
But in general, it would be to save settings on blur of the input or similar, instead of requiring a submit.
Unfortunately, this is not possible in this case. The Options UI is actually very unknown, so many will not find the settings. To keep the UX as good as possible, everything should be found in one place, preferably in the pop-up.
I also cannot save the values, for example, when entering them, as 3 dropdowns result in one entry at the end.
My code should be correct though, if Iâm not completely wrong. So I donât understand why the entries are not set.
async function setSomeData() {
await browser.storage.local.set({a: 1});
const {a} = await browser.storage.local.get('a'); // getting back "a" using Destructuring assignment
console.log(a); // prints "1"
}
I have no idea what I am doing wrong here. The chrome api has a similar structure, so I only need to change browser to chrome. I have the same problem there.
However when I go to âabout:debuggingâ and click âInspectâ button next to my addon then in there I can see âExtension storageâ with my storage.
Anyway, when you need to check the storage, it may be faster to just open a console and execute:
Yeah, thatâs right. I am using the storage inspector via the âInspectâ from âDebug Addonsâ. As you can see here, the console output is correct, but the storage inspector remains empty, even after reloading it manually.
Note that you are in a Popup context - maybe if you switch to background script context it would help.
Just like with multiple iframes in the page you can switch your current âviewâ to display a specific âcontextâ, with the addon debugger you can also switch which part of your extension you want to debug. To do this, there is an icon in the upper right corner: https://developer.mozilla.org/en-US/docs/Tools/Browser_Toolbox#targeting_a_document