Adds command to close all tabs
Type :qa or :quitall to close all tabs
This commit is contained in:
		
							parent
							
								
									982a54c0aa
								
							
						
					
					
						commit
						4445309334
					
				
					 2 changed files with 16 additions and 1 deletions
				
			
		|  | @ -86,10 +86,14 @@ To adjust the search engine default and add/remove search engines, see the [sear | ||||||
| 
 | 
 | ||||||
| Open a URL or search keywords by search engine in new tab. | Open a URL or search keywords by search engine in new tab. | ||||||
| 
 | 
 | ||||||
| #### `:quit` command | #### `:quit` or `:q` command | ||||||
| 
 | 
 | ||||||
| Close the current tab. | Close the current tab. | ||||||
| 
 | 
 | ||||||
|  | #### `:quitall` or `:qa` command | ||||||
|  | 
 | ||||||
|  | Close all tabs. | ||||||
|  | 
 | ||||||
| #### `:bdelete` command | #### `:bdelete` command | ||||||
| 
 | 
 | ||||||
| Close a certain tab. | Close a certain tab. | ||||||
|  |  | ||||||
|  | @ -27,6 +27,14 @@ const tabcloseCommand = () => { | ||||||
|   }); |   }); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | const tabcloseAllCommand = () => { | ||||||
|  |   return browser.tabs.query({ | ||||||
|  |     currentWindow: true | ||||||
|  |   }).then((tabList) => { | ||||||
|  |     return browser.tabs.remove(tabList.map(tab => tab.id)); | ||||||
|  |   }); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| const winopenCommand = (url) => { | const winopenCommand = (url) => { | ||||||
|   return browser.windows.create({ url }); |   return browser.windows.create({ url }); | ||||||
| }; | }; | ||||||
|  | @ -117,6 +125,9 @@ const exec = (tab, line, settings) => { | ||||||
|   case 'q': |   case 'q': | ||||||
|   case 'quit': |   case 'quit': | ||||||
|     return tabcloseCommand(); |     return tabcloseCommand(); | ||||||
|  |   case 'qa': | ||||||
|  |   case 'quitall': | ||||||
|  |     return tabcloseAllCommand() | ||||||
|   case '': |   case '': | ||||||
|     return Promise.resolve(); |     return Promise.resolve(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
		Reference in a new issue