Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new actions: remove left tab and remove right tab #214

Closed
silverzhaojr opened this issue Dec 20, 2017 · 1 comment
Closed

Add new actions: remove left tab and remove right tab #214

silverzhaojr opened this issue Dec 20, 2017 · 1 comment

Comments

@silverzhaojr
Copy link

Gesturefy has "Remove left tabs" and "Remove right tabs", which will close all other tabs before or after the current tab.

Is it possible to add new actions like "Remove left tab" and "Remove right tab", which will close only one neighbour tab? Thanks.

@Robbendebiene
Copy link
Owner

Once you received the update to version 3.0.3 you can use the following code as a user script.

Remove right tab:


const queryTabs = API.tabs.query({
	hidden: false,
  currentWindow: true
});

queryTabs.then((tabs) => {
  const activeTabIndex = tabs.findIndex(tab => tab.active === true);
  
	const nextTab = tabs[activeTabIndex + 1]

	if (nextTab) {
		API.tabs.remove(nextTab.id);
	}
});

Remove left tab:

const queryTabs = API.tabs.query({
	hidden: false,
  currentWindow: true
});

queryTabs.then((tabs) => {
  const activeTabIndex = tabs.findIndex(tab => tab.active === true);
  
	const previousTab = tabs[activeTabIndex - 1]

	if (previousTab) {
		API.tabs.remove(previousTab.id);
	}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants