Fix share current tab function to handle given tab in parameter
This commit is contained in:
parent
0b8d18ff74
commit
b94b88e689
|
@ -17,21 +17,16 @@ function openInPopup(url) {
|
||||||
* Share Current Tab
|
* Share Current Tab
|
||||||
* @return {void} -
|
* @return {void} -
|
||||||
*/
|
*/
|
||||||
function shareCurrentTab() {
|
function shareCurrentTab(tab) {
|
||||||
browser.tabs.query({
|
const url = tab.url;
|
||||||
active: true,
|
const title = tab.title || url;
|
||||||
currentWindow: true,
|
|
||||||
}).then((tabs) => {
|
|
||||||
const url = tabs[0].url;
|
|
||||||
const title = tabs[0].title || url;
|
|
||||||
browser.storage.local.get('url').then((storage) => {
|
browser.storage.local.get('url').then((storage) => {
|
||||||
if(storage.url){
|
if(!storage.url){
|
||||||
|
browser.runtime.openOptionsPage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
const shareUrl = `${storage.url}?post=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&source=bookmarklet`;
|
const shareUrl = `${storage.url}?post=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&source=bookmarklet`;
|
||||||
openInPopup(shareUrl);
|
openInPopup(shareUrl);
|
||||||
}else{
|
|
||||||
browser.runtime.openOptionsPage()
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue