I created a temporary Firefox add-on which opens a new tab when an icon is clicked. I used the example provided in this link:
https://github.com/mdn/webextensions-examples/tree/master/open-my-page-button
This works fine but the new tab opens to a fixed URL. So added a preferences page using the code provided in this link:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Implement_a_settings_page
Now I'm able to save a URL in the preference page of the extension and the saved URL can be verified in the Extension Storage, here is an image showing it:
function openPage() {
browser.tabs.create({
url: "https://www.google.com"
});
}
browser.browserAction.onClicked.addListener(openPage);
function onError(error) {
console.log(`Error: ${error}`);
}
function onGot(item) {
let preference_url = "https://www.google.com";
if (item.preference_url) {
preference_url = item.preference_url;
}
browser.storage.local.set({ type : preference_url });
}
let getting = browser.storage.sync.get("preference_url");
getting.then(onGot, onError);
On the third line I have url: "https://www.google.com" but I would like to use the value in the extension storage.