Open add-on settings when url is not set
This commit is contained in:
		
							parent
							
								
									f39eb6e174
								
							
						
					
					
						commit
						4b0c115cd3
					
				| 
						 | 
					@ -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
 | 
					 * Share Current Tab
 | 
				
			||||||
 * @return {void}       -
 | 
					 * @return {void}       -
 | 
				
			||||||
| 
						 | 
					@ -10,13 +24,12 @@ function shareCurrentTab() {
 | 
				
			||||||
    const url = tabs[0].url;
 | 
					    const url = tabs[0].url;
 | 
				
			||||||
    const title = tabs[0].title || url;
 | 
					    const title = tabs[0].title || url;
 | 
				
			||||||
    browser.storage.local.get('url').then((storage) => {
 | 
					    browser.storage.local.get('url').then((storage) => {
 | 
				
			||||||
      const shareUrl = `${storage.url}?post=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&source=bookmarklet`;
 | 
					      if(storage.url){
 | 
				
			||||||
 | 
					        const shareUrl = `${storage.url}?post=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&source=bookmarklet`;
 | 
				
			||||||
      browser.windows.create({
 | 
					        openInPopup(shareUrl);
 | 
				
			||||||
        url: shareUrl,
 | 
					      }else{
 | 
				
			||||||
        type: 'popup',
 | 
					        browser.runtime.openOptionsPage()
 | 
				
			||||||
        allowScriptsToClose: true,
 | 
					      }
 | 
				
			||||||
      });
 | 
					 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue