Skip to content

Commit 3d49376

Browse files
committed
🐛 修复GM_cookie.set操作 #520
1 parent 4e91b36 commit 3d49376

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/app/service/content/gm_api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const GM_cookie = (
2727
details: GMTypes.CookieDetails,
2828
done: (cookie: GMTypes.Cookie[] | any, error: any | undefined) => void
2929
) => {
30-
// 如果url和域名都没有,自动填充当前url
31-
if (!details.url && !details.domain) {
30+
// 如果没有url,自动填充当前url
31+
if (!details.url) {
3232
details.url = window.location.href;
3333
}
3434
a.sendMessage("GM_cookie", [action, details])

src/app/service/service_worker/gm_api.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ export default class GMApi {
164164
return true;
165165
}
166166
const detail = <GMTypes.CookieDetails>request.params[1];
167-
if (!detail.url && !detail.domain) {
168-
throw new Error("there must be one of url or domain");
167+
if (!detail.url) {
168+
throw new Error("there must be one of url");
169169
}
170170
let url: URL = <URL>{};
171171
if (detail.url) {
@@ -211,8 +211,8 @@ export default class GMApi {
211211
if (detail.domain) {
212212
detail.domain = detail.domain.trim();
213213
}
214-
if (!detail.url && !detail.domain) {
215-
throw new Error("there must be one of url or domain");
214+
if (!detail.url) {
215+
throw new Error("there must be one of url");
216216
}
217217
if (typeof detail.partitionKey !== "object" || detail.partitionKey == null) {
218218
detail.partitionKey = {};
@@ -258,8 +258,8 @@ export default class GMApi {
258258
break;
259259
}
260260
case "set": {
261-
if (!detail.url || !detail.name) {
262-
throw new Error("set operation must have name and value");
261+
if (!detail.url || !detail.name || !detail.value) {
262+
throw new Error("set operation must have url, name and value");
263263
}
264264
await chrome.cookies.set({
265265
url: detail.url,

0 commit comments

Comments
 (0)