UNPKG

@ng1005/chrome-extension-common

Version:

chrome扩展通用库--消息与storage

72 lines (71 loc) 1.65 kB
/** * 消息interface */ interface IMessageInterface { /** * 是否支持跨扩展(仅runtime有效) */ crossExtension: boolean; /** * 当前脚本 */ script: string; /** * 监听 */ listener(): void; /** * 提交给当前script(如过当前时contentScript则发送给contentScript,其他则是其他) * @param type * @param args */ $emit(type: string, ...args: any): Promise<any>; /** * 发送给ContentScript * @param type * @param args */ $emitContent(type: string, ...args: any): Promise<any>; /** * 发送给backgroundScript * @param type * @param args */ $emitBackground(type: string, ...args: any): Promise<any>; /** * 发送给popup消息 * @param type * @param args */ $emitPopup(type: string, ...args: any): Promise<any>; /** * 发送给window消息 * @param type * @param args */ $emitWindow(type: string, ...args: any): Promise<any>; /** * 发送给所有打开的网页tab-contentScript * @param type * @param args */ $emitAllTabs(type: string, ...args: any): Promise<any>; /** * * @param callback 获取当前标签tabId */ getCurrentTabId(callback: Function): this; /** * 获取tabs * @param callback * @param queryInfo */ getTabs(callback: Function, queryInfo?: chrome.tabs.QueryInfo): this; /** * 获取tabs * @param callback * @param queryInfo */ getCurrentTabs(callback: Function): this; } export default IMessageInterface;