first commit
This commit is contained in:
31
background.js
Normal file
31
background.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Background Service Worker
|
||||
*/
|
||||
|
||||
// 监听来自 content script 的消息
|
||||
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
if (message.type === 'DECRYPTED_REQUEST') {
|
||||
// 保存解密记录到 storage
|
||||
chrome.storage.local.get(['decryptedRequests'], (result) => {
|
||||
const requests = result.decryptedRequests || [];
|
||||
requests.push(message.data);
|
||||
|
||||
// 只保留最近1000条
|
||||
if (requests.length > 1000) {
|
||||
requests.shift();
|
||||
}
|
||||
|
||||
chrome.storage.local.set({ decryptedRequests: requests });
|
||||
});
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
// 监听标签页更新
|
||||
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
|
||||
if (changeInfo.status === 'complete') {
|
||||
// 页面加载完成,可以注入脚本
|
||||
console.log('页面加载完成:', tab.url);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user