browser-automator
Version:
Puppeteer alternative for Chrome extensions. A module for Chrome extensions that functions similarly to Puppeteer.
58 lines (57 loc) • 2.47 kB
TypeScript
import Page from './page';
export declare const syncPageIntegration: (tabId: number) => Promise<void>;
/**
* Represents a Browser instance for interacting with Chrome browser pages.
*/
export default class Browser {
/**
* An array of available Page instances within the browser.
*/
availablePages: Page[];
/**
* Creates a new Browser instance.
*/
constructor();
/**
* Returns an array of available Page instances.
* @returns An array of available Page instances.
*/
pages(): Page[];
/**
* Closes all associated pages in the Browser instance.
*/
close(): Promise<void>;
/**
* Creates a new Page instance and associates it with the browser.
* @param tabId - The ID of the tab to use for creating the Page instance. If not supplied a tab will be created.
* @param windowId - The ID of the window to open the page in. If not supplied a window will be created.
* @param originWindowId - The ID of the tab's origin window. If supplied the tab will be moved in that window when closing the browser-automator instance instead of closing the tab.
* @param activeInOrigin - Whether the page/tab should be active in the origin window when moved to the origin window.
* @param windowOptions - Options for creating the window.
* @param tabOptions - Options for creating or updating the tab.
* @returns A Promise that resolves with the new Page instance.
*/
newPage({ tabId, windowId, originWindowId, activeInOrigin, windowOptions, tabOptions }?: {
tabId?: number;
windowId?: number;
originWindowId?: number;
activeInOrigin?: boolean;
windowOptions?: chrome.windows.CreateData;
tabOptions?: chrome.tabs.CreateProperties | chrome.tabs.UpdateProperties;
}): Promise<Page>;
/**
* A callback function that is invoked when a new page is added to the browser.
*/
onPageAdded?: Function;
/**
* A callback function that is invoked when a page is closed.
*/
onPageClose?: (tabId: number, removeInfo: chrome.tabs.TabRemoveInfo) => void;
/**
* A callback function that is invoked when a page is updated.
*/
onPageUpdate?: Function;
handleTabRemove: (tabId: number, removeInfo: chrome.tabs.TabRemoveInfo) => void;
handleTabUpdate: (tabId: number, changeInfo: chrome.tabs.TabChangeInfo, tab: chrome.tabs.Tab) => void;
syncListeners(): void;
}