Skip to content

Commit 2f3e31e

Browse files
committed
aded pictute in picture
1 parent f7edf7c commit 2f3e31e

File tree

6 files changed

+100
-10
lines changed

6 files changed

+100
-10
lines changed

chrome/_locales/en/messages.json

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
"volume": {
3838
"message": "Volume"
3939
},
40+
"pictureInPicture":{
41+
"message": "Picture in Picture"
42+
},
4043

4144
"additionally": {
4245
"message": "Additionally"

chrome/_locales/ru/messages.json

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
"volume": {
3838
"message": "Громкость"
3939
},
40+
"pictureInPicture":{
41+
"message": "Картинка в Картинке"
42+
},
4043

4144
"additionally": {
4245
"message": "Дополнительно"

chrome/_locales/uk/messages.json

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
"volumeController": {
3838
"message": "Гучність"
3939
},
40+
"pictureInPicture":{
41+
"message": "Картинка в Картинці"
42+
},
4043

4144
"additionally": {
4245
"message": "Додатково"

chrome/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"manifest_version": 3,
3-
"version": "1.0",
3+
"version": "1.1",
44
"name": "__MSG_extName__",
55
"description": "__MSG_extDesc__",
66
"default_locale": "en",

chrome/menu/options.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ <h2>__MSG_settings__</h2>
7474
<input class="form-check-input" type="checkbox" name="volumeController" checked>
7575
<a class="cursor">__MSG_volumeController__</a>
7676
</label>
77+
78+
<label>
79+
<input class="form-check-input" type="checkbox" name="PictureInPicture" checked>
80+
<a class="cursor">__MSG_pictureInPicture__</a>
81+
</label>
7782
</details>
7883

7984

@@ -88,7 +93,7 @@ <h2>__MSG_settings__</h2>
8893
</a>
8994

9095
<span style="margin-top:2px;">
91-
<img src="https://shields.io/badge/version-v1.0-blue">
96+
<img src="https://shields.io/badge/version-v1.1-blue">
9297
</span>
9398
</p>
9499

chrome/script.js

+84-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var Settings = {}
22
chrome.storage.sync.get({ AutoJoin: false, AutoMute: false, AutoSkipAlerts: false,
33
Fullscreen: true, fullscreen_hotkey: true, volumeController: true,
4+
PictureInPicture: true,
45
account: null, language: null
56
}, results => {
67
Settings = results;
@@ -9,7 +10,7 @@ chrome.storage.sync.get({ AutoJoin: false, AutoMute: false, AutoSkipAlerts: fals
910

1011
chrome.storage.sync.onChanged.addListener(function (changes, namespace) {
1112
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
1314
}, results => { Settings = results; main(); });
1415
});
1516

@@ -110,17 +111,25 @@ function get_mic_and_vid_controls(){
110111
return false
111112
}
112113

114+
var pictureInPictureInterval;
113115
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+
114124
if (Settings.volumeController){
115125
if (!document.querySelector("#volumeController")){
116126
var currentVolume = 1;
117-
let menu_items = document.querySelector('div[jsname="tc8lHd"]')
118127
let div = document.createElement("div")
119128
div.id = "volumeController"
120129
div.style.height = "48px"; div.style.width = "48px";
121130
div.style.cursor = "pointer";
122131
div.style.position = "relative";
123-
div.style.display = "flex";
132+
div.style.display = "inline-flex";
124133
div.style.alignItems = "center"; div.style.placeContent = "center";
125134
div.style.borderRadius = "50px";
126135
div.style.transition = "0.2s ease";
@@ -233,7 +242,7 @@ function in_meet_main(){
233242
setInterval(_=>{
234243
setAllVolume(currentVolume)
235244
}, 200)
236-
menu_items.appendChild(div)
245+
menu_items.prepend(div)
237246
}
238247
}
239248
else{
@@ -243,12 +252,11 @@ function in_meet_main(){
243252

244253
if (Settings.Fullscreen){
245254
if (!document.querySelector("#MeetFullScreen")){
246-
let menu_items = document.querySelector('div[jsname="tc8lHd"]')
247255
let div = document.createElement("div")
248256
div.id = "MeetFullScreen"
249257
div.style.height = "48px"; div.style.width = "48px";
250258
div.style.cursor = "pointer";
251-
div.style.display = "flex";
259+
div.style.display = "inline-flex";
252260
div.style.alignItems = "center"; div.style.placeContent = "center";
253261
div.style.transition = "0.2s ease";
254262
div.style.borderRadius = "50px";
@@ -268,11 +276,11 @@ function in_meet_main(){
268276
div.addEventListener("mouseleave", _=> {
269277
div.style.background = ""
270278
})
271-
div.children[0].addEventListener("mouseenter", _=> {
279+
div.addEventListener("mouseenter", _=> {
272280
div.children[0].style.transform = "scale(1.15)"
273281
setTimeout(function(){ div.children[0].style.transform = "" }, 200)
274282
})
275-
div.children[0].addEventListener("click", _=>{
283+
div.addEventListener("click", _=>{
276284
openInFullScreen()
277285
})
278286
menu_items.appendChild(div)
@@ -289,6 +297,64 @@ function in_meet_main(){
289297
else{
290298
window.removeEventListener("keydown", hotKeyFullscreenHandler)
291299
}
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+
}
292358
}
293359

294360
function openInFullScreen(){
@@ -307,3 +373,13 @@ function hotKeyFullscreenHandler(e){
307373
}
308374
}
309375
}
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

Comments
 (0)