Skip to content

Commit 2092772

Browse files
xupeaxupea
authored andcommitted
feat: make sure it only work under csdn blog website
1 parent 172dd7d commit 2092772

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "clean-csdn",
33
"displayName": "Clean CSDN Blog",
4-
"version": "1.0.3",
4+
"version": "1.0.4",
55
"author": "Peter Xu",
66
"description": "Just make csdn blog as clean as it should be",
77
"type": "module",

src/background/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,24 @@ console.log('background is running')
33
chrome.runtime.onMessage.addListener((request) => {
44
chrome.tabs.reload(request.id)
55
})
6+
7+
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
8+
if (changeInfo.status === 'complete') {
9+
let url = new URL(tab.url!)
10+
let domain = url.hostname
11+
12+
if (domain === 'blog.csdn.net') {
13+
// 启用弹出页
14+
chrome.action.setPopup({
15+
tabId: tabId,
16+
popup: 'popup.html', // 指定你的弹出页面
17+
})
18+
} else {
19+
// 禁用弹出页,可以设置为空字符串或不设置popup属性
20+
chrome.action.setPopup({
21+
tabId: tabId,
22+
popup: '', // 禁用弹出页面
23+
})
24+
}
25+
}
26+
})

0 commit comments

Comments
 (0)