forked from refined-github/refined-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
56 lines (51 loc) · 1.45 KB
/
background.js
File metadata and controls
56 lines (51 loc) · 1.45 KB
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
51
52
53
54
55
56
import OptionsSync from 'webext-options-sync';
import domainPermissionToggle from 'webext-domain-permission-toggle';
import dynamicContentScripts from 'webext-dynamic-content-scripts';
// Define defaults
new OptionsSync().define({
defaults: {
disabledFeatures: '',
customCSS: '',
logging: false
},
migrations: [
// Migration example:
// options => {
// // #1200
// options.disabledFeatures = options.disabledFeatures.replace('extend-issue-status-label', 'extend-status-labels');
// },
OptionsSync.migrations.removeUnused
]
});
browser.runtime.onMessage.addListener(async message => {
if (!message || message.action !== 'openAllInTabs') {
return;
}
const [currentTab] = await browser.tabs.query({currentWindow: true, active: true});
for (const [i, url] of message.urls.entries()) {
browser.tabs.create({
url,
index: currentTab.index + i + 1,
active: false
});
}
});
browser.runtime.onInstalled.addListener(async ({reason}) => {
// Cleanup old key
// TODO: remove in the future
browser.storage.local.remove('userWasNotified');
// Only notify on install
if (reason === 'install') {
const {installType} = await browser.management.getSelf();
if (installType === 'development') {
return;
}
browser.tabs.create({
url: 'https://github.com/sindresorhus/refined-github/issues/1137',
active: false
});
}
});
// GitHub Enterprise support
dynamicContentScripts.addToFutureTabs();
domainPermissionToggle.addContextMenu();