Skip to content

Instantly share code, notes, and snippets.

@mavc
Last active September 28, 2017 03:24
Show Gist options
  • Save mavc/cbaeda11b3f510f23fa165316e12903c to your computer and use it in GitHub Desktop.
Save mavc/cbaeda11b3f510f23fa165316e12903c to your computer and use it in GitHub Desktop.
Foxy Gestures: Close Tab and Focus Left
executeInBackground(async () => {
const tabs = await browser.tabs.query({currentWindow: true});
const activeTab = tabs.find((t) => t.active);
if (activeTab.index > 0) {
// Set the current tab to the tab on the left.
let nextTab = tabs.find((t) => t.index == activeTab.index - 1);
await browser.tabs.update(nextTab.id, {active: true});
}
// Close the current tab.
await browser.tabs.remove(activeTab.id);
}).catch((e) => {
console.error(e);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment