-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtidy_original.js
3512 lines (2821 loc) · 133 KB
/
tidy_original.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name StreamYard Tidy
// @namespace http://tampermonkey.net/
// @version 0.252.00030
// @description try to take over the world!
// @updateURL https://quiz.zenidge.net/LiveScripts/StreamYardTidy.user.js
// @downloadURL https://quiz.zenidge.net/LiveScripts/StreamYardTidy.user.js
// @author Critical Cripple
// @match https://streamyard.com/*
// @grant none
// ==/UserScript==
var sVersion = '0.252.00030';
var MASTER_kazz_override = true;
var bNewSettingsSystemEnable = true;
var bMakeControlsOnTop = true;
var bMakeBackroomOnTop = true;
var bMakeBackroomBottom = true;
var bAutoAddHost = false;
var bAutoAdd = false;
var bEnabledArrowKeys = true;
var bMuteEveryone = false;
var bRemoteControlWebService = true;
var bRemoteControlChat = true;
var WS_ON = true;
var DEBUG_LOG_OBSERVER_ADD_REMOVE_ETC = false;
var checkWSInterval;
var iMS_CheckWS = 5000;
var sWSKeys = [];
var sWSAliases = [];
var sRemoteWSPerm = {};
var sRemoteChatPerm = '';
var permissionCommands = ['ME_MIC_OFF', 'ME_MIC_ON', 'ME_MIC_TOGGLE',
'ME_CAM_ON', 'ME_CAM_OFF', 'ME_CAM_TOGGLE',
'TIDY_VIEW_ON', 'TIDY_VIEW_OFF', 'TIDY_VIEW_TOGGLE',
'ADD_SELF', 'REMOVE_SELF', 'MUTE_SELF', 'UNMUTE_SELF',
'ADD_OTHER', 'REMOVE_OTHER', 'MUTE_OTHER', 'UNMUTE_OTHER'];
var bStartUp_IfHost_EnableView = true;
var bStartUp_IfHost_ShowTidyWindow = true;
var bStartUp_IfGuest_EnableView = false;
var bStartUp_IfGuest_ShowTidyWindow = false;
var bForce_RemainFullScreen = false;
var bForceFullScreen = false;
var LAST_SOLO_LAYOUT_BUTTON;
var RemotelyLogConnectDisconnectMessage = true;
var googleTagLengthChecked = 0;
var checkingGoogleTags = false;
var googleTagInterval;
//var cellStyle = 'height:270px;width:466px;';
//var cellStyle = 'height:135px;width:233px;background-color:red;';
//var iHeight = 135
//var iWidth = 233
//var iHeight = 270
//var iWidth = 466
var slots = 12;
var baseHeight = 135;
var baseWidth = 233;
var sizeAdjust = 1.00;
var nameHeight = 30;
var rows = 2;
var cols = 3;
var iGap = 0; //13; //3;
var iInfoGap = 35;
//140 = Dave - 6 People x2.0 - Font 30
//70 = Dave - 10 People x1.6 - Font 23
//3 = Everyone - Release
var iGapWidthBetween = 3; // ;140; //
//var iGapWidthBetween = 63; // 3 // ;
//var iGapWidthBetween =? 3; // 3 // ;
var iGapHeightBetween = 3; // 165; // 3 // ;
var doConnectToOBS = false;
var backgroundType = 'img';
//var sIm = 'https://i.imgur.com/DSPabnO.png';
var sIm = 'https://i.imgur.com/h4cjsdX.png';
//var sIm = 'https://i.imgur.com/7F4Xj93.jpg' // MathPig Productions
var tidyExternalWindow;
var chatWindow;
var openedChatWindow = false;
var tidySettingsWindow;
var tidySettingsWindowOpen = false;
var backgroundColour = '#FF0000';
var backgroundColourName = '#00FF00';
var foregroundColourName = '#000000';
var eslStyle = 'border: 1px solid black;'; //''; //
//var eslStyle = ''; //''; //
var iDoneX = 0;
var bIsOn = false;
var bIsHost = false;
var hostName = '';
var sssK = '';
var clientID = '';
var setupKeyUp = false;
var State = "UNKNOWN";
var nameTextSize = 20;
(function () {
'use strict';
//setInterval(doThis, 1000);
setTimeout(doThis, 3000);
// Your code here...
})();
var cells = [];
var gotWrap = false;
var tagsWrap;
var lookingForWrap = false;
var rowChatColour = 1;
var rowChatColour1 = '#c9ffd0'
var rowChatColour2 = '#d7bdff';
var rowChatColourMe = '#ffba4a';
var dave_chatTextBox;
var chatTextArea, chatSubmitBtn;
function clickDaveChatSubmit() {
// chatTextArea.value = dave_chatTextBox.value;
//chatTextArea.checkValidity();
//chatSubmitBtn.click();
sendMessageOurSelf(dave_chatTextBox.value);
dave_chatTextBox.value = '';
}
var chatDiv;
var sHangoutTitle = '';
var bProcessingFlip = false;
var bDoingTimedFlipp = false;
var lastScreenFliip = -1;
function doGoRandomScrenFlip() {
if (bDoingTimedFlipp) {
if (!bProcessingFlip) {
bProcessingFlip = true;
var elements = document.querySelectorAll('path');
var tmpClassName = '';
var tmpEle;
var screens = [];
var i, iLen;
for (i = 0, iLen = elements.length; i < iLen; i++) {
if (elements[i].getAttribute('d') == 'M21 2H3c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h7v2H8v2h8v-2h-2v-2h7c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H3V4h18v12z') {
screens.push(elements[i]);
}
/*if (elements[i].className.indexOf('ButtonBase__WrapperButton') != -1) {
var sTmp = elements[i].ariaLabel;
if (sTmp == 'Fullscreen layout') {
screens.push(elements[i]);
// got 1
}
}
*/
}
if (screens.length > 0) {
var randomNo = getRandomInt(0, screens.length);
if (randomNo == lastScreenFliip) { randomNo = getRandomInt(0, screens.length); }
if (randomNo == lastScreenFliip) { randomNo = getRandomInt(0, screens.length); }
if (randomNo == lastScreenFliip) { randomNo = getRandomInt(0, screens.length); }
if (randomNo == lastScreenFliip) { randomNo = getRandomInt(0, screens.length); }
lastScreenFliip = randomNo;
tmpEle = screens[randomNo];
try {
elements = tmpEle.parentNode.parentNode.parentNode.querySelectorAll('button');
for (i = 0, iLen = elements.length; i < iLen; i++) {
if (elements[i].ariaLabel == 'Add to stream') {
elements[i].click();
console.log('Flip...');
}
}
} catch (e) {
console.log('Failed flip...');
}
}
//ButtonBase__WrapperButton
setTimeout(doGoRandomScrenFlip, 10000);
bProcessingFlip = false;
}
}
}
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function unLoadPage() {
try {
if (openedChatWindow) {
if (chatWindow) {
chatWindow.document.title = chatWindow.document.title + ' [DISCONECTED]';
}
}
if (bIsOn) {
turnScriptOnOff();
}
} catch (e) { }
}
function SetAllCardRowWrapSettings() {
var elements = document.querySelectorAll('div');
var tmpClassName = '';
for (var i = 0, iLen = elements.length; i < iLen; i++) {
tmpClassName = elements[i].className;
if (tmpClassName.startsWith("CardRow__Row") || tmpClassName.startsWith("CardRow__Wrap") || tmpClassName.startsWith("Studio__CardRowWrap")) {
SetCardRowWrapSettings(elements[i]);
}
}
}
function SetCardRowWrapSettings(e) {
var zIndex = null, marginBottom = null, marginTop = null;
if (bIsOn) {
// add gubbins
if (bMakeBackroomOnTop) { zIndex = '9005'; }
if (bMakeBackroomBottom) { marginBottom = '0px'; marginTop = 'auto'; }
}
e.style.zIndex = zIndex;
e.style.marginBottom = marginBottom; e.style.marginTop = marginTop;
}
function formatAMPM(date) {
var hours = date.getHours();
var minutes = date.getMinutes();
var ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
hours = hours < 10 ? '0' + hours : hours;
minutes = minutes < 10 ? '0' + minutes : minutes;
var strTime = hours + ':' + minutes + ' ' + ampm;
return strTime;
}
var divCardWrap;
function getInitialNamesFromWrap() {
if (divCardWrap) {
var elements = divCardWrap.querySelectorAll('span');
var tmpClassName = '';
for (var i = 0, iLen = elements.length; i < iLen; i++) {
tmpClassName = elements[i].className;
if (tmpClassName.startsWith("Card__NameText") || (tmpClassName.indexOf('CardName__StyledText') != -1)) {
addSystemMessageToChatWindow('[Initial]', "'" + elements[i].textContent + "' Connected.");
}
}
}
}
function getNamesFromBackRoom() {
var sRes = '';
if (divCardWrap) {
var iCount = 0;
var elements = divCardWrap.querySelectorAll('span');
var tmpClassName = '';
var iNo;
for (var i = 0, iLen = elements.length; i < iLen; i++) {
tmpClassName = elements[i].className;
if (tmpClassName.startsWith("Card__NameText") || (tmpClassName.indexOf('CardName__StyledText') != -1)) {
iCount++;
sRes = sRes + iCount + '|#|' + elements[i].textContent + '||##|';
}
}
}
return sRes;
}
function FindCardWrapForPerson(sName) {
var elements = document.querySelectorAll('span');
var tmpClassName = '';
var tmpEle;
for (var i = 0, iLen = elements.length; i < iLen; i++) {
if (elements[i].className.indexOf('CardName__StyledText') != -1) {
var sTmp = elements[i].innerText;
if (sTmp == sName) {
tmpEle = elements[i].parentNode;
for (var k = 0; k < 6; k++) {
if (tmpEle.className.indexOf('CardWrap') != -1) {
return tmpEle;
} else {
tmpEle = tmpEle.parentNode;
}
}
}
}
}
}
function clickCardButtonForEveryoneButHost(sAriaLabel) {
if (divCardWrap) {
var elements = divCardWrap.querySelectorAll('span');
var tmpClassName = '';
var tmpHostName = getHostName()
var tmpName = ''
for (var i = 0, iLen = elements.length; i < iLen; i++) {
tmpClassName = elements[i].className;
//console.log('clickCardButtonForEveryoneButHost ' + tmpClassName);
if (tmpClassName.startsWith("Card__NameText") || (tmpClassName.indexOf('CardName__StyledText') != -1)) {
tmpName = elements[i].textContent;
if (tmpName != tmpHostName) {
if (clickCardButton(elements[i].textContent, sAriaLabel) == 1) {
addSystemMessageToChatWindow('[Tidy]', sAriaLabel + " '" + tmpName + "'.");
} else {
addSystemMessageToChatWindow('[Tidy]', sAriaLabel + " '" + tmpName + "' failed.");
}
}
}
}
}
}
function clickCardButton(sName, sAriaLabel) {
// sAriaLabel = 'Add ';
//console.log('clickCardButton ' + sName + ' ' + sAriaLabel);
var eWraper = FindCardWrapForPerson(sName);
if (eWraper) {
var elements = eWraper.querySelectorAll('button');
var sTmp;
for (var i = 0, iLen = elements.length; i < iLen; i++) {
try {
sTmp = elements[i].ariaLabel;
if (sTmp.indexOf(sAriaLabel) != -1) {
elements[i].click();
return 1;
}
} catch (e) { }
}
return 3;
} else {
return 2;
}
}
function getParentNodeWithClass(e, sName) {
var tmpClassName = '';
var tryParent = true;
try {
tmpClassName = e.className;
//console.log('getParentNodeWithClass: ' + sName + ' / ' + tmpClassName);
if (tmpClassName.indexOf(sName) != -1) {
return e;
}
} catch (e) { }
if (tryParent) {
if (e.parentNode) {
return getParentNodeWithClass(e.parentNode, sName);
}
}
}
function processCard__Wrap(e) {
//console.log('processCard__Wrap');
if (!divCardWrap) { divCardWrap = getParentNodeWithClass(e.parentNode, 'Cards__Wrap'); }
var elements = e.querySelectorAll('span');
var tmpClassName = '';
for (var i = 0, iLen = elements.length; i < iLen; i++) {
tmpClassName = elements[i].className;
if (tmpClassName.startsWith("Card__NameText") || (tmpClassName.indexOf('CardName__StyledText') != -1)) {
if (hostName == '') {
// we should never get here anymore, it should be picked up from the GoogleTags
addSystemMessageToChatWindow(formatAMPM(new Date), "'" + hostName + "' set in processCard__Wrap.");
hostName = elements[i].textContent;
//
}
var sName = elements[i].textContent;
//console.log('found: ' + sName);
addSystemMessageToChatWindow(formatAMPM(new Date), "'" + sName + "' Connected.");
if (RemotelyLogConnectDisconnectMessage) { if (bIsHost) { sendMessageOurSelf(sName + ' entered the backroom.'); } }
if (bAutoAdd || bAutoAddHost) { DelayedAddToStream(sName, elements[i].parentNode.parentNode, 1); }
} else if (tmpClassName.startsWith("Card__BottomIconWrap")) {
// alert('found: ' + elements[i].innerHTML);
}
}
}
function doesNodeContainButtonCalled(eWraper, sButtonName) {
if (eWraper) {
var elements = eWraper.querySelectorAll('button');
var sTmp;
for (var i = 0, iLen = elements.length; i < iLen; i++) {
try {
sTmp = elements[i].ariaLabel;
if (sTmp.indexOf(sButtonName) != -1) {
return true;
}
} catch (e) { }
}
}
return false;
}
function DelayedAddToStream(sName, e, iTryNo) {
// Devices not connected
if ((MASTER_kazz_override) && (sName == 'kazz')) { return; }
if (e) {
if (e.innerHTML.indexOf('Devices not connected') == -1) {
var addResult;
if (sName != getHostName()) {
if (bAutoAdd) {
if (doesNodeContainButtonCalled(e.parentNode.parentNode, 'Remove ')) {
// person is already in the stream
addToChatWindow(formatAMPM(new Date), '[Tidy]', sName + ' Already in the stream.');
} else {
addResult = clickCardButton(sName, 'Add ');
switch (addResult) {
case 1: addToChatWindow(formatAMPM(new Date), '[Tidy]', 'Automatically added ' + sName); break;
case 2: addToChatWindow(formatAMPM(new Date), '[Tidy]', 'Failed to add ' + sName); if (RemotelyLogConnectDisconnectMessage) { sendMessageOurSelf('Failed to add ' + sName) } break;
case 3: if (iTryNo < 50) {
setTimeout(function () { DelayedAddToStream(sName, e, iTryNo + 1); }, 2500);
} else {
addToChatWindow(formatAMPM(new Date), '[Tidy]', 'Failed to add ' + sName + ' tried ' + iTryNo + ' times'); if (RemotelyLogConnectDisconnectMessage) { sendMessageOurSelf('Failed to add ' + sName) }
} break;
}
}
/*
if (clickCardButton(sName, 'Add ') == 1) {
addToChatWindow(formatAMPM(new Date),'[Tidy]','Automatically added ' + sName);
} else {
}
*/
}
} else {
if (bAutoAddHost) {
if (doesNodeContainButtonCalled(e.parentNode.parentNode, 'Remove ')) {
// person is already in the stream
addToChatWindow(formatAMPM(new Date), '[Tidy]', sName + ' Host already in the stream.');
} else {
addResult = clickCardButton(sName, 'Add ');
switch (addResult) {
case 1: addToChatWindow(formatAMPM(new Date), '[Tidy]', 'Automatically added host' + sName); break;
case 2: addToChatWindow(formatAMPM(new Date), '[Tidy]', 'Failed to add host' + sName); break;
case 3: if (iTryNo < 50) {
setTimeout(function () { DelayedAddToStream(sName, e, iTryNo + 1); }, 2500);
} else {
addToChatWindow(formatAMPM(new Date), '[Tidy]', 'Failed to add host' + sName + ' tried ' + iTryNo + ' times');
} break;
}
}
} else {
addToChatWindow(formatAMPM(new Date), '[Tidy]', 'Skipping autoadd for host ' + sName);
}
}
} else {
setTimeout(function () { DelayedAddToStream(sName, e, iTryNo + 1); }, 2500);
addToChatWindow(formatAMPM(new Date), '[Tidy]', 'Delaying add, waiting for devices for ' + sName);
}
}
}
function processCard__Wrap_Remove(e) {
//console.log('processCard__Wrap_Remove');
var elements = e.querySelectorAll('span');
var tmpClassName = '';
for (var i = 0, iLen = elements.length; i < iLen; i++) {
tmpClassName = elements[i].className;
if (tmpClassName.startsWith("Card__NameText") || (tmpClassName.indexOf('CardName__StyledText') != -1)) {
//console.log('found: ' + elements[i].innerHTML);
addSystemMessageToChatWindow(formatAMPM(new Date), "'" + elements[i].textContent + "' Removed.");
if (RemotelyLogConnectDisconnectMessage) {
sendMessageOurSelf(elements[i].textContent + ' left the back room.')
}
} else if (tmpClassName.startsWith("Card__BottomIconWrap")) {
// alert('found: ' + elements[i].innerHTML);
}
}
}
var buttons_soloLayout, buttons_thinLayout, buttons_groupLayout, buttons_leaderLayout,
buttons_smallScreenLayout, buttons_largeScreenLayout, buttons_fullScreenLayout;
var buttons_tab_chat;
var private_chat_master_div;
var muteMeButton, camMeButton;
function getStreamButtons() {
var noGot = 0;
var elements = document.querySelectorAll('button');
var tmpClassName = '';
var layoutButtonType;
var addEvent = false;
for (var i = 0, iLen = elements.length; i < iLen; i++) {
layoutButtonType = getLayoutButtonType(elements[i]);
if (layoutButtonType != -1) {
switch (layoutButtonType) {
case 1: buttons_soloLayout = elements[i]; addEvent = true; break;
case 2: buttons_thinLayout = elements[i]; addEvent = true; break;
case 3: buttons_groupLayout = elements[i]; addEvent = true; break;
case 4: buttons_leaderLayout = elements[i]; addEvent = true; break;
case 5: buttons_smallScreenLayout = elements[i]; addEvent = true; break;
case 6: buttons_largeScreenLayout = elements[i]; addEvent = true; break;
case 7: buttons_fullScreenLayout = elements[i]; addEvent = true; break;
case 21: muteMeButton = elements[i]; addEvent = true; break;
case 22: camMeButton = elements[i]; addEvent = true; break;
}
noGot++; // REMOVED XX1 - observer.observe(elements[i], config);
if (addEvent) {
//var btnType = layoutButtonType;
//elements[i].addEventListener("click", function() {changedLayoutClicked(btnType, this);} );
addLayoutClickHandler(elements[i], layoutButtonType);
addEvent = false;
}
}
}
try {
buttons_tab_chat = document.getElementById('broadcast-aside-tab-chat');
private_chat_master_div = document.getElementById('broadcast-aside-content-chat');
buttons_tab_chat.click();
} catch (e) { }
return noGot;
}
function addLayoutClickHandler(e, btnType) {
e.addEventListener("click", function () { changedLayoutClicked(btnType, this, true); });
}
function getAriaLabel(e) {
var aria = '';
try { aria = e.getAttribute('aria-label'); aria = '' + aria; } catch (e) { aria = ''; }
return aria;
}
function getLayoutButtonType(e) {
var aria = (getAriaLabel(e) + '').toLowerCase();
//console.log('getLayoutButtonType: ' + aria);
if (aria.startsWith('solo layout')) {
return 1;
} else if (aria.startsWith('thin layout')) {
return 2;
} else if (aria.startsWith('group layout')) {
return 3;
} else if (aria.startsWith('leader layout')) {
return 4;
} else if (aria.startsWith('small screen layout')) {
return 5;
} else if (aria.startsWith('large screen layout')) {
return 6;
} else if (aria.startsWith('full screen')) {
return 7;
} else if (aria.indexOf('unmute microphone') != -1) {
return 21;
} else if (aria.indexOf('mute microphone') != -1) {
return 21;
} else if (aria.indexOf('turn on camera') != -1) {
return 22;
} else if (aria.indexOf('turn off camera') != -1) {
return 22;
} else { return -1; }
}
var currentLayout = '';
var lastLayoutByChoice = -1;
function cardSoloLayoutClicked(e) {
//console.log('Aria label: ' + (e.ariaLabel + '').toLowerCase())
if ((e.ariaLabel + '').toLowerCase().indexOf('exit') != -1) {
//console.log('exited solo layout');
LAST_SOLO_LAYOUT_BUTTON = false;
} else {
//console.log('entered solo layout');
LAST_SOLO_LAYOUT_BUTTON = e;
}
}
/*
function changedLayoutNOTClicked(layoutButtonType,e) {
console.log('changedLayoutNOTClicked current: ' + currentLayout + ', LBC: ' + lastLayoutByChoice + ', new: ' + layoutButtonType);
if (layoutButtonType != -1) {
if (lastLayoutByChoice != layoutButtonType) {
if (bForce_RemainFullScreen && currentLayout == 'buttons_soloLayout') {
console.log('clicking solo layout to prevent removal.: ' + LAST_SOLO_LAYOUT_BUTTON);
buttons_soloLayout.click();
//currentLayout = 'buttons_soloLayout';
//lastLayoutByChoice = 1;
} else {
switch(layoutButtonType) {
case 1: currentLayout = 'buttons_soloLayout'; break;
case 2: currentLayout = 'buttons_thinLayout'; break;
case 3: currentLayout = 'buttons_groupLayout'; break;
case 4: currentLayout = 'buttons_leaderLayout'; break;
case 5: currentLayout = 'buttons_smallScreenLayout'; break;
case 6: currentLayout = 'buttons_largeScreenLayout'; break;
case 7: currentLayout = 'buttons_fullScreenLayout'; break;
//default: alert('unknown btn:' + layoutButtonType);
}
//console.log('Layout changed NOT by choice to : ' + layoutButtonType);
}
}
}
}
*/
/*function forceFullScreenIfNeeded(newCurrentLayout, newLastLayoutByChoice, fromEvent) {
if (bForce_RemainFullScreen && lastLayoutByChoice == 1) {
buttons_soloLayout.click();
} else {
currentLayout = newCurrentLayout;
lastLayoutByChoice = newLastLayoutByChoice;
}
}*/
function changedLayoutClicked(layoutButtonType, e, fromEvent) {
//console.log('changedLayoutClicked current: ' + currentLayout + ', LBC: ' + lastLayoutByChoice + ', new: ' + layoutButtonType + ', fromEvent: ' + fromEvent);
if (layoutButtonType != -1) {
if (bForceFullScreen) {
if (layoutButtonType != 1) { buttons_soloLayout.click(); }
} else {
switch (layoutButtonType) {
case 1: currentLayout = 'buttons_soloLayout'; lastLayoutByChoice = layoutButtonType; break;
case 2: currentLayout = 'buttons_thinLayout'; lastLayoutByChoice = layoutButtonType; break;
case 3: currentLayout = 'buttons_groupLayout'; lastLayoutByChoice = layoutButtonType; break;
case 4: currentLayout = 'buttons_leaderLayout'; lastLayoutByChoice = layoutButtonType; break;
case 5: currentLayout = 'buttons_smallScreenLayout'; lastLayoutByChoice = layoutButtonType; break;
case 6: currentLayout = 'buttons_largeScreenLayout'; lastLayoutByChoice = layoutButtonType; break;
case 7: currentLayout = 'buttons_fullScreenLayout'; lastLayoutByChoice = layoutButtonType; break;
//default: alert('unknown btn:' + layoutButtonType);
}
}
}
//console.log('Layout changed by choice to : ' + layoutButtonType);
}
/*
function GrabInitialVideos() {
showHideOuterDiv();
GrabVideos();
}
*/
function GrabVideos() {
var elements = document.querySelectorAll('div');
var i, iLen;
var foundStreams = [];
var foundNo = 0;
var tmpClassName = '';
for (i = 0, iLen = elements.length; i < iLen; i++) {
tmpClassName = elements[i].className;
if (tmpClassName.startsWith("Stream__Wrap")) {
foundStreamVideo(elements[i])
} else if (tmpClassName.indexOf('Video__Wrap') != -1) {
elements[i].setAttribute('style', 'z-index:auto;');
var SubElements = elements[i].querySelectorAll('img');
for (var iSub = 0, iSubLen = SubElements.length; iSub < iSubLen; iSub++) {
if (SubElements[iSub].className.startsWith("OverlayImage__StyledImage")) {
SubElements[iSub].setAttribute('style', 'visibility:hidden;');
}
}
} else if (tmpClassName.startsWith("GhostWrapper")) {
elements[i].style.display = 'none';
elements[i].style.visibility = 'hidden';
}
}
}
function changeZoom(v) {
sizeAdjust = 1.00 * v;
window.writeCookie('davesiz', sizeAdjust);
iHeight = Math.round(baseHeight * sizeAdjust);
iWidth = Math.round(baseWidth * sizeAdjust);
resizeExisting();
resizeEmptySlots();
}
function resizeExisting() {
// assuming new sizes have been set.
outerDiv.style.width = ((cols * (iWidth + iGapWidthBetween) + iGap)) + 'px';
outerDiv.style.height = (((rows) * (iHeight + iGap + iGap + nameHeight)) + iGap) + 'px';
var elements = document.querySelectorAll('div');
var i, iLen;
var foundStreams = [];
var foundNo = 0;
var tmpClassName = '';
for (i = 0, iLen = elements.length; i < iLen; i++) {
tmpClassName = elements[i].className;
if (tmpClassName.startsWith("Stream__Wrap")) {
try {
var vals = elements[i].getAttribute('currentpos').split("|");
var iRow = parseInt(vals[0]);
var iCol = parseInt(vals[1]);
setStreamPosition(elements[i], iRow, iCol, document.getElementById('StreamerName-R' + iRow + '-C' + iCol).textContent);
} catch (e) {
}
}
}
}
function setStreamPosition(e, useRow, useCol, streamerName) {
var iLeft = iGap + (useCol * (iWidth + iGapWidthBetween));
var iTop = iGap + (useRow * (iHeight + iGap + nameHeight + iGapHeightBetween));
var pos = useRow + "|" + useCol;
e.setAttribute('currentpos', pos);
e.setAttribute('style', 'position: fixed; opacity: 1; z-index:1299; top:' + iTop + 'px; left:' + iLeft + 'px; width:' + iWidth + 'px; height:' + iHeight + 'px;');
var txt = document.getElementById('StreamerName-R' + useRow + '-C' + useCol);
txt.innerHTML = streamerName;
setStreamPropopertiesWeLike(e);
}
var masterdiv;
var outerDiv;
var moveSelect;
//var iHeight = 337.5
//var iWidth = 582.5
var iHeight = Math.round(baseHeight * sizeAdjust);
var iWidth = Math.round(baseWidth * sizeAdjust);
var buttonDivs = [];
var bShowNameUnder = true;
var tmpTop = 0;
var tmpLeft = iGap;
var tmpCol = 0;
var tmpRow = 0;
var selectedRow = 0;
var selectedCol = 0;
function getCurrentElementInPlace(findPos) {
var elements = document.querySelectorAll('div');
var i, iLen;
for (i = 0, iLen = elements.length; i < iLen; i++) {
if (elements[i].className.startsWith("Stream__Wrap")) {
try {
var chkPos = elements[i].getAttribute('currentpos');
if (chkPos == findPos) {
return elements[i];
}
} catch (e) {
}
}
}
return false;
}
function moveStream(fromRow, fromCol, toRow, toCol) {
var txtFrom, txtTo;
var sTmp;
// console.log('moveStream: fr:' + fromRow + ', fc:' + fromCol + ', tr:' + toRow + ', tc:' + toCol + ', cols:' + cols + ', rows:' + rows);
if (toRow != fromRow) { if (toRow < 0 || toRow >= rows) return false; }
if (toCol != fromCol) { if (toCol < 0 || toCol >= cols) return false; }
var oFrom = getCurrentElementInPlace(fromRow + "|" + fromCol);
var oTo = getCurrentElementInPlace(toRow + "|" + toCol);
if (oFrom || oTo) {
txtFrom = document.getElementById('StreamerName-R' + fromRow + '-C' + fromCol);
txtTo = document.getElementById('StreamerName-R' + toRow + '-C' + toCol);
sTmp = txtFrom.textContent;
txtFrom.innerHTML = txtTo.textContent;
txtTo.innerHTML = sTmp;
if (oFrom) { setStreamPosition(oFrom, toRow, toCol, txtTo.textContent); }
if (oTo) { setStreamPosition(oTo, fromRow, fromCol, txtFrom.textContent); }
} else {
txtFrom = document.getElementById('StreamerName-R' + fromRow + '-C' + fromCol);
txtTo = document.getElementById('StreamerName-R' + toRow + '-C' + toCol);
sTmp = txtFrom.textContent;
txtFrom.innerHTML = txtTo.textContent;
txtTo.innerHTML = sTmp;
}
return true;
}
function removeStreamVideo(e) {
//e.setAttribute('currentpos', '');
}
var OrigTextFontSize = '';
var OrigTextPadding = '';
var OrigTextColor = '';
var OrigTextHeight = '';
var OrigMicHeight = '';
var OrigMicWidth = '';
var OrigMicFill = '';
function setMicNameFieldFromSVG(e) {
//console.log('setMicNameFieldFromSVG');
if (e.className.baseVal.indexOf('__NameMic') != -1) {
if ((e.style.width != nameTextSize + 'px') || (e.style.height != nameTextSize + 'px')) {
setOrigStyle(e);
OrigMicHeight = e.style.height;
OrigMicWidth = e.style.width;
OrigMicFill = e.style.fill;
if (bIsOn) {
e.style.width = nameTextSize + 'px'; // '26px'
e.style.height = nameTextSize + 'px'; // '26px'
e.style.fill = foregroundColourName;
}
}
}
}
function setNameElement(e) {
//e.setAttribute("style", '--dave:yes;' + e.style.cssText);
//e.style.dave = 'yes';
if ((e.style.fontSize != nameTextSize + 'px')) {
OrigTextFontSize = e.style.fontSize;
OrigTextPadding = e.style.padding;
OrigTextColor = e.style.color;
OrigTextHeight = e.style.height;
if (bIsOn) {
e.style.fontSize = nameTextSize + 'px';
e.style.color = foregroundColourName;
e.style.height = nameHeight + 'px'
e.style.padding = '0 5px 0 5px';
}
}
}
function resetNameComponents() {
var elements = document.querySelectorAll('svg');
var i, iLen;
for (i = 0, iLen = elements.length; i < iLen; i++) {
if (((elements[i].className) + '').startsWith("[object SVGAnimatedString]")) { setMicNameFieldFromSVG(elements[i]); }
}
elements = document.querySelectorAll('div');
for (i = 0, iLen = elements.length; i < iLen; i++) {
if (((elements[i].className) + '').indexOf("__NameWrap") != -1) {
setOrigStyle(elements[i]);
var eleName;
for (var iSubEle = 0; iSubEle < elements[i].children.length; iSubEle++) {
if (((elements[i].children[iSubEle].className) + '').indexOf("__NameText") != -1) {
eleName = elements[i].children[iSubEle];
}
}
setOrigStyle(eleName);
//console.log("Set OrigTextCSS 1");
//OrigTextCSS = e.getAttribute('style');
setNameElement(eleName);
elements[i].style.borderRadius = '0px 0px 0px 0px'
elements[i].style.backgroundColor = backgroundColourName;
elements[i].style.color = foregroundColourName;
try { elements[i].children[0].style.color = foregroundColourName; } catch (err) { }
if (bShowNameUnder) {
elements[i].style.position = 'fixed';
//parseInt(a);
elements[i].style.height = nameHeight + 'px'
elements[i].style.fontSize = nameTextSize + 'px'; //
}
}
}
}
function setOrigStyle(e) {
try {
var sNope = e.getAttribute('origstyle');
if (!sNope) { e.setAttribute('origstyle', e.getAttribute('style')); }
} catch (e) {
e.setAttribute('origstyle', e.getAttribute('style'));
}
}
function resetOrigStyle(e) {
try {
var sGot = e.getAttribute('origstyle');
if (sGot) { e.setAttribute('style', sGot); }
} catch (e) { }
}
function resetOrigStyles() {
var elements = document.querySelectorAll('svg');
var i, iLen;
for (i = 0, iLen = elements.length; i < iLen; i++) {
if (((elements[i].className) + '').startsWith("[object SVGAnimatedString]")) {
if (elements[i].className.baseVal.indexOf('__NameMic') != -1) {
resetOrigStyle(elements[i]);
elements[i].style.width = OrigMicWidth;
elements[i].style.height = OrigMicHeight;
elements[i].style.fill = OrigMicFill;
}
}
}
elements = document.querySelectorAll('div');
for (i = 0, iLen = elements.length; i < iLen; i++) {
if (((elements[i].className) + '').indexOf("__NameWrap") != -1) {
resetOrigStyle(elements[i]);
}
}
elements = document.querySelectorAll('p');