Skip to content

Commit 9c016db

Browse files
authored
🐛 固定 downloadMode 在 GM_info 總是 "native" (#476)
1 parent 948e113 commit 9c016db

4 files changed

Lines changed: 27 additions & 9 deletions

File tree

src/app/service/content/gm_api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ export default class GMApi {
684684
this.connect("GM_download", [
685685
{
686686
method: details.method,
687-
downloadMethod: details.downloadMethod || "xhr", // 默认使用xhr下载
687+
downloadMode: details.downloadMode || "native", // 默认使用xhr下载
688688
url: details.url,
689689
name: details.name,
690690
headers: details.headers,

src/app/service/service_worker/gm_api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,8 +991,8 @@ export default class GMApi {
991991
@PermissionVerify.API()
992992
async GM_download(request: Request, sender: GetSender) {
993993
const params = <GMTypes.DownloadDetails>request.params[0];
994-
// blob本地文件或显示指定downloadMethod为"browser"则直接下载
995-
if (params.url.startsWith("blob:") || params.downloadMethod === "browser") {
994+
// blob本地文件或显示指定downloadMode为"browser"则直接下载
995+
if (params.url.startsWith("blob:") || params.downloadMode === "browser") {
996996
chrome.downloads.download(
997997
{
998998
url: params.url,

src/template/scriptcat.d.tpl

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ declare const GM_info: {
3131
userConfig?: UserConfig;
3232
userConfigStr?: string;
3333
// isIncognito: boolean;
34-
// downloadMode: "native" | "disabled" | "browser";
34+
downloadMode: "native"; // "native" | "disabled" | "browser";
3535
script: {
3636
author?: string;
3737
description?: string;
@@ -425,7 +425,7 @@ declare namespace GMTypes {
425425

426426
interface DownloadDetails {
427427
method?: "GET" | "POST";
428-
downloadMethod?: "xhr" | "browser";
428+
downloadMode?: "native" | "browser";
429429
url: string;
430430
name: string;
431431
headers?: { [key: string]: string };
@@ -444,8 +444,24 @@ declare namespace GMTypes {
444444
id: string;
445445
}
446446

447-
type NotificationOnClick = (this: NotificationThis, id: string, index?: number) => unknown;
448-
type NotificationOnDone = (this: NotificationThis, user: boolean) => unknown;
447+
type NotificationOnClickEvent = {
448+
event: "click" | "buttonClick";
449+
id: string;
450+
isButtonClick: boolean;
451+
buttonClickIndex: number | undefined;
452+
byUser: boolean | undefined;
453+
preventDefault: () => void;
454+
highlight: NotificationDetails["highlight"];
455+
image: NotificationDetails["image"];
456+
silent: NotificationDetails["silent"];
457+
tag: NotificationDetails["tag"];
458+
text: NotificationDetails["tag"];
459+
timeout: NotificationDetails["timeout"];
460+
title: NotificationDetails["title"];
461+
url: NotificationDetails["url"];
462+
};
463+
type NotificationOnClick = (this: NotificationThis, event: NotificationOnClickEvent) => unknown;
464+
type NotificationOnDone = (this: NotificationThis, user?: boolean) => unknown;
449465

450466
interface NotificationButton {
451467
title: string;
@@ -455,10 +471,12 @@ declare namespace GMTypes {
455471
interface NotificationDetails {
456472
text?: string;
457473
title?: string;
474+
tag?: string;
458475
image?: string;
459476
highlight?: boolean;
460477
silent?: boolean;
461478
timeout?: number;
479+
url?: string;
462480
onclick?: NotificationOnClick;
463481
ondone?: NotificationOnDone;
464482
progress?: number;

src/types/scriptcat.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ declare const GM_info: {
3131
userConfig?: UserConfig;
3232
userConfigStr?: string;
3333
// isIncognito: boolean;
34-
// downloadMode: "native" | "disabled" | "browser";
34+
downloadMode: "native"; // "native" | "disabled" | "browser";
3535
script: {
3636
author?: string;
3737
description?: string;
@@ -425,7 +425,7 @@ declare namespace GMTypes {
425425

426426
interface DownloadDetails {
427427
method?: "GET" | "POST";
428-
downloadMethod?: "xhr" | "browser";
428+
downloadMode?: "native" | "browser";
429429
url: string;
430430
name: string;
431431
headers?: { [key: string]: string };

0 commit comments

Comments
 (0)