Skip to content

Instantly share code, notes, and snippets.

@zbraniecki
Created August 27, 2017 07:05
Show Gist options
  • Save zbraniecki/000268ea27154bbccaad190dd479d226 to your computer and use it in GitHub Desktop.
Save zbraniecki/000268ea27154bbccaad190dd479d226 to your computer and use it in GitHub Desktop.
selectTab extension
browser.commands.onCommand.addListener(async (command) => {
let num = parseInt(command.substr(9, 10)) - 1;
let tabs = await browser.tabs.query({currentWindow: true});
if (tabs.length < num) {
return;
}
browser.tabs.update(tabs[num].id, {active: true});
});
{
"applications": {
"gecko": {
"id": "selecttab@braniecki.net",
"strict_min_version": "48.0"
}
},
"manifest_version": 2,
"name": "SelectTab Gnome Shortcut Override",
"version": "1.0",
"description": "An extension that overrides the default select-tab modifier key.",
"permissions": ["tabs"],
"background": {
"scripts": ["background.js"]
},
"commands": {
"selectTab1": {
"suggested_key": { "default": "Ctrl+1" },
"description": "Activate Tab 1"
},
"selectTab2": {
"suggested_key": { "default": "Ctrl+2" },
"description": "Activate Tab 2"
},
"selectTab3": {
"suggested_key": { "default": "Ctrl+3" },
"description": "Activate Tab 3"
},
"selectTab4": {
"suggested_key": { "default": "Ctrl+4" },
"description": "Activate Tab 4"
},
"selectTab5": {
"suggested_key": { "default": "Ctrl+5" },
"description": "Activate Tab 5"
},
"selectTab6": {
"suggested_key": { "default": "Ctrl+6" },
"description": "Activate Tab 6"
},
"selectTab7": {
"suggested_key": { "default": "Ctrl+7" },
"description": "Activate Tab 7"
},
"selectTab8": {
"suggested_key": { "default": "Ctrl+8" },
"description": "Activate Tab 8"
},
"selectTab9": {
"suggested_key": { "default": "Ctrl+9" },
"description": "Activate Tab 9"
}
}
}
@jarettmillard
Copy link

Ctrl+9 should activate the last tab instead of the 9th tab to match the behaviour of Alt+9.

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