/* @flow */ /* * Based on https://github.com/Shraymonks/flow-interfaces-chrome * not sure if browser polyfill has flow types?? * https://github.com/mozilla/webextension-polyfill/issues/421 */ type browser$StorageArea = { get: (keys: string | Array | Object | null) => Promise, set: (items: Object) => Promise, } type browser$storage = { local: browser$StorageArea, managed: browser$StorageArea, sync: browser$StorageArea, } type result = boolean type granted = boolean type browser$permissions = { contains: (permissions: chrome$Permissions) => Promise, request : (permissions: chrome$Permissions) => Promise, } type browser$tabs = { query(queryInfo: { active?: boolean, audible?: boolean, currentWindow?: boolean, highlighted?: boolean, index?: number, lastFocusedWindow?: boolean, muted?: boolean, pinned?: boolean, status?: chrome$TabStatus, title?: string, url?: string | Array, windowId?: number, windowType?: chrome$WindowType }): Promise>, executeScript: ( (( tabId?: number, details: { allFrames?: boolean, code?: string, file?: string, frameId?: number, matchAboutBlank?: boolean, runAt?: chrome$RunAt }, ) => Promise) & (( details: { allFrames?: boolean, code?: string, file?: string, frameId?: number, matchAboutBlank?: boolean, runAt?: chrome$RunAt }, ) => Promise) ), } type ExecuteResult = { result: any, } type browser$scripting = { executeScript: ({ target: {tabId?: number}, func: () => void, }) => Promise>, } declare var browser: { storage: browser$storage, permissions: browser$permissions, tabs: browser$tabs, scripting: browser$scripting, } declare module "webextension-polyfill" { declare var storage: browser$storage; declare var permissions: browser$permissions; declare var tabs: browser$tabs; declare var scripting: browser$scripting; }