Skip to content

Commit

Permalink
2.2.3
Browse files Browse the repository at this point in the history
rebuild 2.2.2
  • Loading branch information
ckx000 committed Feb 1, 2025
1 parent ef8494d commit c9fac92
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Docker 容器: <https://hub.docker.com/r/qdtoday/qd>
> 同时在该用户的chrome设置里-隐私设置和安全性-cookie及其他网站数据-关闭所有窗口时清除cookie及网站数据 处打勾即可。
## 更新内容
- ### v2.2.2
- ### v2.2.3

添加空cookies的处理

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
},
"permissions": [ "cookies", "storage", "scripting", "activeTab" ],
"update_url": "https://clients2.google.com/service/update2/crx",
"version": "2.2.2"
"version": "2.2.3"
}
38 changes: 18 additions & 20 deletions service_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,25 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {//tab页面
option2["domain"] = tempurl.hostname;
}
console.log(option1,option2);
var obj = {};
chrome.cookies.getAll(option1, function(cookies) {
//console.log(cookies);
for (var i in cookies) {
var cookie = cookies[i];
obj[cookie.name] = cookie.value;
}
});
//查2次//查漏补缺,以防漏掉某些主域名cookies
chrome.cookies.getAll(option2, function(cookies) {
//console.log(cookies);
for (var i in cookies) {
var cookie = cookies[i];
obj[cookie.name] = cookie.value;
}
if(Object.keys(obj).length == 0){
obj={"error":"cookies值为空,清检查是否已登陆"};
}
port.postMessage(obj);
console.log(obj);
const obj = {};
const getCookies = (options) => new Promise(resolve => {
chrome.cookies.getAll(options, resolve);
});
Promise.all([getCookies(option1), getCookies(option2)])
.then(([cookies1, cookies2]) => {
const processCookie = cookie => obj[cookie.name] = cookie.value;
cookies1.forEach(processCookie);
cookies2.forEach(processCookie);
const result = Object.keys(obj).length === 0
? { error: "cookies值为空,请检查是否已登陆" }
: obj;
port.postMessage(result);
console.log(result);
})
.catch(error => {
console.error('Cookie获取失败:', error);
port.postMessage({ error: "获取cookies时发生错误" });
});
}
});
});
Expand Down

0 comments on commit c9fac92

Please sign in to comment.