-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
127 lines (124 loc) · 2.26 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
const RULES = [
{
from: "fb",
dest: "https://facebook.com",
},
{
from: "b",
dest: "https://teamblind.com",
},
{
from: "mk",
dest: "https://mangakakalot.com",
},
{
from: "mg",
dest: "https://truyenqqto.com",
},
{
from: "mf",
dest: "https://ww1.mangafreak.me",
},
{
from: "anime",
dest: "https://kissanimefree.cc/trending-animes",
},
{
from: "gh",
dest: "https://github.com",
},
{
from: "cf",
dest: "https://codeforces.com",
},
{
from: "w",
dest: "https://docs.google.com",
},
{
from: "doc",
dest: "https://docs.google.com",
},
{
from: "sheet",
dest: "https://sheets.google.com",
},
{
from: "slide",
dest: "https://slides.google.com",
},
{
from: "cloud",
dest: "https://console.cloud.google.com",
},
{
from: "news",
dest: "https://news.google.com",
},
{
from: "c",
dest: "https://calendar.google.com",
},
{
from: "y",
dest: "https://youtube.com",
},
{
from: "t",
dest: "https://translate.google.com/?sl=de&tl=en&op=translate",
},
{
from: "vi",
dest: "https://translate.google.com/?tl=vi&op=translate",
},
{
from: "en",
dest: "https://translate.google.com/?tl=en&op=translate",
},
{
from: "de",
dest: "https://translate.google.com/?tl=de&op=translate",
},
{
from: "oald",
dest: "https://www.oxfordlearnersdictionaries.com",
},
{
from: "ldoce",
dest: "https://www.ldoceonline.com",
},
{
from: "m",
dest: "https://gmail.com",
},
{
from: "cs",
dest: "https://sourcegraph.com/search?&patternType=regexp&case=yes",
},
{
from: "ai",
dest: "https://chat.openai.com/chat",
},
];
const FORMATTED_RULES = RULES.map((rule, index) => ({
id: index + 1,
priority: 1,
action: {
type: "redirect",
redirect: {
url: rule.dest,
},
},
condition: {
urlFilter: "http://" + rule.from + "/",
resourceTypes: ["main_frame"],
},
}));
(async () => {
const oldRules = await chrome.declarativeNetRequest.getDynamicRules();
const oldRuleIds = oldRules.map((rule) => rule.id);
await chrome.declarativeNetRequest.updateDynamicRules({
removeRuleIds: oldRuleIds,
addRules: FORMATTED_RULES,
});
})();