完善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 options
* @param options.format
* @param options.quality (jpeg)
* @param options.savePath
* @param options.selector
*/
captureScreenshot(
tab: {
by?: "active" | "url" | "title" | "id";
searchValue?: string;
},
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
options?: {
type?: "png" | "jpeg"; // 图片类型
quality?: number; // 图片质量(仅jpeg)
fullPage?: boolean; // 是否截取完整页面
clip?: {
// 裁剪区域
x: number;
y: number;
width: number;
height: number;
};
encoding?: "base64" | "binary"; // 编码方式
path?: string; // 保存路径
format?: "png" | "jpeg";
quality?: number;
savePath?: string;
selector?: string;
}
): Promise<string>;
/**
* URL
* @param tab
*/
getUrl(): Promise<string>;
getUrl(tab: {
by?: "active" | "url" | "title" | "id";
searchValue?: string;
}): Promise<string>;
/**
* URL
* @param tab
* @param url URL
*/
setUrl(url: string): Promise<void>;
setUrl(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
url: string
): Promise<void>;
/**
* JavaScript代码
* @param tab
* @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选择器
*/
clickElement(selector: string): Promise<void>;
clickElement(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
selector: string
): Promise<void>;
/**
*
* @param tab
* @param selector CSS选择器
* @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选择器
*/
getText(selector: string): Promise<string>;
getText(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
selector: string
): Promise<string>;
/**
* HTML内容
* @param tab
* @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选择器
*/
hideElement(selector: string): Promise<void>;
hideElement(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
selector: string
): Promise<void>;
/**
*
* @param tab
* @param selector CSS选择器
*/
showElement(selector: string): Promise<void>;
showElement(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
selector: string
): Promise<void>;
/**
* CSS样式
@ -2485,57 +2517,136 @@ interface quickcomposerApi {
/**
* Cookie
* @param name Cookie名称
* @param value Cookie值
* @param tab
* @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
* @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
* @param tab
* @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 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选择器
*/
scrollToElement(selector: string): Promise<void>;
scrollToElement(
tab: { by?: "active" | "url" | "title" | "id"; searchValue?: string },
selector: string
): Promise<void>;
/**
*
* @param tab
*/
getScrollPosition(): Promise<{
x: number; // X坐标
y: number; // Y坐标
}>;
getScrollPosition(tab: {
by?: "active" | "url" | "title" | "id";
searchValue?: string;
}): Promise<{ x: number; y: number }>;
/**
*
* @param tab
*/
getPageSize(): Promise<{
width: number; // 页面宽度
height: number; // 页面高度
}>;
getPageSize(tab: {
by?: "active" | "url" | "title" | "id";
searchValue?: string;
}): Promise<{ width: number; height: number }>;
/**
*
* @param tab
* @param selector CSS选择器
* @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>;
};
}