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 386c45c14..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: "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 };