do not define custom events, use as it is
This commit is contained in:
		
							parent
							
								
									5c86f87394
								
							
						
					
					
						commit
						795c97d800
					
				
					 1 changed files with 13 additions and 2 deletions
				
			
		|  | @ -1,8 +1,19 @@ | ||||||
| export default class Tabs { | export default class Tabs { | ||||||
|  |      /* Add an action listener.  | ||||||
|  |       | ||||||
|  |      @param {string} event The event to listen for | ||||||
|  |      @param {function} callback The callback function | ||||||
|  |      */ | ||||||
|      static addActionListener(event, callback) { |      static addActionListener(event, callback) { | ||||||
| 		(event.toLowerCase().includes(`update`)) ? chrome.tabs.onUpdated.addListener(async (tabId, info, tab) => {callback({"tabId": tabId, "info": info, "tab": tab})}) : false; |           chrome.tabs[event].addListener((tabId, info, tab) => {callback({"tabId": tabId, "info": info, "tab": tab})}) | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
|  |      /* Create a new tab. | ||||||
|  | 
 | ||||||
|  |      @param {string} URL The URL to open | ||||||
|  |      @param {number} index The index of the tab | ||||||
|  |      @param {boolean} pinned Whether the tab is pinned | ||||||
|  |      */ | ||||||
|      static create(URL, index, pinned = false) { |      static create(URL, index, pinned = false) { | ||||||
|           ((typeof index).includes(`obj`) && index != null && !Array.isArray(index)) |           ((typeof index).includes(`obj`) && index != null && !Array.isArray(index)) | ||||||
|           // Set the options. 
 |           // Set the options. 
 | ||||||
|  | @ -19,7 +30,7 @@ export default class Tabs { | ||||||
|      @param {number} index the tab number to return |      @param {number} index the tab number to return | ||||||
|      */ |      */ | ||||||
|      static async query(filters, index) { |      static async query(filters, index) { | ||||||
|           filters = ((typeof filters).includes(`obj`)) ? filters : { active: true, currentWindow: true}; |           filters = ((typeof filters).includes(`obj`) && filters != null) ? filters : { active: true, currentWindow: true}; | ||||||
|           let TABS = {}; |           let TABS = {}; | ||||||
| 
 | 
 | ||||||
|           TABS.all = await chrome.tabs.query(filters); |           TABS.all = await chrome.tabs.query(filters); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue