Skip to content

Commit 481a52f

Browse files
committed
新增更多对 V2EX 子域名的匹配
1 parent 2974401 commit 481a52f

File tree

4 files changed

+165
-22
lines changed

4 files changed

+165
-22
lines changed

extension/manifest-firefox.json

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515

1616
"permissions": ["scripting", "contextMenus", "storage", "alarms"],
1717

18-
"host_permissions": ["https://v2ex.com/*", "https://www.v2ex.com/*", "https://cn.v2ex.com/*"],
18+
"host_permissions": [
19+
"https://v2ex.com/*",
20+
"https://www.v2ex.com/*",
21+
"https://cn.v2ex.com/*",
22+
"https://global.v2ex.com/*",
23+
"https://fast.v2ex.com/*",
24+
"https://hk.v2ex.com/*"
25+
],
1926

2027
"icons": {
2128
"16": "images/icon-16.png",
@@ -26,45 +33,90 @@
2633

2734
"content_scripts": [
2835
{
29-
"matches": ["https://v2ex.com/*", "https://www.v2ex.com/*", "https://cn.v2ex.com/*"],
36+
"matches": [
37+
"https://v2ex.com/*",
38+
"https://www.v2ex.com/*",
39+
"https://cn.v2ex.com/*",
40+
"https://global.v2ex.com/*",
41+
"https://fast.v2ex.com/*",
42+
"https://hk.v2ex.com/*"
43+
],
3044
"css": ["css/v2ex-theme-var.css", "css/v2ex-theme-default.css"],
3145
"run_at": "document_start",
3246
"all_frames": true
3347
},
3448
{
35-
"matches": ["https://v2ex.com/*", "https://www.v2ex.com/*", "https://cn.v2ex.com/*"],
49+
"matches": [
50+
"https://v2ex.com/*",
51+
"https://www.v2ex.com/*",
52+
"https://cn.v2ex.com/*",
53+
"https://global.v2ex.com/*",
54+
"https://fast.v2ex.com/*",
55+
"https://hk.v2ex.com/*"
56+
],
3657
"js": ["scripts/polyfill.js"],
3758
"run_at": "document_end",
3859
"all_frames": true
3960
},
4061
{
41-
"matches": ["https://v2ex.com/*", "https://www.v2ex.com/*", "https://cn.v2ex.com/*"],
62+
"matches": [
63+
"https://v2ex.com/*",
64+
"https://www.v2ex.com/*",
65+
"https://cn.v2ex.com/*",
66+
"https://global.v2ex.com/*",
67+
"https://fast.v2ex.com/*",
68+
"https://hk.v2ex.com/*"
69+
],
4270
"css": ["css/v2ex-effect.css"],
4371
"js": ["scripts/jquery.min.js", "scripts/common.min.js"],
4472
"all_frames": true
4573
},
4674
{
47-
"matches": ["https://v2ex.com/*", "https://www.v2ex.com/*", "https://cn.v2ex.com/*"],
75+
"matches": [
76+
"https://v2ex.com/*",
77+
"https://www.v2ex.com/*",
78+
"https://cn.v2ex.com/*",
79+
"https://global.v2ex.com/*",
80+
"https://fast.v2ex.com/*",
81+
"https://hk.v2ex.com/*"
82+
],
4883
"exclude_matches": ["*://*/t/*", "*://*/notes/*", "*://*/settings", "*://*/write"],
4984
"js": ["scripts/v2ex-home.min.js"],
5085
"all_frames": true
5186
},
5287
{
53-
"matches": ["https://v2ex.com/t/*", "https://www.v2ex.com/t/*", "https://cn.v2ex.com/t/*"],
88+
"matches": [
89+
"https://v2ex.com/t/*",
90+
"https://www.v2ex.com/t/*",
91+
"https://cn.v2ex.com/t/*",
92+
"https://global.v2ex.com/t/*",
93+
"https://fast.v2ex.com/t/*",
94+
"https://hk.v2ex.com/t/*"
95+
],
5496
"js": ["scripts/v2ex-topic.min.js"],
5597
"all_frames": true
5698
},
5799
{
58100
"matches": [
59101
"https://v2ex.com/write*",
60102
"https://www.v2ex.com/write*",
61-
"https://cn.v2ex.com/write*"
103+
"https://cn.v2ex.com/write*",
104+
"https://global.v2ex.com/write/*",
105+
"https://fast.v2ex.com/write/*",
106+
"https://hk.v2ex.com/write/*"
62107
],
63108
"js": ["scripts/v2ex-write.min.js"],
64109
"all_frames": true
65110
},
66111
{
67-
"matches": ["https://v2ex.com/*", "https://www.v2ex.com/*", "https://cn.v2ex.com/*"],
112+
"matches": [
113+
"https://v2ex.com/*",
114+
"https://www.v2ex.com/*",
115+
"https://cn.v2ex.com/*",
116+
"https://global.v2ex.com/*",
117+
"https://fast.v2ex.com/*",
118+
"https://hk.v2ex.com/*"
119+
],
68120
"js": ["scripts/toggle-icon.min.js"],
69121
"all_frames": true
70122
}
@@ -76,7 +128,14 @@
76128

77129
"web_accessible_resources": [
78130
{
79-
"matches": ["https://v2ex.com/*", "https://www.v2ex.com/*", "https://cn.v2ex.com/*"],
131+
"matches": [
132+
"https://v2ex.com/*",
133+
"https://www.v2ex.com/*",
134+
"https://cn.v2ex.com/*",
135+
"https://global.v2ex.com/*",
136+
"https://fast.v2ex.com/*",
137+
"https://hk.v2ex.com/*"
138+
],
80139
"resources": ["scripts/web_accessible_resources.min.js"]
81140
}
82141
],

extension/manifest.json

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99

1010
"permissions": ["scripting", "contextMenus", "storage", "alarms", "sidePanel"],
1111

12-
"host_permissions": ["https://v2ex.com/*", "https://www.v2ex.com/*", "https://cn.v2ex.com/*"],
12+
"host_permissions": [
13+
"https://v2ex.com/*",
14+
"https://www.v2ex.com/*",
15+
"https://cn.v2ex.com/*",
16+
"https://global.v2ex.com/*",
17+
"https://fast.v2ex.com/*",
18+
"https://hk.v2ex.com/*"
19+
],
1320

1421
"icons": {
1522
"16": "images/icon-16.png",
@@ -20,47 +27,92 @@
2027

2128
"content_scripts": [
2229
{
23-
"matches": ["https://v2ex.com/*", "https://www.v2ex.com/*", "https://cn.v2ex.com/*"],
30+
"matches": [
31+
"https://v2ex.com/*",
32+
"https://www.v2ex.com/*",
33+
"https://cn.v2ex.com/*",
34+
"https://global.v2ex.com/*",
35+
"https://fast.v2ex.com/*",
36+
"https://hk.v2ex.com/*"
37+
],
2438
"css": ["css/v2ex-theme-var.css", "css/v2ex-theme-default.css"],
2539
"run_at": "document_start",
2640
"all_frames": true
2741
},
2842
{
29-
"matches": ["https://v2ex.com/*", "https://www.v2ex.com/*", "https://cn.v2ex.com/*"],
43+
"matches": [
44+
"https://v2ex.com/*",
45+
"https://www.v2ex.com/*",
46+
"https://cn.v2ex.com/*",
47+
"https://global.v2ex.com/*",
48+
"https://fast.v2ex.com/*",
49+
"https://hk.v2ex.com/*"
50+
],
3051
"js": ["scripts/polyfill.js"],
3152
"run_at": "document_end",
3253
"all_frames": true
3354
},
3455

3556
{
36-
"matches": ["https://v2ex.com/*", "https://www.v2ex.com/*", "https://cn.v2ex.com/*"],
57+
"matches": [
58+
"https://v2ex.com/*",
59+
"https://www.v2ex.com/*",
60+
"https://cn.v2ex.com/*",
61+
"https://global.v2ex.com/*",
62+
"https://fast.v2ex.com/*",
63+
"https://hk.v2ex.com/*"
64+
],
3765
"css": ["css/v2ex-effect.css"],
3866
"js": ["scripts/jquery.min.js", "scripts/common.min.js"],
3967
"all_frames": true
4068
},
4169
{
42-
"matches": ["https://v2ex.com/*", "https://www.v2ex.com/*", "https://cn.v2ex.com/*"],
70+
"matches": [
71+
"https://v2ex.com/*",
72+
"https://www.v2ex.com/*",
73+
"https://cn.v2ex.com/*",
74+
"https://global.v2ex.com/*",
75+
"https://fast.v2ex.com/*",
76+
"https://hk.v2ex.com/*"
77+
],
4378
"exclude_matches": ["*://*/t/*", "*://*/notes/*", "*://*/settings", "*://*/write"],
4479
"js": ["scripts/jquery.min.js", "scripts/v2ex-home.min.js"],
4580
"all_frames": true
4681
},
4782
{
48-
"matches": ["https://v2ex.com/t/*", "https://www.v2ex.com/t/*", "https://cn.v2ex.com/t/*"],
83+
"matches": [
84+
"https://v2ex.com/t/*",
85+
"https://www.v2ex.com/t/*",
86+
"https://cn.v2ex.com/t/*",
87+
"https://global.v2ex.com/t/*",
88+
"https://fast.v2ex.com/t/*",
89+
"https://hk.v2ex.com/t/*"
90+
],
4991
"js": ["scripts/jquery.min.js", "scripts/v2ex-topic.min.js"],
5092
"all_frames": true
5193
},
5294
{
5395
"matches": [
5496
"https://v2ex.com/write*",
5597
"https://www.v2ex.com/write*",
56-
"https://cn.v2ex.com/write*"
98+
"https://cn.v2ex.com/write*",
99+
"https://global.v2ex.com/write/*",
100+
"https://fast.v2ex.com/write/*",
101+
"https://hk.v2ex.com/write/*"
57102
],
58103
"js": ["scripts/jquery.min.js", "scripts/v2ex-write.min.js"],
59104
"all_frames": true
60105
},
61106

62107
{
63-
"matches": ["https://v2ex.com/*", "https://www.v2ex.com/*", "https://cn.v2ex.com/*"],
108+
"matches": [
109+
"https://v2ex.com/*",
110+
"https://www.v2ex.com/*",
111+
"https://cn.v2ex.com/*",
112+
"https://global.v2ex.com/*",
113+
"https://fast.v2ex.com/*",
114+
"https://hk.v2ex.com/*"
115+
],
64116
"js": ["scripts/toggle-icon.min.js"],
65117
"all_frames": true
66118
}
@@ -72,7 +124,14 @@
72124

73125
"web_accessible_resources": [
74126
{
75-
"matches": ["https://v2ex.com/*", "https://www.v2ex.com/*", "https://cn.v2ex.com/*"],
127+
"matches": [
128+
"https://v2ex.com/*",
129+
"https://www.v2ex.com/*",
130+
"https://cn.v2ex.com/*",
131+
"https://global.v2ex.com/*",
132+
"https://fast.v2ex.com/*",
133+
"https://hk.v2ex.com/*"
134+
],
76135
"resources": ["scripts/web_accessible_resources.min.js"]
77136
}
78137
],

src/background/main.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ chrome.contextMenus.removeAll(() => {
3838
const runEnv = getRunEnv()
3939

4040
chrome.contextMenus.create({
41-
documentUrlPatterns: ['https://v2ex.com/*', 'https://www.v2ex.com/*', 'https://cn.v2ex.com/*'],
41+
documentUrlPatterns: [
42+
'https://v2ex.com/*',
43+
'https://www.v2ex.com/*',
44+
'https://cn.v2ex.com/*',
45+
'https://global.v2ex.com/*',
46+
'https://fast.v2ex.com/*',
47+
'https://hk.v2ex.com/*',
48+
],
4249
contexts: ['page'],
4350
title: 'V2EX Polish',
4451
visible: true,
@@ -51,6 +58,9 @@ chrome.contextMenus.removeAll(() => {
5158
'https://v2ex.com/*',
5259
'https://www.v2ex.com/*',
5360
'https://cn.v2ex.com/*',
61+
'https://global.v2ex.com/*',
62+
'https://fast.v2ex.com/*',
63+
'https://hk.v2ex.com/*',
5464
],
5565
contexts: ['page'],
5666
title: '选项设置',
@@ -64,6 +74,9 @@ chrome.contextMenus.removeAll(() => {
6474
'https://v2ex.com/t/*',
6575
'https://www.v2ex.com/t/*',
6676
'https://cn.v2ex.com/t/*',
77+
'https://global.v2ex.com/t/*',
78+
'https://fast.v2ex.com/t/*',
79+
'https://hk.v2ex.com/t/*',
6780
],
6881
contexts: ['page'],
6982
title: '解析本页 Base64',
@@ -76,6 +89,9 @@ chrome.contextMenus.removeAll(() => {
7689
'https://v2ex.com/t/*',
7790
'https://www.v2ex.com/t/*',
7891
'https://cn.v2ex.com/t/*',
92+
'https://global.v2ex.com/t/*',
93+
'https://fast.v2ex.com/t/*',
94+
'https://hk.v2ex.com/t/*',
7995
],
8096
contexts: ['page'],
8197
title: '添加进稍后阅读',
@@ -126,7 +142,10 @@ chrome.tabs.onUpdated.addListener((tabId, _, tab) => {
126142
if (
127143
url.origin === 'https://www.v2ex.com' ||
128144
url.origin === 'https://v2ex.com' ||
129-
url.origin === 'https://cn.v2ex.com'
145+
url.origin === 'https://cn.v2ex.com' ||
146+
url.origin === 'https://global.v2ex.com' ||
147+
url.origin === 'https://fast.v2ex.com' ||
148+
url.origin === 'https://hk.v2ex.com'
130149
) {
131150
await chrome.sidePanel.setOptions({
132151
tabId,

src/user-scripts/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ document.addEventListener('DOMContentLoaded', () => {
1515
const commonRegex = patternToRegex(
1616
'https://v2ex.com/*',
1717
'https://www.v2ex.com/*',
18-
'https://cn.v2ex.com/*'
18+
'https://cn.v2ex.com/*',
19+
'https://global.v2ex.com/*',
20+
'https://fast.v2ex.com/*',
21+
'https://hk.v2ex.com/*'
1922
)
2023
const topicRegex = patternToRegex(
2124
'https://v2ex.com/t/*',
2225
'https://www.v2ex.com/t/*',
23-
'https://cn.v2ex.com/t/*'
26+
'https://cn.v2ex.com/t/*',
27+
'https://global.v2ex.com/t/*',
28+
'https://fast.v2ex.com/t/*',
29+
'https://hk.v2ex.com/t/*'
2430
)
2531
const writeRegex = patternToRegex(
2632
'https://v2ex.com/write*',

0 commit comments

Comments
 (0)