blob: 56f86eb14e25edca5bd05f9b65d977e7a6766ad0 (
plain) (
blame)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
const closeTab = (id) => {
browser.tabs.remove(id);
};
const reopenTab = () => {
browser.sessions.getRecentlyClosed({
maxResults: 1
}).then((sessions) => {
if (sessions.length === 0) {
return;
}
let session = sessions[0];
if (session.tab) {
browser.sessions.restore(session.tab.sessionId);
} else {
browser.sessions.restore(session.window.sessionId);
}
});
};
const selectPrevTab = (current, count) => {
chrome.tabs.query({ currentWindow: true }, (tabs) => {
if (tabs.length < 2) {
return;
}
let select = (current - count) % tabs.length
let id = tabs[select].id;
chrome.tabs.update(id, { active: true })
});
};
const selectNextTab = (current, count) => {
chrome.tabs.query({ currentWindow: true }, (tabs) => {
if (tabs.length < 2) {
return;
}
let select = (current + count + tabs.length) % tabs.length
let id = tabs[select].id;
chrome.tabs.update(id, { active: true })
});
};
const reload = (current, cache) => {
browser.tabs.reload(
current.id,
{ bypassCache: cache }
);
};
export { closeTab, reopenTab, selectNextTab, selectPrevTab, reload };
|