-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
background.js
58 lines (54 loc) · 1.63 KB
/
background.js
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
57
58
import OptionsSync from 'webext-options-sync';
import domainPermissionToggle from 'webext-domain-permission-toggle';
import dynamicContentScripts from 'webext-dynamic-content-scripts';
import './libs/cache';
// Define defaults
new OptionsSync().define({
defaults: {
disabledFeatures: '',
customCSS: '',
personalToken: '',
logging: false
},
migrations: [
options => {
options.disabledFeatures = options.disabledFeatures
.replace('display-issue-suggestions', '') // #1611
.replace('open-all-selected', 'batch-open-issues') // #1402
.replace('copy-file-path', '') // #1628
.replace('bypass-checks-travis', 'bypass-checks') // #1693
.replace(/^add-(.+)-to-(profile|comments|comment-fields|emojis)$/, '$2-$1') // #1719
.replace(/^add-/, ''); // #1719
},
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}) => {
// 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();