1
1
var Settings = { }
2
2
chrome . storage . sync . get ( { AutoJoin : false , AutoMute : false , AutoSkipAlerts : false ,
3
3
Fullscreen : true , fullscreen_hotkey : true , volumeController : true ,
4
+ PictureInPicture : true ,
4
5
account : null , language : null
5
6
} , results => {
6
7
Settings = results ;
@@ -9,7 +10,7 @@ chrome.storage.sync.get({ AutoJoin: false, AutoMute: false, AutoSkipAlerts: fals
9
10
10
11
chrome . storage . sync . onChanged . addListener ( function ( changes , namespace ) {
11
12
chrome . storage . sync . get ( { AutoJoin : false , AutoMute : false , AutoSkipAlerts : false ,
12
- Fullscreen : true , fullscreen_hotkey : true , volumeController : true
13
+ Fullscreen : true , fullscreen_hotkey : true , volumeController : true , PictureInPicture : true
13
14
} , results => { Settings = results ; main ( ) ; } ) ;
14
15
} ) ;
15
16
@@ -110,17 +111,25 @@ function get_mic_and_vid_controls(){
110
111
return false
111
112
}
112
113
114
+ var pictureInPictureInterval ;
113
115
function in_meet_main ( ) {
116
+ var menu_items ;
117
+ let temp = document . querySelector ( 'div[jsname="tc8lHd"]' )
118
+ if ( ! temp . querySelector ( "#meetHelperTools" ) ) {
119
+ menu_items = document . createElement ( "div" )
120
+ menu_items . id = "meetHelperTools"
121
+ temp . appendChild ( menu_items )
122
+ } else { menu_items = temp . querySelector ( "#meetHelperTools" ) }
123
+
114
124
if ( Settings . volumeController ) {
115
125
if ( ! document . querySelector ( "#volumeController" ) ) {
116
126
var currentVolume = 1 ;
117
- let menu_items = document . querySelector ( 'div[jsname="tc8lHd"]' )
118
127
let div = document . createElement ( "div" )
119
128
div . id = "volumeController"
120
129
div . style . height = "48px" ; div . style . width = "48px" ;
121
130
div . style . cursor = "pointer" ;
122
131
div . style . position = "relative" ;
123
- div . style . display = "flex" ;
132
+ div . style . display = "inline- flex" ;
124
133
div . style . alignItems = "center" ; div . style . placeContent = "center" ;
125
134
div . style . borderRadius = "50px" ;
126
135
div . style . transition = "0.2s ease" ;
@@ -233,7 +242,7 @@ function in_meet_main(){
233
242
setInterval ( _ => {
234
243
setAllVolume ( currentVolume )
235
244
} , 200 )
236
- menu_items . appendChild ( div )
245
+ menu_items . prepend ( div )
237
246
}
238
247
}
239
248
else {
@@ -243,12 +252,11 @@ function in_meet_main(){
243
252
244
253
if ( Settings . Fullscreen ) {
245
254
if ( ! document . querySelector ( "#MeetFullScreen" ) ) {
246
- let menu_items = document . querySelector ( 'div[jsname="tc8lHd"]' )
247
255
let div = document . createElement ( "div" )
248
256
div . id = "MeetFullScreen"
249
257
div . style . height = "48px" ; div . style . width = "48px" ;
250
258
div . style . cursor = "pointer" ;
251
- div . style . display = "flex" ;
259
+ div . style . display = "inline- flex" ;
252
260
div . style . alignItems = "center" ; div . style . placeContent = "center" ;
253
261
div . style . transition = "0.2s ease" ;
254
262
div . style . borderRadius = "50px" ;
@@ -268,11 +276,11 @@ function in_meet_main(){
268
276
div . addEventListener ( "mouseleave" , _ => {
269
277
div . style . background = ""
270
278
} )
271
- div . children [ 0 ] . addEventListener ( "mouseenter" , _ => {
279
+ div . addEventListener ( "mouseenter" , _ => {
272
280
div . children [ 0 ] . style . transform = "scale(1.15)"
273
281
setTimeout ( function ( ) { div . children [ 0 ] . style . transform = "" } , 200 )
274
282
} )
275
- div . children [ 0 ] . addEventListener ( "click" , _ => {
283
+ div . addEventListener ( "click" , _ => {
276
284
openInFullScreen ( )
277
285
} )
278
286
menu_items . appendChild ( div )
@@ -289,6 +297,64 @@ function in_meet_main(){
289
297
else {
290
298
window . removeEventListener ( "keydown" , hotKeyFullscreenHandler )
291
299
}
300
+
301
+ if ( Settings . PictureInPicture ) {
302
+ pictureInPictureInterval = setInterval ( _ => {
303
+ let arr = [ ...document . querySelectorAll ( "video" ) ] . filter ( x => x . style . display != "none" )
304
+ if ( arr . length > 0 ) {
305
+ if ( ! document . querySelector ( "#MeetPictureInPicture" ) ) {
306
+ let div = document . createElement ( "div" )
307
+ div . id = "MeetPictureInPicture"
308
+ div . style . height = "48px" ; div . style . width = "48px" ;
309
+ div . style . cursor = "pointer" ;
310
+ div . style . alignItems = "center" ; div . style . placeContent = "center" ;
311
+ div . style . transition = "0.2s ease" ;
312
+ div . style . borderRadius = "50px" ;
313
+ div . style . display = "none" ;
314
+ div . title = chrome . i18n . getMessage ( "pictureInPicture" )
315
+ div . innerHTML = `
316
+ <svg height="24px" width="24px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300" fill="#fff"
317
+ style="transition: 0.25s ease;">
318
+ <path id="pip_arrow" style="transform-origin: center center; transition: 0.2s" d="M202.2 27.553c-5.25 2.85-7.2 6.6-7.2 13.502s3.45 12.153 9.3 14.103c2.55.9 13.2 1.65 23.55 1.65h18.75l-51.3 51.46-51.3 51.46v7.652c0 6.752.6 8.102 4.65 11.553 3.3 2.85 6.3 3.9 10.8 3.9 6.15 0 6.6-.45 58.35-52.06l52.2-52.21v20.704c0 23.255 1.35 27.905 8.85 31.056 6.3 2.55 14.25.75 18.15-4.05 2.85-3.751 3-5.852 3-47.86v-43.96l-3.6-4.2-3.6-4.2-43.35-.3c-36.15-.3-43.8 0-47.25 1.8Z"/>
319
+ <path d="M3.9 63.709 0 67.759V267l3.75 3.6 3.6 3.751H258.3l4.35-4.35 4.35-4.352V219.59c0-48.76-.45-52.51-7.35-56.26-5.25-2.701-13.05-1.801-18 2.4l-4.65 3.9v74.715H30V89.814h123.3l4.35-4.351c6.15-6.151 6.15-15.153 0-21.304l-4.35-4.351H7.95l-4.05 3.9Z"/>
320
+ </svg>
321
+ `
322
+ div . addEventListener ( "mouseenter" , _ => {
323
+ div . style . background = "rgb(255, 255, 255, 0.05)"
324
+ } )
325
+ div . addEventListener ( "mouseleave" , _ => {
326
+ div . style . background = ""
327
+ } )
328
+ div . addEventListener ( "mouseenter" , _ => {
329
+ div . children [ 0 ] . style . transform = "scale(1.15)"
330
+ setTimeout ( function ( ) { div . children [ 0 ] . style . transform = "" } , 200 )
331
+ } )
332
+ div . addEventListener ( "click" , _ => {
333
+ openInPicture ( )
334
+ } )
335
+ document . addEventListener ( 'enterpictureinpicture' , ( ) => {
336
+ div . querySelector ( "#pip_arrow" ) . style . transform = "scale(-1, -1) translate(-115px, 60px)"
337
+ } )
338
+ document . addEventListener ( "leavepictureinpicture" , _ => {
339
+ div . querySelector ( "#pip_arrow" ) . style . transform = ""
340
+ } )
341
+ menu_items . prepend ( div )
342
+ }
343
+ else {
344
+ document . querySelector ( "#MeetPictureInPicture" ) . style . display = "inline-flex"
345
+ }
346
+ }
347
+ else {
348
+ let el = document . querySelector ( "#MeetPictureInPicture" ) ;
349
+ if ( el ) { el . style . display = "none" }
350
+ }
351
+ } , 500 )
352
+ }
353
+ else {
354
+ if ( pictureInPictureInterval ) { clearInterval ( pictureInPictureInterval ) }
355
+ let el = document . querySelector ( "#MeetPictureInPicture" )
356
+ if ( el ) { el . remove ( ) }
357
+ }
292
358
}
293
359
294
360
function openInFullScreen ( ) {
@@ -307,3 +373,13 @@ function hotKeyFullscreenHandler(e){
307
373
}
308
374
}
309
375
}
376
+
377
+ function openInPicture ( ) {
378
+ if ( document . pictureInPictureElement ) {
379
+ document . exitPictureInPicture ( ) ;
380
+ }
381
+ else {
382
+ let element = [ ...document . querySelectorAll ( "video" ) ] . filter ( x => x . style . display != "none" ) [ 0 ] ;
383
+ if ( element ) { element . requestPictureInPicture ( ) }
384
+ }
385
+ }
0 commit comments