Skip to content

Commit 772c58e

Browse files
committed
version 1.0
1 parent 8d6e5e7 commit 772c58e

File tree

3 files changed

+48
-44
lines changed

3 files changed

+48
-44
lines changed

background.js

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
'use strict'
1+
'use strict';
22

33
const kTST_ID = 'treestyletab@piro.sakura.ne.jp';
44

55
async function registerToTST() {
6-
try {
7-
const self = await browser.management.getSelf();
6+
try {
7+
const self = await browser.management.getSelf();
88

9-
let success = await browser.runtime.sendMessage(kTST_ID, {
10-
type: 'register-self',
11-
name: self.id,
12-
});
9+
let success = await browser.runtime.sendMessage(kTST_ID, {
10+
type: 'register-self',
11+
name: self.id,
12+
});
1313

14-
return success;
15-
}
16-
catch(e) {
17-
// TST is not available
18-
}
14+
return success;
15+
} catch (e) {
16+
// TST is not available
17+
}
1918
}
2019

2120
browser.runtime.onMessageExternal.addListener((aMessage, aSender) => {
@@ -30,43 +29,43 @@ browser.runtime.onMessageExternal.addListener((aMessage, aSender) => {
3029
}
3130
});
3231

33-
registerToTST().then((res) => {
34-
browser.tabs.onActivated.addListener(callback);
35-
browser.tabs.onCreated.addListener(callback);
36-
browser.tabs.onRemoved.addListener(callback);
32+
registerToTST().then(res => {
33+
browser.tabs.onActivated.addListener(callback);
34+
browser.tabs.onCreated.addListener(callback);
35+
browser.tabs.onRemoved.addListener(callback);
3736
});
3837

3938
async function getSortedWinTabs() {
40-
const tabs = await browser.tabs.query({ currentWindow: true })
41-
tabs.sort((a, b) => (a.lastAccessed < b.lastAccessed ? 1 : -1))
42-
return tabs
39+
const tabs = await browser.tabs.query({ currentWindow: true });
40+
tabs.sort((a, b) => (a.lastAccessed < b.lastAccessed ? 1 : -1));
41+
return tabs;
4342
}
4443

4544
async function wait(ms) {
46-
return new Promise(resolve => {
47-
setTimeout(resolve, ms);
48-
});
45+
return new Promise(resolve => {
46+
setTimeout(resolve, ms);
47+
});
4948
}
5049

5150
async function callback() {
52-
await wait(300);
51+
await wait(300);
5352

54-
const sortedTabs = await getSortedWinTabs();
53+
const sortedTabs = await getSortedWinTabs();
5554

56-
const allTabsIDs = sortedTabs.reduce((allIDs, currentTab) => {
57-
allIDs.push(currentTab.id);
58-
return allIDs;
59-
}, []);
55+
const allTabsIDs = sortedTabs.reduce((allIDs, currentTab) => {
56+
allIDs.push(currentTab.id);
57+
return allIDs;
58+
}, []);
6059

61-
browser.runtime.sendMessage(kTST_ID, {
62-
type: 'remove-tab-state',
63-
tabs: allTabsIDs,
64-
state: 'last-active',
65-
});
60+
browser.runtime.sendMessage(kTST_ID, {
61+
type: 'remove-tab-state',
62+
tabs: allTabsIDs,
63+
state: 'last-active',
64+
});
6665

67-
browser.runtime.sendMessage(kTST_ID, {
68-
type: 'add-tab-state',
69-
tabs: [sortedTabs[1].id],
70-
state: 'last-active',
71-
});
66+
browser.runtime.sendMessage(kTST_ID, {
67+
type: 'add-tab-state',
68+
tabs: [sortedTabs[1].id],
69+
state: 'last-active',
70+
});
7271
}

manifest.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
{
2-
"manifest_version": 2,
3-
"name": "Add Last Active Class To Tab",
4-
"version": "1.0",
2+
"manifest_version": 2,
3+
"name": "Add Last Active Class To Tab",
4+
"version": "1.0",
55

6-
"description": "Add a last-active class to a TST tab",
6+
"description": "Add a last-active class to a TST tab",
77

8-
"background" : {
9-
"scripts": ["background.js"]
8+
"background": {
9+
"scripts": ["background.js"]
10+
},
11+
"applications": {
12+
"gecko": {
13+
"id": "davidsierra@outlook.com"
1014
}
15+
}
1116
}
5.54 KB
Binary file not shown.

0 commit comments

Comments
 (0)