diff --git a/package.json b/package.json index 8c4f8ba..f33021d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/background/index.ts b/src/background/index.ts index 037a62f..bb37da1 100644 --- a/src/background/index.ts +++ b/src/background/index.ts @@ -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: '', // 禁用弹出页面 + }) + } + } +})