2018-05-27 01:29:02 +02:00
if ( Debug . debug ) {
2018-07-16 22:30:52 +02:00
console . log ( "Loading Comms.js" ) ;
2018-05-27 01:29:02 +02:00
}
2018-05-26 23:08:49 +02:00
class CommsClient {
2018-08-22 23:16:08 +02:00
constructor ( name , settings ) {
2018-07-16 22:30:52 +02:00
if ( BrowserDetect . firefox ) {
this . port = browser . runtime . connect ( { name : name } ) ;
} else if ( BrowserDetect . chrome ) {
this . port = chrome . runtime . connect ( { name : name } ) ;
2018-08-07 23:31:28 +02:00
} else if ( BrowserDetect . edge ) {
this . port = browser . runtime . connect ( { name : name } )
2018-07-16 22:30:52 +02:00
}
2018-05-26 23:08:49 +02:00
var ths = this ;
2018-08-30 00:56:15 +02:00
this . _listener = m => ths . processReceivedMessage ( m ) ;
this . port . onMessage . addListener ( this . _listener ) ;
2018-08-07 23:31:28 +02:00
2018-08-22 23:16:08 +02:00
this . settings = settings ;
2018-08-22 23:46:59 +02:00
this . pageInfo = undefined ;
2018-08-30 00:56:15 +02:00
this . commsId = ( Math . random ( ) * 20 ) . toFixed ( 0 ) ;
2018-05-26 23:08:49 +02:00
}
2018-08-30 00:56:15 +02:00
destroy ( ) {
this . pageInfo = null ;
this . settings = null ;
2018-09-27 00:17:49 +02:00
if ( ! BrowserDetect . edge ) { // edge is a very special browser made by outright morons.
this . port . onMessage . removeListener ( this . _listener ) ;
}
2018-08-30 00:56:15 +02:00
}
2018-05-26 23:08:49 +02:00
setPageInfo ( pageInfo ) {
2018-08-30 00:56:15 +02:00
2018-05-26 23:08:49 +02:00
this . pageInfo = pageInfo ;
2018-08-30 00:56:15 +02:00
if ( Debug . debug ) {
console . log ( ` [CommsClient::setPageInfo] < ${ this . commsId } > ` , "SETTING PAGEINFO —" , this . pageInfo , this )
}
var ths = this ;
this . _listener = m => ths . processReceivedMessage ( m ) ;
2018-09-27 00:17:49 +02:00
if ( ! BrowserDetect . edge ) {
this . port . onMessage . removeListener ( this . _listener ) ;
}
2018-08-30 00:56:15 +02:00
this . port . onMessage . addListener ( this . _listener ) ;
2018-05-26 23:08:49 +02:00
}
processReceivedMessage ( message ) {
if ( Debug . debug && Debug . comms ) {
2018-08-30 00:56:15 +02:00
console . log ( ` [CommsClient.js::processMessage] < ${ this . commsId } > Received message from background script! ` , message ) ;
2018-05-26 23:08:49 +02:00
}
2018-08-30 00:56:15 +02:00
if ( ! this . pageInfo || ! this . settings . active ) {
2018-08-22 23:46:59 +02:00
if ( Debug . debug && Debug . comms ) {
2018-08-30 00:56:15 +02:00
console . log ( ` [CommsClient.js::processMessage] < ${ this . commsId } > this.pageInfo (or settings) not defined. Extension is probably disabled for this site. \n pageInfo: ` , this . pageInfo ,
"\nsettings.active:" , this . settings . active ,
"\nnobj:" , this
) ;
2018-08-22 23:46:59 +02:00
}
return ;
}
2018-09-21 00:26:08 +02:00
if ( message . cmd === 'get-current-zoom' ) {
this . pageInfo . requestCurrentZoom ( ) ;
}
2018-07-15 16:22:32 +02:00
if ( message . cmd === "set-ar" ) {
2018-11-21 21:58:13 +01:00
this . pageInfo . setAr ( message . arg , message . playing ) ;
2018-09-23 02:39:27 +02:00
} else if ( message . cmd === 'set-alignment' ) {
2018-11-21 21:58:13 +01:00
this . pageInfo . setVideoFloat ( message . arg , message . playing ) ;
2018-07-15 16:22:32 +02:00
this . pageInfo . restoreAr ( ) ;
2018-05-26 23:08:49 +02:00
} else if ( message . cmd === "set-stretch" ) {
2018-11-26 22:41:44 +01:00
this . pageInfo . setStretchMode ( message . arg , message . playing ) ;
2018-06-15 00:33:10 +02:00
} else if ( message . cmd === "autoar-start" ) {
2018-05-26 23:08:49 +02:00
if ( message . enabled !== false ) {
2018-11-21 21:58:13 +01:00
this . pageInfo . initArDetection ( message . playing ) ;
this . pageInfo . startArDetection ( message . playing ) ;
2018-05-26 23:08:49 +02:00
} else {
2018-11-21 21:58:13 +01:00
this . pageInfo . stopArDetection ( message . playing ) ;
2018-05-26 23:08:49 +02:00
}
} else if ( message . cmd === "pause-processing" ) {
2018-11-21 21:58:13 +01:00
this . pageInfo . pauseProcessing ( message . playing ) ;
2018-05-26 23:08:49 +02:00
} else if ( message . cmd === "resume-processing" ) {
// todo: autoArStatus
2018-11-21 21:58:13 +01:00
this . pageInfo . resumeProcessing ( message . autoArStatus , message . playing ) ;
2018-09-18 23:37:33 +02:00
} else if ( message . cmd === 'set-zoom' ) {
2018-11-21 21:58:13 +01:00
this . pageInfo . setZoom ( message . zoom , true , message . playing ) ;
2018-09-18 23:37:33 +02:00
}
2018-05-26 23:08:49 +02:00
}
async sleep ( n ) {
return new Promise ( ( resolve , reject ) => setTimeout ( resolve , n ) ) ;
}
async sendMessage _nonpersistent ( message ) {
if ( BrowserDetect . firefox ) {
return browser . runtime . sendMessage ( message )
} else {
return new Promise ( ( resolve , reject ) => {
try {
if ( BrowserDetect . edge ) {
browser . runtime . sendMessage ( message , function ( response ) {
var r = response ;
resolve ( r ) ;
} ) ;
} else {
chrome . runtime . sendMessage ( message , function ( response ) {
// Chrome/js shittiness mitigation — remove this line and an empty array will be returned
var r = response ;
resolve ( r ) ;
} ) ;
}
}
catch ( e ) {
reject ( e ) ;
}
} ) ;
}
}
async requestSettings ( ) {
if ( Debug . debug ) {
2018-05-27 01:29:02 +02:00
console . log ( "%c[CommsClient::requestSettings] sending request for congif!" , "background: #11D; color: #aad" ) ;
2018-05-26 23:08:49 +02:00
}
var response = await this . sendMessage _nonpersistent ( { cmd : 'get-config' } ) ;
if ( Debug . debug ) {
2018-05-27 01:29:02 +02:00
console . log ( "%c[CommsClient::requestSettings] received settings response!" , "background: #11D; color: #aad" , response ) ;
2018-05-26 23:08:49 +02:00
}
if ( ! response || response . extensionConf ) {
return Promise . resolve ( false ) ;
}
2018-08-05 23:48:56 +02:00
this . settings . active = JSON . parse ( response . extensionConf ) ;
2018-05-26 23:08:49 +02:00
return Promise . resolve ( true ) ;
}
registerVideo ( ) {
2018-11-07 00:03:06 +01:00
if ( Debug . debug && Debug . comms ) {
console . log ( ` [CommsClient::registerVideo] < ${ this . commsId } > ` , "Registering video for current page." ) ;
}
2018-05-26 23:08:49 +02:00
this . port . postMessage ( { cmd : "has-video" } ) ;
}
2018-11-07 00:03:06 +01:00
unregisterVideo ( ) {
if ( Debug . debug && Debug . comms ) {
console . log ( ` [CommsClient::unregisterVideo] < ${ this . commsId } > ` , "Unregistering video for current page." ) ;
}
this . port . postMessage ( { cmd : "noVideo" } ) ; // ayymd
}
2018-09-21 00:26:08 +02:00
announceZoom ( scale ) {
this . port . postMessage ( { cmd : "announce-zoom" , zoom : scale } ) ;
2018-11-07 00:03:06 +01:00
this . registerVideo ( )
2018-09-21 00:26:08 +02:00
}
2018-05-26 23:08:49 +02:00
}
class CommsServer {
constructor ( server ) {
this . server = server ;
2018-08-07 23:31:28 +02:00
this . settings = server . settings ;
2018-05-26 23:08:49 +02:00
this . ports = [ ] ;
var ths = this ;
if ( BrowserDetect . firefox ) {
browser . runtime . onConnect . addListener ( p => ths . onConnect ( p ) ) ;
browser . runtime . onMessage . addListener ( m => ths . processReceivedMessage _nonpersistent _ff ( m ) ) ;
} else {
chrome . runtime . onConnect . addListener ( p => ths . onConnect ( p ) ) ;
chrome . runtime . onMessage . addListener ( ( msg , sender , callback ) => ths . processReceivedMessage _nonpersistent _chrome ( m , sender , callback ) ) ;
}
}
2018-09-20 01:11:18 +02:00
async getCurrentTabHostname ( ) {
const activeTab = await this . _getActiveTab ( ) ;
const url = activeTab [ 0 ] . url ;
var hostname ;
if ( url . indexOf ( "://" ) > - 1 ) { //find & remove protocol (http, ftp, etc.) and get hostname
hostname = url . split ( '/' ) [ 2 ] ;
}
else {
hostname = url . split ( '/' ) [ 0 ] ;
}
hostname = hostname . split ( ':' ) [ 0 ] ; //find & remove port number
hostname = hostname . split ( '?' ) [ 0 ] ; //find & remove "?"
2018-06-27 23:55:37 +02:00
2018-09-20 01:11:18 +02:00
return hostname ;
2018-06-27 23:55:37 +02:00
}
2018-05-26 23:56:50 +02:00
sendToAll ( message ) {
2018-06-28 23:43:52 +02:00
for ( var p of this . ports ) {
for ( var frame in p ) {
2018-05-26 23:56:50 +02:00
p [ frame ] . postMessage ( message ) ;
}
}
}
2018-07-16 22:30:52 +02:00
async _getActiveTab ( ) {
if ( BrowserDetect . firefox ) {
return await browser . tabs . query ( { currentWindow : true , active : true } ) ;
} else {
return await new Promise ( ( resolve , reject ) => {
2018-09-20 21:45:09 +02:00
chrome . tabs . query ( { lastFocusedWindow : true , active : true } , function ( res ) {
2018-07-16 22:30:52 +02:00
resolve ( res ) ;
} ) ;
} ) ;
2018-05-27 01:29:02 +02:00
}
2018-07-16 22:30:52 +02:00
}
2018-05-27 01:29:02 +02:00
2018-11-21 20:41:15 +01:00
async sendToFrame ( message , tab , frame ) {
if ( Debug . debug && Debug . comms ) {
console . log ( ` %c[CommsServer::sendToFrame] attempting to send message to tab ${ tab } , frame ${ frame } ` , "background: #dda; color: #11D" , message ) ;
}
if ( isNaN ( tab ) ) {
if ( tab === '__playing' ) {
message [ 'playing' ] = true ;
this . sendToAll ( message ) ;
return ;
} else if ( tab === '__all' ) {
this . sendToAll ( message ) ;
return ;
}
[ tab , frame ] = tab . split ( '-' )
}
if ( Debug . debug && Debug . comms ) {
console . log ( ` %c[CommsServer::sendToFrame] attempting to send message to tab ${ tab } , frame ${ frame } ` , "background: #dda; color: #11D" , message ) ;
}
try {
this . ports [ tab ] [ frame ] . postMessage ( message ) ;
} catch ( e ) {
if ( Debug . debug && Debug . comms ) {
console . log ( ` %c[CommsServer::sendToFrame] Sending message failed. Reason: ` , "background: #dda; color: #11D" , e ) ;
}
}
}
2018-07-16 22:30:52 +02:00
async sendToActive ( message ) {
if ( Debug . debug && Debug . comms ) {
console . log ( "%c[CommsServer::sendToActive] trying to send a message to active tab. Message:" , "background: #dda; color: #11D" , message ) ;
2018-05-26 23:56:50 +02:00
}
2018-07-16 22:30:52 +02:00
var tabs = await this . _getActiveTab ( ) ;
2018-05-27 01:29:02 +02:00
if ( Debug . debug && Debug . comms ) {
console . log ( "[CommsServer::_sendToActive_ff] currently active tab(s)?" , tabs ) ;
for ( var key in this . ports [ tabs [ 0 ] . id ] ) {
console . log ( "key?" , key , this . ports [ tabs [ 0 ] . id ] ) ;
// this.ports[tabs[0].id][key].postMessage(message);
}
}
for ( var key in this . ports [ tabs [ 0 ] . id ] ) {
2018-05-26 23:56:50 +02:00
this . ports [ tabs [ 0 ] . id ] [ key ] . postMessage ( message ) ;
}
}
2018-05-26 23:08:49 +02:00
onConnect ( port ) {
2018-05-27 01:29:02 +02:00
var ths = this ;
// poseben primer | special case
if ( port . name === 'popup-port' ) {
this . popupPort = port ;
this . popupPort . onMessage . addListener ( ( m , p ) => ths . processReceivedMessage ( m , p ) ) ;
return ;
}
2018-05-26 23:08:49 +02:00
var tabId = port . sender . tab . id ;
2018-05-26 23:56:50 +02:00
var frameId = port . sender . frameId ;
if ( ! this . ports [ tabId ] ) {
this . ports [ tabId ] = { } ;
}
this . ports [ tabId ] [ frameId ] = port ;
this . ports [ tabId ] [ frameId ] . onMessage . addListener ( ( m , p ) => ths . processReceivedMessage ( m , p ) ) ;
this . ports [ tabId ] [ frameId ] . onDisconnect . addListener ( ( p ) => {
delete ths . ports [ p . sender . tab . id ] [ p . sender . frameId ] ;
if ( Object . keys ( ths . ports [ p . sender . tab . id ] ) . length === 0 ) {
ths . ports [ tabId ] = undefined ;
}
} ) ;
2018-05-26 23:08:49 +02:00
}
2018-09-20 01:11:18 +02:00
async processReceivedMessage ( message , port ) {
2018-05-26 23:08:49 +02:00
if ( Debug . debug && Debug . comms ) {
2018-08-23 01:04:37 +02:00
console . log ( "[CommsServer.js::processMessage] Received message from background script!" , message , "port" , port , "\nsettings and server:" , this . settings , this . server ) ;
2018-05-26 23:08:49 +02:00
}
2018-09-21 00:26:08 +02:00
if ( message . cmd === 'announce-zoom' ) {
// forward off to the popup, no use for this here
2018-09-23 19:46:40 +02:00
try {
this . popupPort . postMessage ( { cmd : 'set-current-zoom' , zoom : message . zoom } ) ;
} catch ( e ) {
// can't forward stuff to popup if it isn't open
}
2018-09-21 00:26:08 +02:00
} else if ( message . cmd === 'get-current-zoom' ) {
this . sendToActive ( message ) ;
}
if ( message . cmd === 'get-current-site' ) {
2018-11-09 00:57:05 +01:00
port . postMessage ( { cmd : 'set-current-site' , site : this . server . getVideoTab ( ) , tabHostname : await this . getCurrentTabHostname ( ) } ) ;
2018-09-20 01:11:18 +02:00
}
2018-11-23 00:29:13 +01:00
if ( message . cmd === 'popup-set-selected-tab' ) {
this . server . setSelectedTab ( message . selectedMenu , message . selectedSubitem ) ;
2018-11-22 22:55:22 +01:00
}
2018-09-20 01:11:18 +02:00
2018-05-26 23:08:49 +02:00
if ( message . cmd === 'get-config' ) {
2018-08-21 23:48:47 +02:00
if ( Debug . debug ) {
console . log ( "CommsServer: received get-config. Active settings?" , this . settings . active , "\n(settings:" , this . settings , ")" )
}
2018-08-05 23:48:56 +02:00
port . postMessage ( { cmd : "set-config" , conf : this . settings . active , site : this . server . currentSite } )
2018-06-15 00:33:10 +02:00
} else if ( message . cmd === 'set-stretch' ) {
2018-11-21 20:41:15 +01:00
this . sendToFrame ( message , message . targetFrame ) ;
2018-06-15 00:33:10 +02:00
} else if ( message . cmd === 'set-ar' ) {
2018-11-21 20:41:15 +01:00
this . sendToFrame ( message , message . targetFrame ) ;
2018-07-09 23:30:11 +02:00
} else if ( message . cmd === 'set-custom-ar' ) {
2018-11-18 03:29:16 +01:00
this . settings . active . keyboard . shortcuts . q . arg = message . arg ;
2018-08-07 23:31:28 +02:00
this . settings . save ( ) ;
2018-09-23 02:39:27 +02:00
} else if ( message . cmd === 'set-alignment' ) {
2018-11-21 20:41:15 +01:00
this . sendToFrame ( message , message . targetFrame ) ;
2018-06-15 00:33:10 +02:00
} else if ( message . cmd === 'autoar-start' ) {
2018-11-21 20:41:15 +01:00
this . sendToFrame ( message , message . targetFrame ) ;
2018-09-18 23:37:33 +02:00
} else if ( message . cmd === "autoar-disable" ) { // LEGACY - can be removed prolly
2018-08-05 23:48:56 +02:00
this . settings . active . arDetect . mode = "disabled" ;
2018-06-15 00:33:10 +02:00
if ( message . reason ) {
2018-08-05 23:48:56 +02:00
this . settings . active . arDetect . disabledReason = message . reason ;
2018-06-15 00:33:10 +02:00
} else {
2018-08-05 23:48:56 +02:00
this . settings . active . arDetect . disabledReason = 'User disabled' ;
2018-06-15 00:33:10 +02:00
}
2018-08-07 23:31:28 +02:00
this . settings . save ( ) ;
2018-09-18 23:37:33 +02:00
} else if ( message . cmd === 'set-zoom' ) {
2018-11-21 20:41:15 +01:00
this . sendToFrame ( message , message . targetFrame ) ;
2018-11-07 00:03:06 +01:00
} else if ( message . cmd === 'has-video' ) {
this . server . registerVideo ( port . sender ) ;
} else if ( message . cmd === 'noVideo' ) {
this . server . unregisterVideo ( port . sender ) ;
2018-06-28 23:43:52 +02:00
}
2018-05-26 23:08:49 +02:00
}
processReceivedMessage _nonpersistent _ff ( message , sender ) {
if ( Debug . debug && Debug . comms ) {
2018-05-27 01:29:02 +02:00
console . log ( "%c[CommsServer.js::processMessage_nonpersistent_ff] Received message from background script!" , "background-color: #11D; color: #aad" , message , sender ) ;
2018-05-26 23:08:49 +02:00
}
if ( message . cmd === 'get-config' ) {
2018-08-05 23:48:56 +02:00
var ret = { extensionConf : JSON . stringify ( this . settings . active ) } ;
2018-05-26 23:08:49 +02:00
if ( Debug . debug && Debug . comms ) {
2018-05-27 01:29:02 +02:00
console . log ( "%c[CommsServer.js::processMessage_nonpersistent_ff] Returning this:" , "background-color: #11D; color: #aad" , ret ) ;
2018-05-26 23:08:49 +02:00
}
Promise . resolve ( ret ) ;
2018-06-15 00:33:10 +02:00
} else if ( message . cmd === "autoar-enable" ) {
2018-08-05 23:48:56 +02:00
this . settings . active . arDetect . mode = "blacklist" ;
2018-08-07 23:31:28 +02:00
this . settings . save ( ) ;
2018-06-15 00:33:10 +02:00
this . sendToAll ( { cmd : "reload-settings" , sender : "uwbg" } )
if ( Debug . debug ) {
2018-08-05 23:48:56 +02:00
console . log ( "[uw-bg] autoar set to enabled (blacklist). evidenz:" , this . settings . active ) ;
2018-06-15 00:33:10 +02:00
}
} else if ( message . cmd === "autoar-disable" ) {
2018-08-05 23:48:56 +02:00
this . settings . active . arDetect . mode = "disabled" ;
2018-06-15 00:33:10 +02:00
if ( message . reason ) {
2018-08-05 23:48:56 +02:00
this . settings . active . arDetect . disabledReason = message . reason ;
2018-06-15 00:33:10 +02:00
} else {
2018-08-05 23:48:56 +02:00
this . settings . active . arDetect . disabledReason = 'User disabled' ;
2018-06-15 00:33:10 +02:00
}
2018-08-07 23:31:28 +02:00
this . settings . save ( ) ;
2018-08-05 23:48:56 +02:00
this . sendToAll ( { cmd : 'reload-settings' , newConf : this . settings . active } ) ;
2018-06-15 00:33:10 +02:00
if ( Debug . debug ) {
2018-08-05 23:48:56 +02:00
console . log ( "[uw-bg] autoar set to disabled. evidenz:" , this . settings . active ) ;
2018-06-15 00:33:10 +02:00
}
} else if ( message . cmd === "autoar-set-interval" ) {
if ( Debug . debug )
console . log ( "[uw-bg] trying to set new interval for autoAr. New interval is" , message . timeout , "ms" ) ;
// set fairly liberal limit
var timeout = message . timeout < 4 ? 4 : message . timeout ;
2018-08-05 23:48:56 +02:00
this . settings . active . arDetect . timer _playing = timeout ;
2018-08-07 23:31:28 +02:00
this . settings . save ( ) ;
2018-08-05 23:48:56 +02:00
this . sendToAll ( { cmd : 'reload-settings' , newConf : this . settings . active } ) ;
2018-05-26 23:56:50 +02:00
}
2018-05-26 23:08:49 +02:00
}
processReceivedMessage _nonpersistent _chrome ( message , sender , sendResponse ) {
if ( Debug . debug && Debug . comms ) {
console . log ( "[CommsServer.js::processMessage_nonpersistent_chrome] Received message from background script!" , message ) ;
}
if ( message . cmd === 'get-config' ) {
2018-09-20 21:45:09 +02:00
sendResponse ( { extensionConf : JSON . stringify ( this . settings . active ) , site : this . getCurrentTabHostname ( ) } ) ;
2018-05-26 23:08:49 +02:00
// return true;
2018-06-15 00:33:10 +02:00
} else if ( message . cmd === "autoar-enable" ) {
2018-08-05 23:48:56 +02:00
this . settings . active . arDetect . mode = "blacklist" ;
2018-08-07 23:31:28 +02:00
this . settings . save ( ) ;
2018-06-15 00:33:10 +02:00
this . sendToAll ( { cmd : "reload-settings" , sender : "uwbg" } )
if ( Debug . debug ) {
2018-08-05 23:48:56 +02:00
console . log ( "[uw-bg] autoar set to enabled (blacklist). evidenz:" , this . settings . active ) ;
2018-06-15 00:33:10 +02:00
}
} else if ( message . cmd === "autoar-disable" ) {
2018-08-05 23:48:56 +02:00
this . settings . active . arDetect . mode = "disabled" ;
2018-06-15 00:33:10 +02:00
if ( message . reason ) {
2018-08-05 23:48:56 +02:00
this . settings . active . arDetect . disabledReason = message . reason ;
2018-06-15 00:33:10 +02:00
} else {
2018-08-05 23:48:56 +02:00
this . settings . active . arDetect . disabledReason = 'User disabled' ;
2018-06-15 00:33:10 +02:00
}
2018-08-07 23:31:28 +02:00
this . settings . save ( ) ;
2018-08-05 23:48:56 +02:00
this . sendToAll ( { cmd : 'reload-settings' , newConf : this . settings . active } ) ;
2018-06-15 00:33:10 +02:00
if ( Debug . debug ) {
2018-08-05 23:48:56 +02:00
console . log ( "[uw-bg] autoar set to disabled. evidenz:" , this . settings . active ) ;
2018-06-15 00:33:10 +02:00
}
} else if ( message . cmd === "autoar-set-interval" ) {
if ( Debug . debug )
console . log ( "[uw-bg] trying to set new interval for autoAr. New interval is" , message . timeout , "ms" ) ;
// set fairly liberal limit
var timeout = message . timeout < 4 ? 4 : message . timeout ;
2018-08-05 23:48:56 +02:00
this . settings . active . arDetect . timer _playing = timeout ;
2018-08-07 23:31:28 +02:00
this . settings . save ( ) ;
2018-08-05 23:48:56 +02:00
this . sendToAll ( { cmd : 'reload-settings' , newConf : this . settings . active } ) ;
2018-05-26 23:08:49 +02:00
}
}
}
2018-05-27 01:29:02 +02:00
class Comms {
static async sendMessage ( message ) {
if ( BrowserDetect . firefox ) {
return browser . runtime . sendMessage ( message )
} else {
return new Promise ( ( resolve , reject ) => {
try {
if ( BrowserDetect . edge ) {
browser . runtime . sendMessage ( message , function ( response ) {
var r = response ;
resolve ( r ) ;
} ) ;
} else {
chrome . runtime . sendMessage ( message , function ( response ) {
// Chrome/js shittiness mitigation — remove this line and an empty array will be returned
var r = response ;
resolve ( r ) ;
} ) ;
}
}
catch ( e ) {
reject ( e ) ;
}
} ) ;
}
}
2018-01-06 22:58:31 +01:00
2018-05-27 01:29:02 +02:00
}