import { Message } from './messages' ; export function createTab ( url , active = true ) { return new Promise ( ( resolve ) => { chrome . tabs . create ( { url , active } , resolve ) ; } ) ; } export function sendMessageToTab < T > ( tabId , message ) { chrome . tabs . sendMessage ( tabId , message ) ; } export function sendMessageToAllTabs < P > ( message ) { chrome . tabs . query ( { } , tabs => { tabs . forEach ( tab => sendMessageToTab ( tab . id , message ) ) ; } ) ; } export function getActiveTab ( ) { return new Promise ( resolve => { chrome . tabs . query ( { active : true } , function ( tabs ) { resolve ( tabs [ 0 ] ) ; } ) ; } ) ; }