-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackground.js
More file actions
26 lines (20 loc) · 761 Bytes
/
background.js
File metadata and controls
26 lines (20 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';
// ----------------- keyboard shortcuts --------------------
chrome.commands.onCommand.addListener(command => {
chrome.tabs.query({currentWindow: true}, tabs => { // get the active tab
let activeId, previousId, nextId;
for (let i = 0, len = tabs.length; i < len; i++) {
if (tabs[i].active) {
activeId = tabs[i].id;
previousId = tabs[i-1] && tabs[i-1].id;
nextId = tabs[i+1] && tabs[i+1].id;
break;
}
}
switch (command) {
case 'close': chrome.tabs.remove(activeId); break;
case 'previous': previousId && chrome.tabs.update(previousId, {active: true}); break;
case 'next': nextId && chrome.tabs.update(nextId, {active: true}); break;
}
});
});