From 5bd6a7a2d8da8647436686cdc4d2145d2ae562bb Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Mon, 30 Jun 2025 07:55:21 +0900 Subject: [PATCH 1/2] =?UTF-8?q?downloadMode=20=E5=9C=A8=20GM=5Finfo=20?= =?UTF-8?q?=E7=B8=BD=E6=98=AF=20"browser"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/types/scriptcat.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/scriptcat.d.ts b/src/types/scriptcat.d.ts index 386c45c14..4186e938b 100644 --- a/src/types/scriptcat.d.ts +++ b/src/types/scriptcat.d.ts @@ -31,7 +31,7 @@ declare const GM_info: { userConfig?: UserConfig; userConfigStr?: string; // isIncognito: boolean; - // downloadMode: "native" | "disabled" | "browser"; + downloadMode: "browser"; // "native" | "disabled" | "browser"; script: { author?: string; description?: string; From 6c6e8fdde7e0208eba36ee40eda94ceabee0e5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=80=E4=B9=8B?= Date: Mon, 30 Jun 2025 08:35:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20=E5=A4=84=E7=90=86downloadMo?= =?UTF-8?q?de?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/service/content/gm_api.ts | 2 +- src/app/service/service_worker/gm_api.ts | 4 ++-- src/template/scriptcat.d.tpl | 26 ++++++++++++++++++++---- src/types/scriptcat.d.ts | 4 ++-- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/app/service/content/gm_api.ts b/src/app/service/content/gm_api.ts index 908407fbd..e75704513 100644 --- a/src/app/service/content/gm_api.ts +++ b/src/app/service/content/gm_api.ts @@ -684,7 +684,7 @@ export default class GMApi { this.connect("GM_download", [ { method: details.method, - downloadMethod: details.downloadMethod || "xhr", // 默认使用xhr下载 + downloadMode: details.downloadMode || "native", // 默认使用xhr下载 url: details.url, name: details.name, headers: details.headers, diff --git a/src/app/service/service_worker/gm_api.ts b/src/app/service/service_worker/gm_api.ts index f9da3fd42..e80a115ff 100644 --- a/src/app/service/service_worker/gm_api.ts +++ b/src/app/service/service_worker/gm_api.ts @@ -991,8 +991,8 @@ export default class GMApi { @PermissionVerify.API() async GM_download(request: Request, sender: GetSender) { const params = request.params[0]; - // blob本地文件或显示指定downloadMethod为"browser"则直接下载 - if (params.url.startsWith("blob:") || params.downloadMethod === "browser") { + // blob本地文件或显示指定downloadMode为"browser"则直接下载 + if (params.url.startsWith("blob:") || params.downloadMode === "browser") { chrome.downloads.download( { url: params.url, diff --git a/src/template/scriptcat.d.tpl b/src/template/scriptcat.d.tpl index c6e0bb502..b354f6cb8 100644 --- a/src/template/scriptcat.d.tpl +++ b/src/template/scriptcat.d.tpl @@ -31,7 +31,7 @@ declare const GM_info: { userConfig?: UserConfig; userConfigStr?: string; // isIncognito: boolean; - // downloadMode: "native" | "disabled" | "browser"; + downloadMode: "native"; // "native" | "disabled" | "browser"; script: { author?: string; description?: string; @@ -425,7 +425,7 @@ declare namespace GMTypes { interface DownloadDetails { method?: "GET" | "POST"; - downloadMethod?: "xhr" | "browser"; + downloadMode?: "native" | "browser"; url: string; name: string; headers?: { [key: string]: string }; @@ -444,8 +444,24 @@ declare namespace GMTypes { id: string; } - type NotificationOnClick = (this: NotificationThis, id: string, index?: number) => unknown; - type NotificationOnDone = (this: NotificationThis, user: boolean) => unknown; + type NotificationOnClickEvent = { + event: "click" | "buttonClick"; + id: string; + isButtonClick: boolean; + buttonClickIndex: number | undefined; + byUser: boolean | undefined; + preventDefault: () => void; + highlight: NotificationDetails["highlight"]; + image: NotificationDetails["image"]; + silent: NotificationDetails["silent"]; + tag: NotificationDetails["tag"]; + text: NotificationDetails["tag"]; + timeout: NotificationDetails["timeout"]; + title: NotificationDetails["title"]; + url: NotificationDetails["url"]; + }; + type NotificationOnClick = (this: NotificationThis, event: NotificationOnClickEvent) => unknown; + type NotificationOnDone = (this: NotificationThis, user?: boolean) => unknown; interface NotificationButton { title: string; @@ -455,10 +471,12 @@ declare namespace GMTypes { interface NotificationDetails { text?: string; title?: string; + tag?: string; image?: string; highlight?: boolean; silent?: boolean; timeout?: number; + url?: string; onclick?: NotificationOnClick; ondone?: NotificationOnDone; progress?: number; diff --git a/src/types/scriptcat.d.ts b/src/types/scriptcat.d.ts index 4186e938b..b354f6cb8 100644 --- a/src/types/scriptcat.d.ts +++ b/src/types/scriptcat.d.ts @@ -31,7 +31,7 @@ declare const GM_info: { userConfig?: UserConfig; userConfigStr?: string; // isIncognito: boolean; - downloadMode: "browser"; // "native" | "disabled" | "browser"; + downloadMode: "native"; // "native" | "disabled" | "browser"; script: { author?: string; description?: string; @@ -425,7 +425,7 @@ declare namespace GMTypes { interface DownloadDetails { method?: "GET" | "POST"; - downloadMethod?: "xhr" | "browser"; + downloadMode?: "native" | "browser"; url: string; name: string; headers?: { [key: string]: string };