Midora/extension/webextensions.d.ts

59 lines
1.8 KiB
TypeScript
Raw Normal View History

2019-06-29 15:16:27 +02:00
declare type Browser = {
runtime: {
sendMessage<TRequest, TResponse>(request: TRequest, response: (response: TResponse) => void): void;
2019-06-29 15:41:37 +02:00
onMessage: {
addListener<TRequest, TResponse>(listener: (message: TRequest, sender: MessageSender, sendResponse: (response: TResponse) => void) => void): void
2019-06-29 15:41:37 +02:00
}
2019-06-29 15:16:27 +02:00
}
2019-06-29 15:41:37 +02:00
2019-06-29 15:16:27 +02:00
storage: {
local: BrowserStorage
}
2019-06-29 15:41:37 +02:00
tabs: {
remove(id: number): void
2019-06-29 15:41:37 +02:00
sendMessage<TRequest, TResponse>(tabId: number, request: TRequest, options?: {
frameId: number
}, callback?: (response: TResponse) => void): void
2019-06-29 15:41:37 +02:00
create(options: {
url: string
}): void
2019-07-17 23:35:00 +02:00
query(query: {}, callback: (tabs: { id: number }[]) => void): void;
2019-06-29 15:41:37 +02:00
}
2019-06-29 15:16:27 +02:00
extension: {
2019-06-29 15:41:37 +02:00
getURL(relativeUrl: string): string
}
contextMenus: {
create(options: {
2019-07-17 23:35:00 +02:00
id?: string
title?: string
enabled?: boolean
contexts?: ('all' | 'page' | 'frame' | 'selection' | 'link' | 'editable' | 'image' | 'video' | 'audio' | 'launcher' | 'browser_action' | 'page_action' | 'action')[]
2019-07-17 23:35:00 +02:00
targetUrlPatterns?: string[]
documentUrlPatterns?: string[]
2019-07-17 23:35:00 +02:00
type?: 'normal' | 'separator'
2019-06-29 15:41:37 +02:00
}): void
onClicked: {
addListener(listener: (info: {
menuItemId: string
frameId: number
linkUrl: string
}, tab: {
id: number
}) => void): void
2019-06-29 15:41:37 +02:00
}
2019-06-29 15:16:27 +02:00
}
}
type MessageSender = {
2019-07-17 23:35:00 +02:00
tab?: { id: number };
frameId?: number;
id?: string;
url?: string;
tlsChannelId?: string;
2019-07-17 23:35:00 +02:00
};
2019-06-29 15:16:27 +02:00
declare type BrowserStorage = {
get(names: string[], callback: (obj: any) => void): void
set(obj: { [name: string]: any }): void;
2019-06-29 15:16:27 +02:00
}
2019-06-29 15:41:37 +02:00
declare var browser: Browser;
declare var chrome: Browser;