browser-automator
Version:
Puppeteer alternative for Chrome extensions. A module for Chrome extensions that functions similarly to Puppeteer.
77 lines (76 loc) • 3.02 kB
TypeScript
/**
* Delays execution for the specified number of milliseconds.
*
* @param {number} milliseconds - The duration of the delay in milliseconds.
* @returns {Promise<void>}
*/
declare const doDelay: (milliseconds: number) => Promise<void>;
/**
* Crops an offscreen image.
*
* @param {ImageBitmap} image - The image to crop.
* @param {number} width - The width of the cropped area.
* @param {number} height - The height of the cropped area.
* @param {number} left - The left position of the cropped area.
* @param {number} top - The top position of the cropped area.
* @returns {OffscreenCanvas} - The cropped image as an OffscreenCanvas.
*/
declare const cropImageOffscreen: (image: ImageBitmap, width: number, height: number, left: number, top: number) => OffscreenCanvas;
/**
* Creates an ImageBitmap from a given image URL.
*
* @param {string} url - The URL of the image.
* @returns {Promise<ImageBitmap>} - The created ImageBitmap.
*/
declare const imageBitmapFromUrl: (url: string) => Promise<ImageBitmap>;
/**
* Converts a Blob to a data URL.
*
* @param {Blob} blob - The Blob to convert.
* @returns {Promise<string>} - The data URL representing the Blob.
*/
declare const blobToDataUrl: (blob: Blob) => Promise<unknown>;
/**
* Retrieves a random element from an array.
*
* @param {any[]} array - The array from which to select a random element.
* @returns {any} - The randomly selected element from the array.
*/
declare const getRandomFromArray: (array: any[]) => any;
/**
* Triggers a DOM event on the specified element.
*
* @param {any} element - The DOM element on which to trigger the event.
* @param {string} type - The type of event to trigger.
*/
declare const triggerEvent: (element: any, type: string) => void;
/**
* Sets a value for an HTML element and triggers input-related events.
*
* @param {{ tagName: string; value: any; innerHTML: any }} element - The HTML element to set the value on.
* @param {any} value - The value to set on the element.
*/
declare const setValue: (element: {
tagName: string;
value: any;
innerHTML: any;
}, value: any) => void;
/**
* Omits specified properties from an object.
*
* @template T
* @param {T} item - The object to omit properties from.
* @param {keyof T} keys - The properties to omit from the object.
* @returns {Partial<T>} - A new object with omitted properties.
*/
declare const omitProperties: <T extends Record<string, any>>(item: T, keys: (keyof T)[]) => Partial<T>;
/**
* Chooses specified properties from an object.
*
* @template T
* @param {T} item - The object to choose properties from.
* @param {keyof T} keys - The properties to choose from the object.
* @returns {Partial<T>} - A new object with chosen properties.
*/
declare const chooseProperties: <T extends Record<string, any>>(item: T, keys: (keyof T)[]) => Partial<T>;
export { doDelay, cropImageOffscreen, imageBitmapFromUrl, blobToDataUrl, getRandomFromArray, triggerEvent, setValue, omitProperties, chooseProperties };