完善quickcomposer.browser的声明文件

This commit is contained in:
fofolee 2025-03-20 10:33:58 +08:00
parent 75c7d1ec50
commit 3cec2f94f2

View File

@ -2401,81 +2401,113 @@ interface quickcomposerApi {
* *
* @param tab * @param tab
* @param options * @param options
* @param options.format
* @param options.quality (jpeg)
* @param options.savePath
* @param options.selector
*/ */
captureScreenshot( captureScreenshot(
tab: { tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
by?: "active" | "url" | "title" | "id";
searchValue?: string;
},
options?: { options?: {
type?: "png" | "jpeg"; // 图片类型 format?: "png" | "jpeg";
quality?: number; // 图片质量(仅jpeg) quality?: number;
fullPage?: boolean; // 是否截取完整页面 savePath?: string;
clip?: { selector?: string;
// 裁剪区域
x: number;
y: number;
width: number;
height: number;
};
encoding?: "base64" | "binary"; // 编码方式
path?: string; // 保存路径
} }
): Promise<string>; ): Promise<string>;
/** /**
* URL * URL
* @param tab
*/ */
getUrl(): Promise<string>; getUrl(tab: {
by?: "active" | "url" | "title" | "id";
searchValue?: string;
}): Promise<string>;
/** /**
* URL * URL
* @param tab
* @param url URL * @param url URL
*/ */
setUrl(url: string): Promise<void>; setUrl(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
url: string
): Promise<void>;
/** /**
* JavaScript代码 * JavaScript代码
* @param tab
* @param script JavaScript代码 * @param script JavaScript代码
* @param args
*/ */
executeScript(script: string): Promise<any>; executeScript(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
script: string,
args?: Record<string, any>
): Promise<any>;
/** /**
* *
* @param tab
* @param selector CSS选择器 * @param selector CSS选择器
*/ */
clickElement(selector: string): Promise<void>; clickElement(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
selector: string
): Promise<void>;
/** /**
* *
* @param tab
* @param selector CSS选择器 * @param selector CSS选择器
* @param text * @param text
*/ */
inputText(selector: string, text: string): Promise<void>; inputText(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
selector: string,
text: string
): Promise<void>;
/** /**
* *
* @param tab
* @param selector CSS选择器 * @param selector CSS选择器
*/ */
getText(selector: string): Promise<string>; getText(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
selector: string
): Promise<string>;
/** /**
* HTML内容 * HTML内容
* @param tab
* @param selector CSS选择器 * @param selector CSS选择器
*/ */
getHtml(selector: string): Promise<string>; getHtml(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
selector: string
): Promise<string>;
/** /**
* *
* @param tab
* @param selector CSS选择器 * @param selector CSS选择器
*/ */
hideElement(selector: string): Promise<void>; hideElement(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
selector: string
): Promise<void>;
/** /**
* *
* @param tab
* @param selector CSS选择器 * @param selector CSS选择器
*/ */
showElement(selector: string): Promise<void>; showElement(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
selector: string
): Promise<void>;
/** /**
* CSS样式 * CSS样式
@ -2485,57 +2517,136 @@ interface quickcomposerApi {
/** /**
* Cookie * Cookie
* @param name Cookie名称 * @param tab
* @param value Cookie值 * @param cookies Cookie配置数组
* @param options Cookie选项
*/ */
setCookie(name: string, value: string): Promise<void>; setCookie(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
cookies: Array<{ name: string; value: string }>,
options?: {
domain?: string;
path?: string;
secure?: boolean;
expires?: number;
}
): Promise<void>;
/** /**
* Cookie * Cookie
* @param name Cookie名称 * @param tab
* @param name Cookie名称Cookie
*/ */
getCookie(name: string): Promise<string>; getCookie(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
name?: string
): Promise<
| { name: string; value: string; domain: string; path: string }[]
| { name: string; value: string; domain: string; path: string }
>;
/** /**
* Cookie * Cookie
* @param tab
* @param name Cookie名称 * @param name Cookie名称
*/ */
deleteCookie(name: string): Promise<void>; deleteCookie(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
name: string
): Promise<void>;
/** /**
* *
* @param tab
* @param x X坐标 * @param x X坐标
* @param y Y坐标 * @param y Y坐标
*/ */
scrollTo(x: number, y: number): Promise<void>; scrollTo(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
x: number,
y: number
): Promise<void>;
/** /**
* *
* @param tab
* @param selector CSS选择器 * @param selector CSS选择器
*/ */
scrollToElement(selector: string): Promise<void>; scrollToElement(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
selector: string
): Promise<void>;
/** /**
* *
* @param tab
*/ */
getScrollPosition(): Promise<{ getScrollPosition(tab: {
x: number; // X坐标 by?: "active" | "url" | "title" | "id";
y: number; // Y坐标 searchValue?: string;
}>; }): Promise<{ x: number; y: number }>;
/** /**
* *
* @param tab
*/ */
getPageSize(): Promise<{ getPageSize(tab: {
width: number; // 页面宽度 by?: "active" | "url" | "title" | "id";
height: number; // 页面高度 searchValue?: string;
}>; }): Promise<{ width: number; height: number }>;
/** /**
* *
* @param tab
* @param selector CSS选择器 * @param selector CSS选择器
* @param timeout () * @param timeout ()
*/ */
waitForElement(selector: string, timeout?: number): Promise<void>; waitForElement(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
selector: string,
timeout?: number
): Promise<void>;
/**
* CSS样式
* @param tab
* @param css CSS样式代码
*/
injectCSS(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
css: string
): Promise<void>;
/**
*
* @param tab
* @param buttonSelector CSS选择器
* @param inputSelectors
*/
submitForm(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
buttonSelector: string,
inputSelectors: Array<{ selector: string; value: string }>
): Promise<void>;
/**
*
* @param tab
* @param url URL
*/
injectRemoteScript(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
url: string
): Promise<boolean>;
/**
*
* @param tab
* @param filePath
*/
injectLocalScript(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
filePath: string
): Promise<boolean>;
}; };
} }