Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/service/content/gm_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/app/service/service_worker/gm_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,8 @@ export default class GMApi {
@PermissionVerify.API()
async GM_download(request: Request, sender: GetSender) {
const params = <GMTypes.DownloadDetails>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,
Expand Down
26 changes: 22 additions & 4 deletions src/template/scriptcat.d.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 };
Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/types/scriptcat.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 };
Expand Down