Skip to content

Commit

Permalink
feat: make sure it only work under csdn blog website
Browse files Browse the repository at this point in the history
  • Loading branch information
xupea authored and xupea committed Mar 21, 2024
1 parent 172dd7d commit 2092772
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "clean-csdn",
"displayName": "Clean CSDN Blog",
"version": "1.0.3",
"version": "1.0.4",
"author": "Peter Xu",
"description": "Just make csdn blog as clean as it should be",
"type": "module",
Expand Down
21 changes: 21 additions & 0 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,24 @@ console.log('background is running')
chrome.runtime.onMessage.addListener((request) => {
chrome.tabs.reload(request.id)
})

chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.status === 'complete') {
let url = new URL(tab.url!)
let domain = url.hostname

if (domain === 'blog.csdn.net') {
// 启用弹出页
chrome.action.setPopup({
tabId: tabId,
popup: 'popup.html', // 指定你的弹出页面
})
} else {
// 禁用弹出页,可以设置为空字符串或不设置popup属性
chrome.action.setPopup({
tabId: tabId,
popup: '', // 禁用弹出页面
})
}
}
})

0 comments on commit 2092772

Please sign in to comment.