AutoControl Control your browser your way Forum               Install now from theChrome Web Store

ACtl.getTabIds


Returns the identifier number of each tab in a tab-selection, maintaining the order and grouping specified by it. ACtl.getTabIds(tabSpec[,mergeGroups]) tabSpec Type: string Selection of tabs whose IDs will be returned. It can be the name of a preset tab-selection or a custom tab-selection. Full details at Tab Specifier. mergeGroups Type: boolean Default: true If tabSpec gives the tabs in groups (example below), pass false to preserve those groups. Pass true to merge all groups into a single array of IDs. Returns Type: Promise Resolves to: Array Returns immediately. The Promise will resolve with an array of tab IDs or groups of IDs in the order given by tabSpec. Throws Type: string Error description if tabSpec is not a valid Tab Specifier.

Examples

Cycle through all tabs in the current window from left to right, with half a second delay in between.

	//Get all tab IDs in the current window from left to right
	let currWinTabs = await ACtl.getTabIds('#currWinTabs') ;
	//For each of those tabs
	for( let tabId of currWinTabs ){
		//Activate the tab
		await ACtl.setTabState(tabId, 'active') ;
		//And sleep for half a second
		await ACtl.sleep(500) ;
	}
	

Use a custom tab-selection to get all tabs grouped by domain and then pin only the groups with 3 or more tabs.

	//Get all tabs grouped by domain
	let tabGroups = await ACtl.getTabIds('All tabs grouped by domain', false) ;
	//For each tab group
	for( let group of tabGroups ){
		//If the group has 3 or more tabs
		if( group.length >= 3 ){
			//Pin all tabs in the group
			ACtl.setTabState(group, 'pinned') ;
		}
	}
	
[{img:'/img/allTabsGroupByDomain.png', elems:[ {type:'rect', params:[[272,283], [178,232], 3, 'dashed']} ], bkgr:'transparent'}]
And this is the custom tab-selection used in the script.
The result of the GROUP BY operation in this example is 3 groups of tabs, one for each domain.
Scripting API Script Isolation Asynchronicity Backgrnd Scripts GUI vs API ACtl.include ACtl.import ACtl.getFile ACtl.saveFile ACtl.saveURL ACtl.openURL ACtl.closeTab ACtl.runInTab ACtl.runInFrames ACtl.runInPageCtx ACtl.getTabInfo ACtl.getTabIds ACtl.TAB_ID ACtl.setTabState ACtl.captureTab ACtl.execAction ACtl.runCommand ACtl.getClipboard ACtl.setClipboard ACtl.expand ACtl.switchState ACtl.var ACtl.pubVar ACtl.on ACtl.off ACtl.sleep ACtl.STOP_CHAIN ACtl.STOP_FULL_SEQ