Open add-on settings when url is not set

This commit is contained in:
ikipatang 2017-11-22 14:21:30 +01:00
parent f39eb6e174
commit 4b0c115cd3

View file

@ -1,3 +1,17 @@
/**
* Open the given url in a popup
* @param {string} url -
* @return {void} -
*/
function openInPopup(url) {
browser.windows.create({
url,
type: 'popup',
allowScriptsToClose: true,
});
}
/**
* Share Current Tab
* @return {void} -
@ -10,13 +24,12 @@ function shareCurrentTab() {
const url = tabs[0].url;
const title = tabs[0].title || url;
browser.storage.local.get('url').then((storage) => {
const shareUrl = `${storage.url}?post=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&source=bookmarklet`;
browser.windows.create({
url: shareUrl,
type: 'popup',
allowScriptsToClose: true,
});
if(storage.url){
const shareUrl = `${storage.url}?post=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&source=bookmarklet`;
openInPopup(shareUrl);
}else{
browser.runtime.openOptionsPage()
}
});
});
}