-
Notifications
You must be signed in to change notification settings - Fork 5
/
viewtubeplus.user.js
2119 lines (1919 loc) · 84.8 KB
/
viewtubeplus.user.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 ViewTube+
// @version 2024.06.09
// @description Watch videos from video sharing websites without Flash Player.
// @author sebaro
// @namespace http://sebaro.pro/viewtube
// @downloadURL https://gitlab.com/sebaro/viewtube/raw/master/viewtubeplus.user.js
// @updateURL https://gitlab.com/sebaro/viewtube/raw/master/viewtubeplus.user.js
// @icon https://gitlab.com/sebaro/viewtube/raw/master/viewtube.png
// @include http://video.repubblica.it/*
// @include https://video.repubblica.it/*
// @include http://*.gelocal.it/*
// @include https://*.gelocal.it/*
// @include http://video.corriere.it/*
// @include https://video.corriere.it/*
// @include http://www.altoadige.it/*
// @include https://www.altoadige.it/*
// @include http://www.ilfattoquotidiano.it/*
// @include https://www.ilfattoquotidiano.it/*
// @include http://www.mediasetplay.mediaset.it/*
// @include https://www.mediasetplay.mediaset.it/*
// @include http://www.youreporter.it/*
// @include https://www.youreporter.it/*
// @include https://drive.google.com/file/d/*
// @include https://docs.google.com/file/d/*
// @include http://areena.yle.fi/*
// @include https://areena.yle.fi/*
// @include http://archive.org/*
// @include http://www.archive.org/*
// @include https://archive.org/*
// @include https://www.archive.org/*
// @include http://streamable.com/*
// @include http://www.streamable.com/*
// @include https://streamable.com/*
// @include https://www.streamable.com/*
// @include http://facebook.com/*
// @include http://www.facebook.com/*
// @include https://facebook.com/*
// @include https://www.facebook.com/*
// @noframes
// @grant none
// @run-at document-end
// ==/UserScript==
/*
Copyright (C) 2010 - 2024 Sebastian Luncan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Website: http://sebaro.pro/viewtube
Contact: http://sebaro.pro/contact
*/
(function() {
// Don't run on frames or iframes
if (window.top != window.self) return;
// ==========Variables========== //
// Userscript
var userscript = 'ViewTube+';
var website = 'http://sebaro.pro/viewtube';
var contact = 'http://sebaro.pro/contact';
// Page
var page = {win: window, doc: window.document, body: window.document.body, url: window.location.href, site: window.location.hostname.match(/([^.]+)\.[^.]+$/)[1]};
// Player
var player = {};
var myPlayerWindow;
var myPlayerPanelHeight = 30;
// Features/Options
var feature = {'definition': true, 'container': true, 'openpagelink': true, 'autoplay': true, 'playdash': false, 'widesize': true, 'fullsize': true};
var option = {'embed': 'Video', 'media': 'Auto', 'definition': 'High Definition', 'container': 'MP4', 'openpagelink': false, 'autoplay': false, 'playdash': false, 'widesize': false, 'fullsize': false};
// Embed
var embedtypes = ['Video', 'Object', 'Embed', 'Protocol'];
var embedcontent = {
'Video': '<br><br>The video should be loading. If it doesn\'t load, make sure your browser supports HTML5\'s Video and this video codec. If you think it\'s a script issue, please report it <a href="' + contact + '" style="color:#00892C">here</a>.',
'Object': '<br><br>The video should be loading. If it doesn\'t load, make sure a video plugin is installed. If you think it\'s a script issue, please report it <a href="' + contact + '" style="color:#00892C">here</a>.<param name="scale" value="aspect"><param name="stretchtofit" value="true"><param name="autostart" value="true"><param name="autoplay" value="true">',
'Embed': '<br><br>The video should be loading. If it doesn\'t load, make sure a video plugin is installed. If you think it\'s a script issue, please report it <a href="' + contact + '" style="color:#00892C">here</a>.<param name="scale" value="aspect"><param name="stretchtofit" value="true"><param name="autostart" value="true"><param name="autoplay" value="true">'
};
// Media
var mediatypes = {'MP4': 'video/mp4', 'WebM': 'video/webm', 'M3U8': 'application/x-mpegURL', 'M3U8*': 'application/vnd.apple.mpegURL', 'VLC': 'application/x-vlc-plugin', 'VLC*': 'application/x-vlc-plugin'}
if (navigator.platform.indexOf('Win') != -1) {
mediatypes['WMP'] = 'application/x-ms-wmp';
mediatypes['WMP*'] = 'application/x-mplayer2';
mediatypes['QT'] = 'video/quicktime';
}
else if (navigator.platform.indexOf('Mac') != -1) {
mediatypes['QT'] = 'video/quicktime';
}
else {
mediatypes['Totem'] = 'application/x-totem-plugin';
mediatypes['Xine'] = 'application/x-xine-plugin';
}
var mediakeys = ['Auto'];
for (var mediakey in mediatypes) {
mediakeys.push(mediakey);
}
// Sources
var sources = {};
// Intervals
var intervals = [];
// ==========Functions========== //
function createMyElement(type, properties, event, listener) {
var obj = page.doc.createElement(type);
for (var propertykey in properties) {
if (propertykey == 'target') obj.setAttribute('target', properties[propertykey]);
else obj[propertykey] = properties[propertykey];
}
if (event && listener) {
obj.addEventListener(event, listener, false);
}
return obj;
}
function modifyMyElement(obj, properties, event, listener) {
for (var propertykey in properties) {
if (propertykey == 'target') obj.setAttribute('target', properties[propertykey]);
else obj[propertykey] = properties[propertykey];
}
if (event && listener) {
obj.addEventListener(event, listener, false);
}
}
function styleMyElement(obj, styles) {
for (var stylekey in styles) {
obj.style[stylekey] = styles[stylekey];
}
}
function cleanMyElement(obj, hide) {
if (hide) {
for (var i = 0; i < obj.children.length; i++) {
styleMyElement(obj.children[i], {display: 'none'});
}
}
else {
if (obj.hasChildNodes()) {
while (obj.childNodes.length >= 1) {
obj.removeChild(obj.firstChild);
}
}
}
}
function getMyElement(obj, type, from, value, child, content) {
var getObj, chObj, coObj;
var pObj = (!obj) ? page.doc : obj;
if (type == 'body') {
getObj = pObj.body;
}
else {
if (from == 'id') getObj = pObj.getElementById(value);
else if (from == 'class') getObj = pObj.getElementsByClassName(value);
else if (from == 'tag') getObj = pObj.getElementsByTagName(type);
else if (from == 'ns') {
if (pObj.getElementsByTagNameNS) getObj = pObj.getElementsByTagNameNS(value, type);
}
else if (from == 'query') {
if (child > 0) {
if (pObj.querySelectorAll) getObj = pObj.querySelectorAll(value);
}
else {
if (pObj.querySelector) getObj = pObj.querySelector(value);
}
}
}
chObj = (getObj && child >= 0) ? getObj[child] : getObj;
if (content && chObj) {
if (type == 'html' || type == 'body' || type == 'div' || type == 'option') coObj = chObj.innerHTML;
else if (type == 'object') coObj = chObj.data;
else if (type == 'img' || type == 'video' || type == 'embed') coObj = chObj.src;
else coObj = chObj.textContent;
return coObj;
}
else {
return chObj;
}
}
function appendMyElement(parent, child) {
parent.appendChild(child);
}
function removeMyElement(parent, child) {
parent.removeChild(child);
}
function replaceMyElement(parent, orphan, child) {
parent.replaceChild(orphan, child);
}
function cleanMyContent(content, unesc, extra) {
if (unesc) content = unescape(content);
content = content.replace(/\\u0025/g, '%');
content = content.replace(/\\u0026/g, '&');
content = content.replace(/\\u002F/g, '/');
content = content.replace(/\\/g, '');
content = content.replace(/\n/g, '');
if (extra) {
content = content.replace(/"/g, '\'').replace(/"/g, '\'').replace(/"/g, '\'').replace(/["“”„‘’]/g, '\'');
content = content.replace(/'/g, '\'').replace(/'/g, '\'').replace(/'/g, '\'');
content = content.replace(/&/g, 'and').replace(/&/g, 'and');
//content = content.replace(/[^\x20-\xFF]/g, '');
content = content.replace(/[\/\|]/g, '-');
content = content.replace(/[<>#:\*\?]/g, '');
content = content.replace(/^\s+|\s+$/, '').replace(/\s+/g, ' ').replace(/\.+$/g, '');
}
return content;
}
function parseMyContent(content, pattern) {
var parse, response;
content = content.replace(/(\r\n|\n|\r)/gm, '');
parse = content.match(pattern);
if (parse) {
response = (/g$/.test(pattern)) ? parse : parse[1];
}
return response;
}
function getMyContent(url, pattern) {
var urle, data, headers, xhr, response;
if (url.indexOf('|') != -1) {
headers = url.split('|')[2];
data = url.split('|')[1];
url = url.split('|')[0];
}
if (data) {
//console.log('ViewTube: POST [' + pattern + '] ' + url + '\n' + data + '\n' + headers);
urle = btoa(url + data + headers);
if (!sources[urle]) {
xhr = new XMLHttpRequest();
xhr.open('POST', url, false);
if (data.indexOf('{') != -1) {
xhr.setRequestHeader('Content-Type', 'application/json');
}
else {
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
}
if (headers) {
headers = JSON.parse(headers);
if (headers['withCredentials']) {
xhr.withCredentials = true;
delete headers['withCredentials']
}
for (var header in headers) {
xhr.setRequestHeader(header, headers[header]);
}
}
try {
xhr.send(data);
}
catch(e) {
}
sources[urle] = (xhr.responseText) ? xhr.responseText : xhr.responseXML;
}
}
else {
console.log('ViewTube: GET [' + pattern + '] ' + url + '\n' + headers);
urle = btoa(url + headers);
if (!sources[urle]) {
xhr = new XMLHttpRequest();
xhr.open('GET', url, false);
if (headers) {
headers = JSON.parse(headers);
if (headers['withCredentials']) {
xhr.withCredentials = true;
delete headers['withCredentials']
}
for (var header in headers) {
xhr.setRequestHeader(header, headers[header]);
}
}
try {
xhr.send();
}
catch(e) {
}
sources[urle] = (xhr.responseText) ? xhr.responseText : xhr.responseXML;
}
}
if (sources[urle]) {
response = sources[urle];
if (pattern) {
response = parseMyContent(response, pattern);
}
}
return response;
}
function getMyContentOld(url, pattern, clean) {
var myPageContent, myVideosParse, myVideosContent;
if (!sources[url]) {
var XHRequest = new XMLHttpRequest();
XHRequest.open('GET', url, false);
XHRequest.send();
sources[url] = (XHRequest.responseText) ? XHRequest.responseText : XHRequest.responseXML;
//console.log('Request: ' + url + ' ' + pattern);
//console.log(sources[url]);
}
if (pattern == 'TEXT') {
myVideosContent = sources[url];
}
else {
myPageContent = (sources[url]) ? sources[url] : '';
if (clean) myPageContent = cleanMyContent(myPageContent, true);
myVideosParse = myPageContent.match(pattern);
myVideosContent = (myVideosParse) ? myVideosParse[1] : null;
}
return myVideosContent;
}
function createMyPlayer() {
/* The Content */
player['contentWidth'] = player['playerWidth'];
player['contentHeight'] = player['playerHeight'] - myPlayerPanelHeight;
player['playerContent'] = createMyElement('div');
styleMyElement(player['playerContent'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px', position: 'relative', color: '#AD0000', backgroundColor: '#000000', fontFamily: 'sans-serif', fontSize: '14px', fontWeight: 'bold', textAlign: 'center'});
appendMyElement(player['playerWindow'], player['playerContent']);
/* The Video Thumbnail */
if (player['videoThumb']) {
player['contentImage'] = createMyElement('img', {src: player['videoThumb'], title: '{Click to start video playback}'}, 'click', function() {
if (player['showsOptions'] && option['embed'] != 'Protocol') {
player['showsOptions'] = false;
}
playMyVideo(!player['isPlaying']);
});
styleMyElement(player['contentImage'], {maxWidth: '100%', maxHeight: '100%', position: 'absolute', top: '0px', left: '0px', right: '0px', bottom: '0px', margin: 'auto', border: '0px', cursor: 'pointer'});
player['contentImage'].addEventListener('load', function() {
if (page.site == 'youtube') {
if (this.width < 300) {
player['videoThumb'] = this.src.replace('maxresdefault', 'mqdefault');
this.src = player['videoThumb'];
}
}
if (this.width/this.height >= player['contentWidth']/player['contentHeight']) {
this.style.width = '100%';
}
else {
this.style.height = '100%';
}
}, false);
}
/* The Panel */
player['playerPanel'] = createMyElement('div');
styleMyElement(player['playerPanel'], {width: player['playerWidth'] + 'px', height: myPlayerPanelHeight + 'px', fontFamily: 'sans-serif', fontSize: '10px', lineHeight: (myPlayerPanelHeight - 2) + 'px', backgroundColor: '#000000', textAlign: 'center', boxSizing: 'content-box'});
appendMyElement(player['playerWindow'], player['playerPanel']);
/* Panel Logo */
player['panelLogo'] = createMyElement('div', {title: '{ViewTube: click to visit the script wesite}', textContent: userscript}, 'click', function() {
page.win.location.href = website;
});
styleMyElement(player['panelLogo'], {display: 'inline-block', color: '#E24994', fontSize: '14px', fontWeight: 'bold', border: '1px solid #E24994', borderRadius: '2px', padding: '0px 4px', lineHeight: 'normal', verticalAlign: 'middle', marginRight: '10px', cursor: 'pointer', boxSizing: 'content-box'});
appendMyElement(player['playerPanel'], player['panelLogo']);
/* Panel Video Menu */
player['videoMenu'] = createMyElement('select', {title: '{Videos: select the video format for playback}'}, 'change', function() {
player['videoPlay'] = this.value;
if (player['isSaving']) {
cleanMyElement(player['buttonSaveLink'], false);
player['isSaving'] = false;
}
if (player['isPlaying']) playMyVideo(option['autoplay']);
});
styleMyElement(player['videoMenu'], {display: 'inline-block', maxWidth: '50%', height: '20px', fontFamily: 'inherit', fontSize: '14px', fontWeight: 'bold', padding: '0px 3px', overflow: 'hidden', border: '1px solid #777777', color: '#CCCCCC', backgroundColor: '#000000', lineHeight: 'normal', verticalAlign: 'middle', cursor: 'pointer', boxSizing: 'content-box'});
appendMyElement(player['playerPanel'], player['videoMenu']);
if (feature['openpagelink']) {
player['videoList']['Page Link'] = page.url;
}
var videosProgressive = [];
var videosAdaptiveHLS = [];
var videosAdaptiveDASHVideo = [];
var videosAdaptiveDASHAudio = [];
var videosAdaptiveDASHMuxed = [];
var videosExtra = [];
for (var videoCode in player['videoList']) {
if (videoCode.indexOf('Video') != -1) videosAdaptiveDASHVideo.push(videoCode);
else if (videoCode.indexOf('Audio') != -1) videosAdaptiveDASHAudio.push(videoCode);
else if (player['videoList'][videoCode] == 'DASH') videosAdaptiveDASHMuxed.push(videoCode);
else if (videoCode.indexOf('M3U8') != -1) videosAdaptiveHLS.push(videoCode);
else if (videoCode.indexOf('MP4') != -1 || videoCode.indexOf('WebM') != -1) videosProgressive.push(videoCode);
else videosExtra.push(videoCode);
}
if (videosProgressive.length > 0) {
for (var i = 0; i < videosProgressive.length; i++) {
player['videoItem'] = createMyElement('option', {value: videosProgressive[i], textContent: videosProgressive[i]});
styleMyElement(player['videoItem'], {fontSize: '14px', fontWeight: 'bold', cursor: 'pointer'});
appendMyElement(player['videoMenu'], player['videoItem']);
}
}
if (videosAdaptiveHLS.length > 0) {
player['videoItem'] = createMyElement('option', {value: 'HLS', textContent: 'HLS'});
styleMyElement(player['videoItem'], {fontSize: '14px', fontWeight: 'bold', color: '#FF0000'});
player['videoItem'].disabled = 'disabled';
appendMyElement(player['videoMenu'], player['videoItem']);
for (var i = 0; i < videosAdaptiveHLS.length; i++) {
player['videoItem'] = createMyElement('option', {value: videosAdaptiveHLS[i], textContent: videosAdaptiveHLS[i]});
styleMyElement(player['videoItem'], {fontSize: '14px', fontWeight: 'bold', cursor: 'pointer'});
appendMyElement(player['videoMenu'], player['videoItem']);
}
}
if (videosAdaptiveDASHVideo.length > 0) {
player['videoItem'] = createMyElement('option', {value: 'DASH (Video Only)', textContent: 'DASH (Video Only)'});
styleMyElement(player['videoItem'], {fontSize: '14px', fontWeight: 'bold', color: '#FF0000'});
player['videoItem'].disabled = 'disabled';
appendMyElement(player['videoMenu'], player['videoItem']);
for (var i = 0; i < videosAdaptiveDASHVideo.length; i++) {
player['videoItem'] = createMyElement('option', {value: videosAdaptiveDASHVideo[i], textContent: videosAdaptiveDASHVideo[i]});
styleMyElement(player['videoItem'], {fontSize: '14px', fontWeight: 'bold', cursor: 'pointer'});
appendMyElement(player['videoMenu'], player['videoItem']);
}
}
if (videosAdaptiveDASHAudio.length > 0) {
player['videoItem'] = createMyElement('option', {value: 'DASH (Audio Only)', textContent: 'DASH (Audio Only)'});
styleMyElement(player['videoItem'], {fontSize: '14px', fontWeight: 'bold', color: '#FF0000'});
player['videoItem'].disabled = 'disabled';
appendMyElement(player['videoMenu'], player['videoItem']);
for (var i = 0; i < videosAdaptiveDASHAudio.length; i++) {
player['videoItem'] = createMyElement('option', {value: videosAdaptiveDASHAudio[i], textContent: videosAdaptiveDASHAudio[i]});
styleMyElement(player['videoItem'], {fontSize: '14px', fontWeight: 'bold', cursor: 'pointer'});
appendMyElement(player['videoMenu'], player['videoItem']);
}
}
if (videosAdaptiveDASHMuxed.length > 0) {
feature['playdash'] = true;
if (option['playdash']) {
player['videoItem'] = createMyElement('option', {value: 'DASH (Video With Audio)', textContent: 'DASH (Video With Audio)'});
styleMyElement(player['videoItem'], {fontSize: '14px', fontWeight: 'bold', color: '#FF0000'});
player['videoItem'].disabled = 'disabled';
appendMyElement(player['videoMenu'], player['videoItem']);
for (var i = 0; i < videosAdaptiveDASHMuxed.length; i++) {
player['videoItem'] = createMyElement('option', {value: videosAdaptiveDASHMuxed[i], textContent: videosAdaptiveDASHMuxed[i]});
styleMyElement(player['videoItem'], {fontSize: '14px', fontWeight: 'bold', cursor: 'pointer'});
appendMyElement(player['videoMenu'], player['videoItem']);
}
}
else {
for (var videoCode in player['videoList']) {
if (player['videoList'][videoCode] == 'DASH') delete player['videoList'][videoCode];
}
}
}
if (videosExtra.length > 0) {
player['videoItem'] = createMyElement('option', {value: 'Extra', textContent: 'Extra'});
styleMyElement(player['videoItem'], {fontSize: '14px', fontWeight: 'bold', color: '#FF0000'});
player['videoItem'].disabled = 'disabled';
appendMyElement(player['videoMenu'], player['videoItem']);
for (var i = 0; i < videosExtra.length; i++) {
player['videoItem'] = createMyElement('option', {value: videosExtra[i], textContent: videosExtra[i]});
styleMyElement(player['videoItem'], {fontSize: '14px', fontWeight: 'bold', cursor: 'pointer'});
appendMyElement(player['videoMenu'], player['videoItem']);
}
}
/* Panel Options Button */
player['buttonOptions'] = createMyElement('div', {title: '{Options: click to show the available options}'}, 'click', function() {
if (player['showsOptions']) {
player['showsOptions'] = false;
playMyVideo(option['autoplay']);
}
else {
player['showsOptions'] = true;
playMyVideo(false);
createMyOptions();
}
});
styleMyElement(player['buttonOptions'], {width: '1px', height: '8px', borderTop: '4px dotted #CCCCCC', borderBottom: '4px dotted #CCCCCC', borderLeft: '4px dotted #CCCCCC', display: 'inline-block', lineHeight: 'normal', verticalAlign: 'middle', marginLeft: '20px', cursor: 'pointer', boxSizing: 'content-box'});
appendMyElement(player['playerPanel'], player['buttonOptions']);
/* Panel Play Button */
player['buttonPlay'] = createMyElement('div', {title: '{Play/Stop: click to start/stop video playback}'}, 'click', function() {
if (player['showsOptions'] && option['embed'] != 'Protocol') {
player['showsOptions'] = false;
}
playMyVideo(!player['isPlaying']);
});
styleMyElement(player['buttonPlay'], {width: '0px', height: '0px', display: 'inline-block', borderTop: '8px solid transparent', borderBottom: '8px solid transparent', borderLeft: '15px solid #CCCCCC', lineHeight: 'normal', verticalAlign: 'middle', marginLeft: '20px', cursor: 'pointer', boxSizing: 'content-box'});
appendMyElement(player['playerPanel'], player['buttonPlay']);
/* Panel Save Button */
player['buttonSave'] = createMyElement('div', {title: '{Save: click to download the selected video format}'}, 'click', function() {
saveMyVideo();
});
styleMyElement(player['buttonSave'], {width: '0px', height: '0px', display: 'inline-block', borderLeft: '8px solid transparent', borderRight: '8px solid transparent', borderTop: '15px solid #CCCCCC', lineHeight: 'normal', verticalAlign: 'middle', marginTop: '1px', marginLeft: '20px', cursor: 'pointer', boxSizing: 'content-box'});
appendMyElement(player['playerPanel'], player['buttonSave']);
/* Panel Save Button Link */
player['buttonSaveLink'] = createMyElement('div', {title: '{Save: right click & save as to download the selected video format}'});
styleMyElement(player['buttonSaveLink'], {display: 'inline-block', color: '#CCCCCC', fontSize: '14px', fontWeight: 'bold', lineHeight: 'normal', verticalAlign: 'middle', marginLeft: '5px', marginBottom: '2px', boxSizing: 'content-box'});
appendMyElement(player['playerPanel'], player['buttonSaveLink']);
/* Panel Widesize Button */
if (!player['playerWideWidth']) {
feature['widesize'] = false;
option['widesize'] = false;
}
if (feature['widesize']) {
player['buttonWidesize'] = createMyElement('div', {title: '{Widesize: click to enter player widesize or return to normal size}'}, 'click', function() {
option['widesize'] = (option['widesize']) ? false : true;
setMyOptions('widesize', option['widesize']);
resizeMyPlayer('widesize');
});
styleMyElement(player['buttonWidesize'], {border: '2px solid #CCCCCC', display: 'inline-block', lineHeight: 'normal', verticalAlign: 'middle', marginLeft: '20px', cursor: 'pointer', boxSizing: 'content-box'});
if (option['widesize']) styleMyElement(player['buttonWidesize'], {width: '16px', height: '8px'});
else styleMyElement(player['buttonWidesize'], {width: '20px', height: '10px'});
appendMyElement(player['playerPanel'], player['buttonWidesize']);
}
/* Panel Fullsize Button */
if (feature['fullsize']) {
player['buttonFullsize'] = createMyElement('div', {title: '{Fullsize: click to enter player fullsize or return to normal size}'}, 'click', function() {
option['fullsize'] = (option['fullsize']) ? false : true;
setMyOptions('fullsize', option['fullsize']);
resizeMyPlayer('fullsize');
});
styleMyElement(player['buttonFullsize'], {width: '20px', height: '14px', display: 'inline-block', lineHeight: 'normal', verticalAlign: 'middle', marginLeft: '20px', cursor: 'pointer', boxSizing: 'content-box'});
if (option['fullsize']) styleMyElement(player['buttonFullsize'], {border: '2px solid #CCCCCC'});
else styleMyElement(player['buttonFullsize'], {border: '2px dashed #CCCCCC'});
appendMyElement(player['playerPanel'], player['buttonFullsize']);
}
/* Definitions Option */
if (player['videoDefinitions'].length < 2) feature['definition'] = false;
/* Containers Option */
if (player['videoContainers'].length < 2) feature['container'] = false;
/* Resize My Player */
if (option['widesize']) resizeMyPlayer('widesize');
if (option['fullsize']) resizeMyPlayer('fullsize');
/* Select The Video */
if (feature['definition'] || feature['container'] || feature['openpagelink']) {
if (!option['definition'] || player['videoDefinitions'].indexOf(option['definition']) == -1) option['definition'] = player['videoPlay'].replace(/Definition.*/, 'Definition');
if (!option['container'] || player['videoContainers'].indexOf(option['container']) == -1) option['container'] = player['videoPlay'].replace(/.*\s/, '');
selectMyVideo();
}
/* Play The Video */
playMyVideo(option['autoplay']);
}
function resizeMyPlayer(size) {
var playerWidth, playerHeight, playerIndex;
/* Resize The Player */
if (size == 'widesize') {
var sidebarMargin;
if (option['widesize']) {
if (player['buttonWidesize']) styleMyElement(player['buttonWidesize'], {width: '16px', height: '8px'});
playerWidth = player['playerWideWidth'];
playerHeight= player['playerWideHeight'];
sidebarMargin = player['sidebarMarginWide'];
playerIndex = '2';
}
else {
if (player['buttonWidesize']) styleMyElement(player['buttonWidesize'], {width: '20px', height: '10px'});
playerWidth = player['playerWidth'];
playerHeight= player['playerHeight'];
sidebarMargin = player['sidebarMarginNormal'];
playerIndex = 'auto';
}
if (player['sidebarWindow']) styleMyElement(player['sidebarWindow'], {marginTop: sidebarMargin + 'px'});
styleMyElement(player['playerSocket'], {height: playerHeight + 'px'});
styleMyElement(player['playerWindow'], {width: playerWidth + 'px', height: playerHeight + 'px'});
}
else if (size == 'fullsize') {
var playerPosition;
if (option['fullsize']) {
playerPosition = 'fixed';
playerIndex = '9999999999';
playerWidth = page.win.innerWidth || page.doc.documentElement.clientWidth;
playerHeight = page.win.innerHeight || page.doc.documentElement.clientHeight;
if (!player['isFullsize']) {
if (feature['widesize']) styleMyElement(player['buttonWidesize'], {display: 'none'});
styleMyElement(player['buttonFullsize'], {border: '2px solid #CCCCCC'});
appendMyElement(page.body, player['playerWindow']);
styleMyElement(page.body, {overflow: 'hidden'});
styleMyElement(page.body.parentNode, {overflow: 'hidden'});
if (!player['resizeListener']) player['resizeListener'] = function() {resizeMyPlayer('fullsize')};
page.win.addEventListener('resize', player['resizeListener'], false);
player['isFullsize'] = true;
if (player['isPlaying']) {
if (player['contentVideo'] && player['contentVideo'].paused) player['contentVideo'].play();
}
}
}
else {
playerPosition = 'relative';
playerIndex = (option['widesize']) ? '2' : 'auto';
playerWidth = (option['widesize']) ? player['playerWideWidth'] : player['playerWidth'];
playerHeight = (option['widesize']) ? player['playerWideHeight'] : player['playerHeight'];
if (feature['widesize']) styleMyElement(player['buttonWidesize'], {display: 'inline-block'});
styleMyElement(player['buttonFullsize'], {border: '2px dashed #CCCCCC'});
appendMyElement(player['playerSocket'], player['playerWindow']);
styleMyElement(page.body, {overflow: 'auto'});
styleMyElement(page.body.parentNode, {overflow: 'auto'});
page.win.removeEventListener('resize', player['resizeListener'], false);
player['isFullsize'] = false;
if (player['isPlaying']) {
if (player['contentVideo'] && player['contentVideo'].paused) player['contentVideo'].play();
}
}
styleMyElement(player['playerWindow'], {position: playerPosition, top: '0px', left: '0px', width: playerWidth + 'px', height: playerHeight + 'px', zIndex: playerIndex});
}
/* Resize The Content */
player['contentWidth'] = playerWidth;
player['contentHeight'] = playerHeight - myPlayerPanelHeight;
styleMyElement(player['playerContent'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px'});
if (player['isPlaying']) {
player['contentVideo'].width = player['contentWidth'];
player['contentVideo'].height = player['contentHeight'];
styleMyElement(player['contentVideo'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px'});
}
/* Resize The Panel */
styleMyElement(player['playerPanel'], {width: playerWidth + 'px'});
}
function createMyOptions() {
if (!player['optionsContent']) {
/* Options Window */
player['optionsContent'] = createMyElement('div');
styleMyElement(player['optionsContent'], {width: '100%', height: '100%', position: 'relative', backgroundColor: 'rgba(0, 0, 0, 0.7)' , textAlign: 'center'});
/* Options Object => option: [label, options, new line, change video] */
var options = {
'embed': ['Embed video with', embedtypes, true, false],
'media': ['and play as/with', mediakeys, false, false],
'definition': ['Select the definition', player['videoDefinitions'], true, true],
'container': ['and the container', player['videoContainers'], false, true],
'openpagelink': ['Open Page Link', ['On', 'Off'], true, true],
'autoplay': ['Autoplay', ['On', 'Off'], true, false],
'playdash': ['Play DASH (Video With Audio)', ['On', 'Off'], true, false]
};
/* Options */
var optionsBox, optionBox, optionLabel, optionMenu, optionMenuItem;
for (var o in options) {
if (feature[o] === false) continue;
if (options[o][2]) {
optionsBox = createMyElement('div');
styleMyElement(optionsBox, {display: 'block', padding: '20px 0px 20px 0px'});
appendMyElement(player['optionsContent'], optionsBox);
}
optionBox = createMyElement('div');
styleMyElement(optionBox, {display: 'inline-block'});
optionLabel = createMyElement('div', {textContent: options[o][0]});
styleMyElement(optionLabel, {display: 'inline-block', color: '#CCCCCC', marginRight: '10px', verticalAlign: 'middle'});
optionMenu = createMyElement('select', {id: 'viewtube-option-' + o}, 'change', function() {
var id = this.id.replace('viewtube-option-', '');
if (this.value == 'On' || this.value == 'Off') {
option[id] = (this.value == 'On') ? true : false;
}
else {
option[id] = this.value;
}
setMyOptions(id, option[id]);
if (options[id][3]) {
if (player['isSaving']) {
cleanMyElement(player['buttonSaveLink'], false);
player['isSaving'] = false;
}
selectMyVideo();
}
});
styleMyElement(optionMenu, {display: 'inline-block', width: 'auto', height: '20px', color: '#CCCCCC', backgroundColor: '#000000', border: '1px solid #777777', fontFamily: 'inherit', fontSize: '14px', fontWeight: 'bold', marginRight: '10px', verticalAlign: 'middle'});
appendMyElement(optionBox, optionLabel);
appendMyElement(optionBox, optionMenu);
appendMyElement(optionsBox, optionBox);
for (var i = 0; i < options[o][1].length; i++) {
optionMenuItem = createMyElement('option', {value: options[o][1][i], textContent: options[o][1][i]});
styleMyElement(optionMenuItem, {fontSize: '14px', fontWeight: 'bold', cursor: 'pointer'});
appendMyElement(optionMenu, optionMenuItem);
}
if (optionMenu.value == 'On' || optionMenu.value == 'Off') {
if (option[o]) optionMenu.value = 'On';
else optionMenu.value = 'Off';
}
else {
optionMenu.value = option[o];
}
}
}
if (!player['contentImage']) cleanMyElement(player['playerContent'], false);
appendMyElement(player['playerContent'], player['optionsContent']);
}
function setMyOptions(key, value) {
key = page.site + '_' + userscript.toLowerCase() + '_' + key;
try {
localStorage.setItem(key, value);
if (localStorage.getItem(key) == value) return;
else throw false;
}
catch(e) {
var date = new Date();
date.setTime(date.getTime() + (356*24*60*60*1000));
var expires = '; expires=' + date.toGMTString();
page.doc.cookie = key + '=' + value + expires + '; path=/';
}
}
function getMyOptions() {
for (var opt in option) {
var key = page.site + '_' + userscript.toLowerCase() + '_' + opt;
try {
if (localStorage.getItem(key)) {
option[opt] = localStorage.getItem(key);
continue;
}
else throw false;
}
catch(e) {
var cookies = page.doc.cookie.split(';');
for (var i=0; i < cookies.length; i++) {
var cookie = cookies[i];
while (cookie.charAt(0) == ' ') cookie = cookie.substring(1, cookie.length);
option[opt] = (cookie.indexOf(key) == 0) ? cookie.substring(key.length + 1, cookie.length) : option[opt];
}
}
}
if (!option['embed'] || embedtypes.indexOf(option['embed']) == -1) option['embed'] = embedtypes[0];
if (!option['media'] || mediakeys.indexOf(option['media']) == -1) option['media'] = mediakeys[0];
var boolOptions = ['openpagelink', 'autoplay', 'playdash', 'widesize', 'fullsize'];
for (var i = 0; i < boolOptions.length; i++) {
option[boolOptions[i]] = (option[boolOptions[i]] === true || option[boolOptions[i]] == 'true') ? true : false;
}
}
function selectMyVideo() {
if (option['openpagelink']) {
player['videoPlay'] = 'Page Link';
}
else {
var vdoCont = (option['container'] != 'Any') ? [option['container']] : player['videoContainers'];
var vdoDef = player['videoDefinitions'];
var vdoList = {};
for (var vC = 0; vC < vdoCont.length; vC++) {
if (vdoCont[vC] != 'Any') {
for (var vD = 0; vD < vdoDef.length; vD++) {
var format = vdoDef[vD] + ' ' + vdoCont[vC];
if (!vdoList[vdoDef[vD]]) {
for (var vL in player['videoList']) {
if (vL == format) {
vdoList[vdoDef[vD]] = vL;
break;
}
}
}
}
}
}
var vdoDef2 = [];
var keepDef = false;
for (var vD = 0; vD < vdoDef.length; vD++) {
if (vdoDef[vD] == option['definition'] && keepDef == false) keepDef = true;
if (keepDef == true) vdoDef2.push(vdoDef[vD])
}
for (var vD = 0; vD < vdoDef2.length; vD++) {
if (vdoList[vdoDef2[vD]]) {
player['videoPlay'] = vdoList[vdoDef2[vD]];
break;
}
}
}
player['videoMenu'].value = player['videoPlay'];
}
function playDASHwithVLC() {
var contentVideo = player['videoList'][player['videoPlay'].replace('Definition', 'Definition Video')];
var contentAudio = player['videoList']['High Bitrate Audio WebM'] || player['videoList']['Medium Bitrate Audio WebM']
|| player['videoList']['Medium Bitrate Audio MP4'] || player['videoList'][player['videoPlay'].replace('Definition', 'Definition Audio')];
if (option['media'] == 'VLC*') {
player['contentVideo'] = createMyElement('embed', {id: 'vtVideo', type: mediatypes[option['media']], target: contentVideo, innerHTML: embedcontent['Embed']});
player['contentAudio'] = createMyElement('embed', {id: 'vtVideo', type: mediatypes[option['media']], target: contentAudio});
}
else {
player['contentVideo'] = createMyElement('embed', {id: 'vtVideo', type: mediatypes[option['media']], src: contentVideo, innerHTML: embedcontent['Embed']});
player['contentAudio'] = createMyElement('embed', {id: 'vtVideo', type: mediatypes[option['media']], src: contentAudio});
}
styleMyElement(player['contentAudio'], {position: 'absolute', zIndex: '-1', width: '1px', height: '1px'});
appendMyElement(player['playerContent'], player['contentAudio']);
player['contentVLCInit'] = page.win.setInterval(function() {
if (player['contentAudio'].wrappedJSObject.playlist && player['contentVideo'].wrappedJSObject.playlist
&& player['contentAudio'].wrappedJSObject.input && player['contentVideo'].wrappedJSObject.input) {
player['contentVLCVideoPosition'] = 0;
player['contentVLCSync'] = page.win.setInterval(function() {
if (!player['contentVideo'] || !player['contentVideo'].wrappedJSObject || !player['contentVideo'].wrappedJSObject.input) {
page.win.clearInterval(player['contentVLCSync']);
}
if (player['contentVideo'].wrappedJSObject.input.time != player['contentVLCVideoPosition']) {
if (Math.abs(player['contentVideo'].wrappedJSObject.input.time - player['contentAudio'].wrappedJSObject.input.time) >= 500) {
player['contentAudio'].wrappedJSObject.input.time = player['contentVideo'].wrappedJSObject.input.time;
}
player['contentVLCVideoPosition'] = player['contentVideo'].wrappedJSObject.input.time;
}
if (player['contentVideo'].wrappedJSObject.input.state == '4') {
player['contentAudio'].wrappedJSObject.playlist.pause();
player['contentAudioPaused'] = true;
}
if (player['contentVideo'].wrappedJSObject.input.state == '6') {
player['contentAudio'].wrappedJSObject.playlist.pause();
player['contentAudioPaused'] = true;
}
if (player['contentVideo'].wrappedJSObject.input.state == '3' && player['contentAudioPaused']) {
player['contentAudio'].wrappedJSObject.playlist.play();
player['contentAudioPaused'] = false;
}
}, 1000);
page.win.clearInterval(player['contentVLCInit']);
}
}, 500);
}
function playDASHwithHTML5() {
var contentVideo = player['videoList'][player['videoPlay'].replace('Definition', 'Definition Video')];
var contentAudio = player['videoList']['High Bitrate Audio WebM'] || player['videoList']['Medium Bitrate Audio WebM']
|| player['videoList']['Medium Bitrate Audio MP4'] || player['videoList'][player['videoPlay'].replace('Definition', 'Definition Audio')];
player['contentVideo'] = createMyElement('video', {id: 'vtVideo', type: mediatypes[player['videoPlay'].replace(/.*\s/, '')], src: contentVideo, controls: 'controls', autoplay: 'autoplay', innerHTML: embedcontent['Video']});
player['contentAudio'] = createMyElement('video', {id: 'vtVideo', type: mediatypes[player['videoPlay'].replace(/.*\s/, '')], src: contentAudio, autoplay: 'autoplay'});
player['contentAudio'].pause();
player['contentVideo'].addEventListener('play', function() {
player['contentAudio'].play();
}, false);
player['contentVideo'].addEventListener('pause', function() {
player['contentAudio'].pause();
}, false);
player['contentVideo'].addEventListener('ended', function() {
player['contentVideo'].pause();
player['contentAudio'].pause();
}, false);
player['contentVideo'].addEventListener('timeupdate', function() {
if (player['contentAudio'].paused && !player['contentVideo'].paused) {
player['contentAudio'].play();
}
if (Math.abs(player['contentVideo'].currentTime - player['contentAudio'].currentTime) >= 0.30) {
player['contentAudio'].currentTime = player['contentVideo'].currentTime;
}
}, false);
styleMyElement(player['contentAudio'], {display: 'none'});
appendMyElement(player['contentVideo'], player['contentAudio']);
}
function playMyVideo(play) {
if (play) {
if (option['embed'] == 'Protocol') {
if (player['videoList'][player['videoPlay']] != 'DASH') {
page.win.location.href = 'viewtube:' + player['videoList'][player['videoPlay']];
}
else {
var contentVideo = player['videoList'][player['videoPlay'].replace('Definition', 'Definition Video')];
var contentAudio = player['videoList']['High Bitrate Audio WebM'] || player['videoList']['Medium Bitrate Audio WebM']
|| player['videoList']['Medium Bitrate Audio MP4'] || player['videoList'][player['videoPlay'].replace('Definition', 'Definition Audio')];
page.win.location.href = 'viewtube:' + contentVideo + 'SEPARATOR' + contentAudio;
}
return;
}
player['isPlaying'] = true;
styleMyElement(player['buttonPlay'], {width: '15px', height: '15px', backgroundColor: '#CCCCCC', border: '0px'});
cleanMyElement(player['playerContent'], false);
if (player['videoList'][player['videoPlay']] == 'DASH') {
if (option['media'] == 'VLC' || option['media'] == 'VLC*') {
playDASHwithVLC();
}
else {
playDASHwithHTML5();
}
}
else {
var videoProperties, videoType;
if (option['media'] == 'Auto') {
videoType = mediatypes[player['videoPlay'].replace(/.*\s/, '')];
}
else {
videoType = mediatypes[option['media']];
}
if (option['embed'] == 'Video') {
videoProperties = {id: 'vtVideo', type: videoType, src: player['videoList'][player['videoPlay']], controls: 'controls', autoplay: 'autoplay', poster: player['videoThumb'], innerHTML: embedcontent[option['embed']]};
}
else if (option['embed'] == 'Object') {
videoProperties = {id: 'vtVideo', type: videoType, data: player['videoList'][player['videoPlay']], innerHTML: embedcontent[option['embed']]};
}
else if (option['embed'] == 'Embed') {
if (option['media'] == 'VLC*') {
videoProperties = {id: 'vtVideo', type: videoType, target: player['videoList'][player['videoPlay']], innerHTML: embedcontent[option['embed']]};
}
else {
videoProperties = {id: 'vtVideo', type: videoType, src: player['videoList'][player['videoPlay']], innerHTML: embedcontent[option['embed']]};
}
}
player['contentVideo'] = createMyElement(option['embed'], videoProperties);
}
player['contentVideo'].width = player['contentWidth'];
player['contentVideo'].height = player['contentHeight'];
styleMyElement(player['contentVideo'], {position: 'relative', width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px', outline: 'none'});
appendMyElement(player['playerContent'], player['contentVideo']);
player['contentVideo'].focus();
}
else {
player['isPlaying'] = false;
styleMyElement(player['buttonPlay'], {width: '0px', height: '0px', borderTop: '8px solid transparent', borderBottom: '8px solid transparent', borderLeft: '15px solid #CCCCCC', backgroundColor: '#000000'});
cleanMyElement(player['playerContent'], false);
if (player['contentImage']) appendMyElement(player['playerContent'], player['contentImage']);
else showMyMessage('!thumb');
}
}
function saveMyVideo() {
var vdoURL = player['videoList'][player['videoPlay']];
if (vdoURL == 'DASH') return;
if (vdoURL == page.url) return;
var vdoDef = ' (' + player['videoPlay'].split(' ').slice(0, -1).join('').match(/[A-Z]/g).join('') + ')';
var vdoExt = '.' + player['videoPlay'].split(' ').slice(-1).join('').toLowerCase();
var vdoTle = (player['videoTitle']) ? player['videoTitle'] : page.url.replace(/https?:\/\//, '').replace(/[^0-9a-zA-Z]/g, '-');;
if (page.site == 'youtube' && player['videoPlay'] == 'High Definition MP4') {
page.win.location.href = vdoURL + '&title=' + vdoTle + vdoDef;
}
if (!player['isSaving']) {
var vdoLnk = createMyElement('a', {href: vdoURL, target: '_blank', textContent: '[Link]'});
styleMyElement(vdoLnk, {color: '#CCCCCC', textDecoration: 'underline'});
appendMyElement(player['buttonSaveLink'], vdoLnk);
player['isSaving'] = true;
}
}
function showMyMessage(cause, content) {
var myScriptLogo = createMyElement('div', {textContent: userscript});
styleMyElement(myScriptLogo, {display: 'inline-block', margin: '10px auto', color: '#E24994', fontSize: '24px', fontWeight: 'bold', textAlign: 'center', border: '1px solid #E24994', borderRadius: '2px', padding: '0px 4px'});
var myScriptMess = createMyElement('div');
styleMyElement(myScriptMess, {fontSize: '20px', border: '1px solid #777777', margin: '5px auto 5px auto', padding: '10px', backgroundColor: '#000000', color: '#AD0000', textAlign: 'center'});
if (cause == '!player') {
var myScriptAlert = createMyElement('div');
styleMyElement(myScriptAlert, {position: 'absolute', top: '30%', left: '35%', border: '1px solid #F4F4F4', borderRadius: '3px', padding: '10px', backgroundColor: '#FFFFFF', fontSize: '14px', textAlign: 'center', zIndex: '99999'});
appendMyElement(myScriptAlert, myScriptLogo);
modifyMyElement(myScriptMess, {innerHTML: 'Couldn\'t get the player element. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.'});
styleMyElement(myScriptMess, {border: '1px solid #EEEEEE', backgroundColor: '#FFFFFF'});
appendMyElement(myScriptAlert, myScriptMess);
var myScriptAlertButton = createMyElement('div', {textContent: 'OK'}, 'click', function() {
removeMyElement(page.body, myScriptAlert);
});
styleMyElement(myScriptAlertButton, {width: '100px', border: '3px solid #EEEEEE', borderRadius: '5px', margin: '0px auto', backgroundColor: '#EEEEEE', color: '#666666', fontSize: '18px', textAlign: 'center', cursor: 'pointer'});
appendMyElement(myScriptAlert, myScriptAlertButton);
appendMyElement(page.body, myScriptAlert);
}
else if (cause == '!thumb') {
modifyMyElement(player['playerContent'], {innerHTML: '<br><br>Couldn\'t get the thumbnail for this video. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.'});
}
else {
appendMyElement(myPlayerWindow, myScriptLogo);
if (cause == '!content') {
modifyMyElement(myScriptMess, {innerHTML: 'Couldn\'t get the videos content. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.'});
}
else if (cause == '!videos') {
modifyMyElement(myScriptMess, {innerHTML: 'Couldn\'t get any video. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.'});
}
else if (cause == '!support') {
modifyMyElement(myScriptMess, {textContent: 'This video uses the RTMP protocol and is not supported.'});
}
else if (cause == 'embed') {
modifyMyElement(myScriptMess, {innerHTML: 'This is an embedded video. You can watch it <a href="' + content + '" style="color:#00892C">here</a>.'});
}
else if (cause == 'other') {
modifyMyElement(myScriptMess, {innerHTML: content});
}
appendMyElement(myPlayerWindow, myScriptMess);
}
}