-
Notifications
You must be signed in to change notification settings - Fork 1
/
87011.user_new.js
2004 lines (1816 loc) · 80.3 KB
/
87011.user_new.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_VLC
// @version 2013.08.09
// @namespace trupf
// @description Watch videos from video sharing websites without Flash Player.
// @include http://youtube.com*
// @include http://www.youtube.com*
// @include https://youtube.com*
// @include https://www.youtube.com*
// @include http://dailymotion.com*
// @include http://www.dailymotion.com*
// @include https://dailymotion.com*
// @include https://www.dailymotion.com*
// @include http://vimeo.com*
// @include http://www.vimeo.com*
// @include https://vimeo.com*
// @include https://www.vimeo.com*
// @include http://metacafe.com*
// @include http://www.metacafe.com*
// @include https://metacafe.com*
// @include https://www.metacafe.com*
// @include http://break.com*
// @include http://www.break.com*
// @include https://break.com*
// @include https://www.break.com*
// @include http://funnyordie.com*
// @include http://www.funnyordie.com*
// @include https://funnyordie.com*
// @include https://www.funnyordie.com*
// @include http://videojug.com*
// @include http://www.videojug.com*
// @include https://videojug.com*
// @include https://www.videojug.com*
// @include http://mevio.com*
// @include http://*.mevio.com*
// @include https://mevio.com*
// @include https://*.mevio.com*
// @include http://blip.tv*
// @include http://www.blip.tv*
// @include https://blip.tv*
// @include https://www.blip.tv*
// @include http://veoh.com*
// @include http://www.veoh.com*
// @include https://veoh.com*
// @include https://www.veoh.com*
// @include http://veehd.com*
// @include http://www.veehd.com*
// @include https://veehd.com*
// @include https://www.veehd.com*
// @include http://imdb.com/video*
// @include http://www.imdb.com/video*
// @include https://imdb.com/video*
// @include https://www.imdb.com/video*
// @include http://crackle.com*
// @include http://www.crackle.com*
// @include https://crackle.com*
// @include https://www.crackle.com*
// ==/UserScript==
/*
Copyright (C) 2010 - 2013 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://isebaro.com/viewtube
Contact: http://isebaro.com/contact
*/
(function() {
// ==========Variables========== //
// Userscript
var userscript = 'ViewTube';
// Page
var page = {win: window, doc: document, body: document.body, url: window.location.href};
// Player
var player = {};
var feature = {'autoplay': true, 'definition': true, 'container': true, 'widesize': true, 'fullsize': true};
var option = {'plugin': 'Auto', 'autoplay': false, 'autoget': false, 'definition': 'HD', 'container': 'MP4', 'widesize': false, 'fullsize': false};
var plugins = ['Auto', 'HTML5', 'MPEG', 'MP4', 'FLV', 'VLC'];
if (navigator.platform.indexOf('Win') != -1) plugins = plugins.concat(['WMP', 'WMP2', 'QT']);
else if (navigator.platform.indexOf('Mac') != -1) plugins = plugins.concat(['QT']);
else plugins = plugins.concat(['Totem', 'Xine']);
var mimetypes = {
'MPEG': 'video/mpeg',
'MP4': 'video/mp4',
'WebM': 'video/webm',
'FLV': 'video/x-flv',
'MOV': 'video/quicktime',
'M4V': 'video/x-m4v',
'AVI': 'video/x-msvideo',
'3GP': 'video/3gpp',
'WMP': 'application/x-ms-wmp',
'WMP2': 'application/x-mplayer2',
'QT': 'video/quicktime',
'VLC': 'application/x-vlc-plugin',
'Totem': 'application/x-totem-plugin',
'Xine': 'application/x-xine-plugin'
};
// Links
var website = 'http://isebaro.com/viewtube/?ln=en';
var contact = 'http://isebaro.com/contact/?ln=en&sb=viewtube';
// ==========Fixes========== //
// Don't run on frames or iframes
if (window.top != window.self) return;
// ==========Functions========== //
function createVideoElement (type, content) {
function createPlayerElement (type, content) {
player['contentVideo'] = createMyElement (type, content, '', '', '');
player['contentVideo'].width = player['contentWidth'];
player['contentVideo'].height = player['contentHeight'];
styleMyElement (player['contentVideo'], {position: 'relative', width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px'});
modifyMyElement (player['playerContent'], 'div', '', true);
appendMyElement (player['playerContent'], player['contentVideo']);
}
/* Resolve redirects, if possible */
if (typeof(GM_xmlhttpRequest) == "function") {
var GM_xml = GM_xmlhttpRequest({
method: "HEAD",
headers: {
"Referer": page.url
},
url: content,
synchronous: false,
onload: function(response) {
content = (typeof(response.finalUrl) == "string") ? (response.finalUrl.indexOf('http') == 0) ? response.finalUrl : content : content;
createPlayerElement(type, content);
},
onabort: function(response) {
content = (typeof(response.finalUrl) == "string") ? (response.finalUrl.indexOf('http') == 0) ? response.finalUrl : content : content;
createPlayerElement(type, content);
},
onprogress: function(response) { // this is required in older Greasemonkey as it will dowload complete content despite the "HEAD" request method!!!
GM_xml.abort();
}
});
}
else {
createPlayerElement(type, content);
}
}
function createMyElement (type, content, event, action, target) {
var obj = page.doc.createElement(type);
if (content) {
if (type == 'div') obj.innerHTML = content;
else if (type == 'img') obj.src = content;
else if (type == 'option') {
obj.value = content;
obj.innerHTML = content;
}
else if (type == 'video') {
obj.src = content;
obj.controls = 'controls';
obj.autoplay = 'autoplay';
obj.innerHTML = '<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 + '">here</a>.';
}
else if (type == 'object') {
obj.data = content;
obj.innerHTML = '<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 + '">here</a>.<param name="scale" value="aspect"><param name="stretchtofit" value="true"><param name="autostart" value="true"><param name="autoplay" value="true">';
}
else if (type == 'embed') {
if (option['plugin'] == 'VLC') obj.setAttribute('target', content);
else obj.src = content;
obj.innerHTML = '<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 + '">here</a>.<param name="scale" value="aspect"><param name="stretchtofit" value="true"><param name="autostart" value="true"><param name="autoplay" value="true">';
}
}
if (type == 'video' || type == 'object' || type == 'embed') {
if (option['plugin'] == 'Auto' || option['plugin'] == 'Alt' || option['plugin'] == 'HTML5') {
obj.type = mimetypes[player['videoPlay'].replace(/.*\s/, '')];
}
else {
obj.type = mimetypes[option['plugin']];
}
obj.id = 'vtVideo';
}
if (event == 'change') {
if (target == 'video') {
obj.addEventListener ('change', function () {
player['videoPlay'] = this.value;
if (player['isGetting']) {
modifyMyElement (player['buttonGet'] , 'div', 'Get', false);
player['isGetting'] = false;
}
if (player['isPlaying']) playMyVideo(option['autoplay']);
}, false);
}
else if (target == 'plugin') {
obj.addEventListener ('change', function () {
option['plugin'] = this.value;
setMyOptions ('viewtube_plugin', option['plugin']);
if (player['isPlaying']) playMyVideo(true);
}, false);
}
}
else if (event == 'click') {
obj.addEventListener ('click', function () {
if (action == 'close') {
removeMyElement(page.body, target);
}
else if (action == 'logo') {
page.win.location.href = website;
}
else if (action == 'play') {
playMyVideo(!player['isPlaying']);
}
else if (action == 'get') {
getMyVideo();
}
else if (action == 'autoplay') {
option['autoplay'] = (option['autoplay']) ? false : true;
if (option['autoplay']) {
styleMyElement (player['buttonPlay'], {display: 'none'});
styleMyElement (player['buttonAutoplay'], {color: '#008080', textShadow: '0px 1px 1px #CCCCCC'});
if (!player['isPlaying']) playMyVideo(true);
}
else {
styleMyElement (player['buttonPlay'], {display: 'inline'});
styleMyElement (player['buttonAutoplay'], {color: '#CCCCCC', textShadow: '0px 0px 0px'});
playMyVideo(false);
}
setMyOptions ('viewtube_autoplay', option['autoplay']);
}
else if (action == 'definition') {
for (var itemDef = 0; itemDef < option['definitions'].length; itemDef++) {
if (option['definitions'][itemDef].match(/[A-Z]/g).join('') == option['definition']) {
var nextDef = (itemDef + 1 < option['definitions'].length) ? itemDef + 1 : 0;
option['definition'] = option['definitions'][nextDef].match(/[A-Z]/g).join('');
break;
}
}
modifyMyElement (player['buttonDefinition'], 'div', option['definition'], false);
setMyOptions ('viewtube_definition', option['definition']);
if (player['isGetting']) {
modifyMyElement (player['buttonGet'] , 'div', 'Get', false);
player['isGetting'] = false;
}
selectMyVideo ();
if (player['isPlaying']) playMyVideo(true);
}
else if (action == 'container') {
for (var itemCont = 0; itemCont < option['containers'].length; itemCont++) {
if (option['containers'][itemCont] == option['container']) {
var nextCont = (itemCont + 1 < option['containers'].length) ? itemCont + 1 : 0;
option['container'] = option['containers'][nextCont];
break;
}
}
modifyMyElement (player['buttonContainer'], 'div', option['container'], false);
setMyOptions ('viewtube_container', option['container']);
if (player['isGetting']) {
modifyMyElement (player['buttonGet'] , 'div', 'Get', false);
player['isGetting'] = false;
}
selectMyVideo ();
if (player['isPlaying']) playMyVideo(true);
}
else if (action == 'widesize') {
option['widesize'] = (option['widesize']) ? false : true;
setMyOptions ('viewtube_widesize', option['widesize']);
resizeMyPlayer('widesize');
}
else if (action == 'fullsize') {
option['fullsize'] = (option['fullsize']) ? false : true;
setMyOptions ('viewtube_fullsize', option['fullsize']);
resizeMyPlayer('fullsize');
}
}, false);
}
return obj;
}
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') getObj = pObj.getElementsByTagNameNS(value, type);
}
chObj = (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 modifyMyElement (obj, type, content, clear) {
if (content) {
if (type == 'div') obj.innerHTML = content;
else if (type == 'option') {
obj.value = content;
obj.innerHTML = content;
}
else if (type == 'object') obj.data = content;
else if (type == 'img' || type == 'video' || type == 'embed') obj.src = content;
}
if (clear) {
if (obj.hasChildNodes()) {
while (obj.childNodes.length >= 1) {
obj.removeChild(obj.firstChild);
}
}
}
}
function cleanMyElement (element, hide) {
var elEmbed, elVideo;
if (hide) styleMyElement (element, {display: 'none'});
elEmbed = getMyElement (element, 'embed', 'tag', '', 0, false) || getMyElement (element, 'object', 'tag', '', 0, false);
if (elEmbed && elEmbed.parentNode) {
removeMyElement (elEmbed.parentNode, elEmbed);
if (!hide) return;
}
elVideo = getMyElement (element, 'video', 'tag', '', 0, false);
if (elVideo && elVideo.currentSrc) {
modifyMyElement (elVideo, 'video', 'none', true);
if (!hide && elVideo.parentNode) removeMyElement (elVideo.parentNode, elVideo);
return;
}
var elWait = 50;
var elRemove = page.win.setInterval (function () {
if (!elVideo) {
elVideo = getMyElement (element, 'video', 'tag', '', 0, false);
if (!elVideo) {
elEmbed = getMyElement (element, 'embed', 'tag', '', 0, false) || getMyElement (element, 'object', 'tag', '', 0, false);
if (elEmbed && elEmbed.id != 'vtVideo' && elEmbed.parentNode) {
removeMyElement (elEmbed.parentNode, elEmbed);
page.win.clearInterval (elRemove);
}
}
}
if (elVideo && elVideo.id != 'vtVideo' && elVideo.currentSrc) {
modifyMyElement (elVideo, 'video', 'none', true);
if (!hide && elVideo.parentNode) removeMyElement (elVideo.parentNode, elVideo);
page.win.clearInterval (elRemove);
}
if (elWait > 0) elWait--;
else page.win.clearInterval (elRemove);
}, 500);
}
function styleMyElement (obj, styles) {
for (var property in styles) {
if (styles.hasOwnProperty(property)) obj.style[property] = styles[property];
}
}
function appendMyElement (parent, child) {
parent.appendChild(child);
}
function removeMyElement (parent, child) {
parent.removeChild(child);
}
function replaceMyElement (parent, orphan, child) {
parent.replaceChild(orphan, child);
}
function createMyPlayer () {
/* Get My Options */
getMyOptions ();
/* Player Settings */
player['panelHeight'] = 18;
player['panelPadding'] = 2;
/* The Panel */
var panelWidth = player['playerWidth'] - player['panelPadding'] * 2;
player['playerPanel'] = createMyElement ('div', '', '', '', '');
styleMyElement (player['playerPanel'], {width: panelWidth + 'px', height: player['panelHeight'] + 'px', padding: player['panelPadding'] + 'px', backgroundColor: '#F4F4F4', textAlign: 'center'});
appendMyElement (player['playerWindow'], player['playerPanel']);
/* Panel Items */
var panelItemBorder = 1;
var panelItemHeight = player['panelHeight'] - panelItemBorder * 2;
/* Panel Logo */
player['panelLogo'] = createMyElement ('div', userscript + ':', 'click', 'logo', '');
styleMyElement (player['panelLogo'], {height: panelItemHeight + 'px', border: '1px solid #F4F4F4', borderRadius: '3px', padding: '0px', display: 'inline', color: '#336699', fontSize: '10px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
appendMyElement (player['playerPanel'], player['panelLogo']);
/* Panel Video Menu */
player['videoMenu'] = createMyElement ('select', '', 'change', '', 'video');
styleMyElement (player['videoMenu'], {width: '200px', height: panelItemHeight + 'px', border: '1px solid #F4F4F4', borderRadius: '3px', padding: '0px', display: 'inline', backgroundColor: '#F4F4F4', color: '#336699', fontSize: '10px', textShadow: '0px 1px 1px #CCCCCC', verticalAlign: 'baseline', cursor: 'pointer'});
appendMyElement (player['playerPanel'], player['videoMenu'] );
for (var videoCode in player['videoList']) {
player['videoItem'] = createMyElement ('option', videoCode, '', '', '');
styleMyElement (player['videoItem'], {padding: '0px', display: 'block', backgroundColor: '#F4F4F4', color: '#336699', fontSize: '10px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
appendMyElement (player['videoMenu'], player['videoItem']);
}
/* Panel Plugin Menu */
player['pluginMenu'] = createMyElement ('select', '', 'change', '', 'plugin');
styleMyElement (player['pluginMenu'], {width: '70px', height: panelItemHeight + 'px', border: '1px solid #F4F4F4', borderRadius: '3px', padding: '0px', display: 'inline', backgroundColor: '#F4F4F4', color: '#336699', fontSize: '10px', textShadow: '0px 1px 1px #CCCCCC', verticalAlign: 'baseline', cursor: 'pointer'});
appendMyElement (player['playerPanel'], player['pluginMenu'] );
for (var p = 0; p < plugins.length; p++) {
player['pluginItem'] = createMyElement ('option', plugins[p], '', '', '');
styleMyElement (player['pluginItem'], {padding: '0px', display: 'block', backgroundColor: '#F4F4F4', color: '#336699', fontSize: '10px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
appendMyElement (player['pluginMenu'], player['pluginItem']);
}
player['pluginMenu'].value = option['plugin'];
/* Panel Play Button */
player['buttonPlay'] = createMyElement ('div', 'Play', 'click', 'play', '');
styleMyElement (player['buttonPlay'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#37B704', fontSize: '10px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
if (option['autoplay']) styleMyElement (player['buttonPlay'], {display: 'none'});
appendMyElement (player['playerPanel'], player['buttonPlay']);
/* Panel Get Button */
player['buttonGet'] = createMyElement ('div', 'Get', 'click', 'get', '');
styleMyElement (player['buttonGet'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#C000C0', fontSize: '10px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
appendMyElement (player['playerPanel'], player['buttonGet']);
/* Panel Autoplay Button */
if (feature['autoplay']) {
var bAutoPlay = (player['playerWidth'] > 600) ? 'Autoplay' : 'AP';
player['buttonAutoplay'] = createMyElement ('div', bAutoPlay, 'click', 'autoplay', '');
styleMyElement (player['buttonAutoplay'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#CCCCCC', fontSize: '10px', cursor: 'pointer'});
if (option['autoplay']) styleMyElement (player['buttonAutoplay'], {color: '#008080', textShadow: '0px 1px 1px #CCCCCC'});
appendMyElement (player['playerPanel'], player['buttonAutoplay']);
}
/* Panel Definition Button */
if (feature['definition']) {
player['buttonDefinition'] = createMyElement ('div', option['definition'], 'click', 'definition', '');
styleMyElement (player['buttonDefinition'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#008000', fontSize: '10px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
appendMyElement (player['playerPanel'], player['buttonDefinition']);
}
/* Panel Container Button */
if (feature['container']) {
player['buttonContainer'] = createMyElement ('div', option['container'], 'click', 'container', '');
styleMyElement (player['buttonContainer'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#008000', fontSize: '10px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
appendMyElement (player['playerPanel'], player['buttonContainer']);
}
/* Panel Widesize Button */
if (feature['widesize']) {
if (option['widesize']) player['buttonWidesize'] = createMyElement ('div', '<', 'click', 'widesize', '');
else player['buttonWidesize'] = createMyElement ('div', '>', 'click', 'widesize', '');
styleMyElement (player['buttonWidesize'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#C05800', fontSize: '10px', textShadow: '1px 1px 2px #CCCCCC', cursor: 'pointer'});
appendMyElement (player['playerPanel'], player['buttonWidesize']);
}
/* Panel Fullsize Button */
if (feature['fullsize']) {
if (option['fullsize']) player['buttonFullsize'] = createMyElement ('div', '-', 'click', 'fullsize', '');
else player['buttonFullsize'] = createMyElement ('div', '+', 'click', 'fullsize', '');
styleMyElement (player['buttonFullsize'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#C05800', fontSize: '10px', textShadow: '1px 1px 2px #CCCCCC', cursor: 'pointer'});
appendMyElement (player['playerPanel'], player['buttonFullsize']);
}
/* The Content */
player['contentWidth'] = player['playerWidth'];
player['contentHeight'] = player['playerHeight'] - player['panelHeight'] - player['panelPadding'] * 2;
player['playerContent'] = createMyElement ('div', '', '', '', '');
styleMyElement (player['playerContent'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px', backgroundColor: '#F4F4F4', color: '#AD0000', fontSize: '14px', textAlign: 'center'});
appendMyElement (player['playerWindow'], player['playerContent']);
/* The Video Thumbnail */
if (player['videoThumb']) {
player['contentImage'] = createMyElement ('img', player['videoThumb'], 'click', 'play', '');
styleMyElement (player['contentImage'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px', border: '0px', cursor: 'pointer'});
}
/* Disabled Features */
if (!feature['autoplay']) option['autoplay'] = false;
if (!feature['widesize']) option['widesize'] = false;
if (!feature['fullsize']) option['fullsize'] = false;
/* Resize My Player */
if (option['widesize']) resizeMyPlayer('widesize');
if (option['fullsize']) resizeMyPlayer('fullsize');
/* Select My Video */
if (feature['definition'] || feature['container']) selectMyVideo ();
/* Play My Video */
playMyVideo (option['autoplay']);
}
function selectMyVideo () {
var vdoCont = (option['container'] != 'Any') ? [option['container']] : option['containers'];
var vdoDef = option['definitions'];
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;
}
}
}
}
}
}
if (option['definition'] == 'UHD') {
if (vdoList['Ultra High Definition']) player['videoPlay'] = vdoList['Ultra High Definition'];
else if (vdoList['Full High Definition']) player['videoPlay'] = vdoList['Full High Definition'];
else if (vdoList['High Definition']) player['videoPlay'] = vdoList['High Definition'];
else if (vdoList['Standard Definition']) player['videoPlay'] = vdoList['Standard Definition'];
else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
}
else if (option['definition'] == 'FHD') {
if (vdoList['Full High Definition']) player['videoPlay'] = vdoList['Full High Definition'];
else if (vdoList['High Definition']) player['videoPlay'] = vdoList['High Definition'];
else if (vdoList['Standard Definition']) player['videoPlay'] = vdoList['Standard Definition'];
else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
}
else if (option['definition'] == 'HD') {
if (vdoList['High Definition']) player['videoPlay'] = vdoList['High Definition'];
else if (vdoList['Standard Definition']) player['videoPlay'] = vdoList['Standard Definition'];
else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
}
else if (option['definition'] == 'SD') {
if (vdoList['Standard Definition']) player['videoPlay'] = vdoList['Standard Definition'];
else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
}
else if (option['definition'] == 'LD') {
if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
}
else if (option['definition'] == 'VLD') {
if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
}
player['videoMenu'].value = player['videoPlay'];
}
function playMyVideo (play) {
if (play) {
player['isPlaying'] = true;
modifyMyElement (player['buttonPlay'], 'div', 'Stop', false);
styleMyElement (player['buttonPlay'], {color: '#AD0000'});
if (option['plugin'] == 'HTML5') player['contentVideo'] = createVideoElement ('video', player['videoList'][player['videoPlay']]);
else if (((navigator.appName == 'Netscape') && (navigator.userAgent.indexOf("AppleWebKit") == -1))) player['contentVideo'] = createVideoElement ('embed', player['videoList'][player['videoPlay']]);
else createVideoElement ('object', player['videoList'][player['videoPlay']]);
}
else {
player['isPlaying'] = false;
modifyMyElement (player['buttonPlay'], 'div', 'Play', false);
styleMyElement (player['buttonPlay'], {color: '#37B704'});
modifyMyElement (player['playerContent'], 'div', '', true);
if (player['contentImage']) appendMyElement (player['playerContent'], player['contentImage']);
else showMyMessage ('!thumb');
}
}
function getMyVideo () {
var vdoURL = player['videoList'][player['videoPlay']];
if (player['videoTitle']) {
var vdoD = ' (' + player['videoPlay'] + ')';
vdoD = vdoD.replace(/Ultra High Definition/, 'UHD');
vdoD = vdoD.replace(/Full High Definition/, 'FHD');
vdoD = vdoD.replace(/High Definition/, 'HD');
vdoD = vdoD.replace(/Standard Definition/, 'SD');
vdoD = vdoD.replace(/Very Low Definition/, 'VLD');
vdoD = vdoD.replace(/Low Definition/, 'LD');
vdoD = vdoD.replace(/\sFLV|\sMP4|\sWebM|\s3GP/g, '');
vdoURL = vdoURL + '&title=' + player['videoTitle'] + vdoD;
}
if (option['autoget']) page.win.location.href = vdoURL;
else {
var vdoLink = 'Get <a href="' + vdoURL + '">Link</a>';
modifyMyElement (player['buttonGet'] , 'div', vdoLink, false);
player['isGetting'] = true;
}
}
function resizeMyPlayer (size) {
if (size == 'widesize') {
if (option['widesize']) {
modifyMyElement (player['buttonWidesize'], 'div', '<', false);
var playerWidth = player['playerWideWidth'];
var playerHeight= player['playerWideHeight'];
var sidebarMargin = player['sidebarMarginWide'];
}
else {
modifyMyElement (player['buttonWidesize'], 'div', '>', false);
var playerWidth = player['playerWidth'];
var playerHeight= player['playerHeight'];
var sidebarMargin = player['sidebarMarginNormal'];
}
}
else if (size == 'fullsize') {
if (option['fullsize']) {
var playerPosition = 'fixed';
var playerWidth = page.win.innerWidth || page.doc.documentElement.clientWidth;
var playerHeight = page.win.innerHeight || page.doc.documentElement.clientHeight;
if (!player['isFullsize']) {
if (feature['widesize']) styleMyElement (player['buttonWidesize'], {display: 'none'});
modifyMyElement (player['buttonFullsize'], 'div', '-', false);
appendMyElement (page.body, player['playerWindow']);
styleMyElement (page.body, {overflow: 'hidden'});
if (!player['resizeListener']) player['resizeListener'] = function() {resizeMyPlayer('fullsize')};
page.win.addEventListener ('resize', player['resizeListener'], false);
player['isFullsize'] = true;
}
}
else {
var playerPosition = 'relative';
var playerWidth = (option['widesize']) ? player['playerWideWidth'] : player['playerWidth'];
var playerHeight = (option['widesize']) ? player['playerWideHeight'] : player['playerHeight'];
if (feature['widesize']) styleMyElement (player['buttonWidesize'], {display: 'inline'});
modifyMyElement (player['buttonFullsize'], 'div', '+', false);
appendMyElement (player['playerSocket'], player['playerWindow']);
styleMyElement (page.body, {overflow: 'auto'});
page.win.removeEventListener ('resize', player['resizeListener'], false);
player['isFullsize'] = false;
}
}
/* Resize The Player */
if (size == 'widesize') {
styleMyElement (player['sidebarWindow'], {marginTop: sidebarMargin + 'px'});
styleMyElement (player['playerWindow'], {width: playerWidth + 'px', height: playerHeight + 'px'});
}
else styleMyElement (player['playerWindow'], {position: playerPosition, top: '0px', left: '0px', width: playerWidth + 'px', height: playerHeight + 'px'});
/* Resize The Panel */
var panelWidth = playerWidth - player['panelPadding'] * 2;
styleMyElement (player['playerPanel'], {width: panelWidth + 'px'});
/* Resize The Content */
player['contentWidth'] = playerWidth;
player['contentHeight'] = playerHeight - player['panelHeight'] - player['panelPadding'] * 2;
styleMyElement (player['playerContent'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px'});
if (player['contentImage']) styleMyElement (player['contentImage'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px', border: '0px'});
if (player['isPlaying']) {
player['contentVideo'].width = player['contentWidth'];
player['contentVideo'].height = player['contentHeight'];
styleMyElement (player['contentVideo'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px'});
}
}
function cleanMyContent (content, unesc) {
var myNewContent = content;
if (unesc) myNewContent = unescape (myNewContent);
myNewContent = myNewContent.replace (/\\u0025/g,'%');
myNewContent = myNewContent.replace (/\\u0026/g,'&');
myNewContent = myNewContent.replace (/\\/g,'');
myNewContent = myNewContent.replace (/\n/g,'');
return myNewContent;
}
function getMyContent (url, pattern, clean) {
var myPageContent, myVideosParse, myVideosContent;
var isIE = (navigator.appName.indexOf('Internet Explorer') != -1) ? true : false;
var getMethod = (url != page.url || isIE) ? 'XHR' : 'DOM';
if (getMethod == 'DOM') {
myPageContent = getMyElement ('', 'html', 'tag', '', 0, true);
if (!myPageContent) myPageContent = getMyElement ('', 'body', '', '', -1, true);
if (clean) myPageContent = cleanMyContent (myPageContent, true);
myVideosParse = myPageContent.match (pattern);
myVideosContent = (myVideosParse) ? myVideosParse[1] : null;
if (myVideosContent) return myVideosContent;
else getMethod = 'XHR';
}
if (getMethod == 'XHR') {
var xmlHTTP = new XMLHttpRequest();
xmlHTTP.open('GET', url, false);
xmlHTTP.send();
if (pattern == 'XML') {
myVideosContent = xmlHTTP.responseXML;
}
else if (pattern == 'TEXT') {
myVideosContent = xmlHTTP.responseText;
}
else {
myPageContent = xmlHTTP.responseText;
if (clean) myPageContent = cleanMyContent (myPageContent, true);
myVideosParse = myPageContent.match (pattern);
myVideosContent = (myVideosParse) ? myVideosParse[1] : null;
}
return myVideosContent;
}
}
function setMyOptions (key, value) {
try {
localStorage.setItem(key, value);
}
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 () {
var vtPlugin = 'viewtube_plugin';
var vtAutoplay = 'viewtube_autoplay';
var vtDefinition = 'viewtube_definition';
var vtContainer = 'viewtube_container';
var vtWidesize = 'viewtube_widesize';
var vtFullsize = 'viewtube_fullsize';
try {
if (localStorage.getItem(vtPlugin)) option['plugin'] = localStorage.getItem(vtPlugin);
if (localStorage.getItem(vtAutoplay)) option['autoplay'] = localStorage.getItem(vtAutoplay);
if (localStorage.getItem(vtDefinition)) option['definition'] = localStorage.getItem(vtDefinition);
if (localStorage.getItem(vtContainer)) option['container'] = localStorage.getItem(vtContainer);
if (localStorage.getItem(vtWidesize)) option['widesize'] = localStorage.getItem(vtWidesize);
if (localStorage.getItem(vtFullsize)) option['fullsize'] = localStorage.getItem(vtFullsize);
}
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);
if (cookie.indexOf(vtPlugin) == 0) option['plugin'] = cookie.substring(vtPlugin.length + 1, cookie.length);
if (cookie.indexOf(vtAutoplay) == 0) option['autoplay'] = cookie.substring(vtAutoplay.length + 1, cookie.length);
if (cookie.indexOf(vtDefinition) == 0) option['definition'] = cookie.substring(vtDefinition.length + 1, cookie.length);
if (cookie.indexOf(vtContainer) == 0) option['container'] = cookie.substring(vtContainer.length + 1, cookie.length);
if (cookie.indexOf(vtWidesize) == 0) option['widesize'] = cookie.substring(vtWidesize.length + 1, cookie.length);
if (cookie.indexOf(vtFullsize) == 0) option['fullsize'] = cookie.substring(vtFullsize.length + 1, cookie.length);
}
}
option['autoplay'] = (option['autoplay'] == 'true') ? true : false;
option['widesize'] = (option['widesize'] == 'true') ? true : false;
option['fullsize'] = (option['fullsize'] == 'true') ? true : false;
}
function showMyMessage (cause, content) {
var myScriptLogo = createMyElement ('div', userscript, '', '', '');
styleMyElement (myScriptLogo, {margin: '0px auto', padding: '10px', color: '#666666', fontSize: '24px', textAlign: 'center', textShadow: '#FFFFFF -1px -1px 2px'});
var myScriptMess = createMyElement ('div', '', '', '', '');
styleMyElement (myScriptMess, {border: '1px solid #F4F4F4', margin: '5px auto 5px auto', padding: '10px', backgroundColor: '#FFFFFF', 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: '#F8F8F8', fontSize: '14px', textAlign: 'center', zIndex: '99999'});
appendMyElement (myScriptAlert, myScriptLogo);
var myNoPlayerMess = 'Couldn\'t get the player element. Please report it <a href="' + contact + '">here</a>.';
modifyMyElement (myScriptMess, 'div', myNoPlayerMess, false);
appendMyElement (myScriptAlert, myScriptMess);
var myScriptAlertButton = createMyElement ('div', 'OK', 'click', 'close', myScriptAlert);
styleMyElement (myScriptAlertButton, {width: '100px', border: '3px solid #EEEEEE', borderRadius: '5px', margin: '0px auto', backgroundColor: '#EEEEEE', color: '#666666', fontSize: '18px', textAlign: 'center', textShadow: '#FFFFFF -1px -1px 2px', cursor: 'pointer'});
appendMyElement (myScriptAlert, myScriptAlertButton);
appendMyElement (page.body, myScriptAlert);
}
else if (cause == '!thumb') {
var myNoThumbMess = '<br><br>Couldn\'t get the thumbnail for this video. Please report it <a href="' + contact + '">here</a>.';
modifyMyElement (player['playerContent'], 'div', myNoThumbMess, false);
}
else {
appendMyElement (myPlayerWindow, myScriptLogo);
if (cause == '!content') {
var myNoContentMess = 'Couldn\'t get the videos content. Please report it <a href="' + contact + '">here</a>.';
modifyMyElement (myScriptMess, 'div', myNoContentMess, false);
}
else if (cause == '!videos') {
var myNoVideosMess = 'Couldn\'t get any video. Please report it <a href="' + contact + '">here</a>.';
modifyMyElement (myScriptMess, 'div', myNoVideosMess, false);
}
else if (cause == '!support') {
var myNoSupportMess = 'This video uses the RTMP protocol and is not supported.';
modifyMyElement (myScriptMess, 'div', myNoSupportMess, false);
}
else if (cause == 'embed') {
var myEmbedMess = 'This is an embedded video. You can watch it <a href="' + content + '">here</a>.';
modifyMyElement (myScriptMess, 'div', myEmbedMess, false);
}
appendMyElement (myPlayerWindow, myScriptMess);
}
}
// ==========Websites========== //
// =====YouTube===== //
if (page.url.indexOf('youtube.com/watch') != -1) {
/* Get Player Window */
var ytFeatherBeta;
var ytPlayerWindow = getMyElement ('', 'div', 'id', 'player', -1, false);
if (!ytPlayerWindow) {
ytPlayerWindow = getMyElement ('', 'div', 'id', 'p', -1, false);
ytFeatherBeta = true;
}
if (!ytPlayerWindow) {
showMyMessage ('!player');
}
else {
/* Get Video Thumbnail */
if (ytFeatherBeta) {
var ytVideoID = page.url.match (/watch\?v=(.*?)(&|$)/);
if (ytVideoID) var ytVideoThumb = 'http://img.youtube.com/vi/' + ytVideoID[1] + '/0.jpg';
}
else {
var ytVideoThumb = getMyContent (page.url, 'link\\s+itemprop="thumbnailUrl"\\s+href="(.*?)"', false);
if (!ytVideoThumb) ytVideoThumb = getMyContent (page.url, 'meta\\s+property="og:image"\\s+content="(.*?)"', false);
if (!ytVideoThumb) {
var ytVideoID = page.url.match (/watch\?v=(.*?)(&|$)/);
if (ytVideoID) ytVideoThumb = 'http://img.youtube.com/vi/' + ytVideoID[1] + '/0.jpg';
}
}
/* Get Video Title */
if (ytFeatherBeta) {
var ytVideoTitle = page.doc.title;
}
else {
var ytVideoTitle = getMyContent (page.url, 'meta\\s+itemprop="name"\\s+content="(.*?)"', false);
if (!ytVideoTitle) ytVideoTitle = getMyContent (page.url, 'meta\\s+property="og:title"\\s+content="(.*?)"', false);
if (!ytVideoTitle) ytVideoTitle = page.doc.title;
}
if (ytVideoTitle) {
ytVideoTitle = ytVideoTitle.replace(/"/g, '\'').replace(/"/g, '\'').replace(/"/g, '\'');
ytVideoTitle = ytVideoTitle.replace(/'/g, '\'').replace(/'/g, '\'');
ytVideoTitle = ytVideoTitle.replace(/&/g, 'and').replace(/&/g, 'and');
ytVideoTitle = ytVideoTitle.replace(/\?/g, '').replace(/[#:\*]/g, '-').replace(/\//g, '-');
ytVideoTitle = ytVideoTitle.replace(/^\s+|\s+$/, '').replace(/\.+$/g, '');
ytVideoTitle = ytVideoTitle.replace(/^YouTube\s-\s/, '');
}
/* Get Videos Content */
if (ytFeatherBeta) {
var ytVideosContent = getMyContent (page.url, 'url_encoded_fmt_stream_map=(.*?)=', false);
if (ytVideosContent) ytVideosContent = cleanMyContent (ytVideosContent, true);
}
else {
var ytVideosContent = getMyContent (page.url, '"url_encoded_fmt_stream_map":\\s+"(.*?)"', false);
if (ytVideosContent) ytVideosContent = cleanMyContent (ytVideosContent, false);
}
/* Clean Player Window */
var ytWatchPlayer = getMyElement ('', 'div', 'id', 'player-api', -1, false);
if (ytWatchPlayer) cleanMyElement (ytWatchPlayer, true);
/* My Player Window */
var myPlayerWindow = createMyElement ('div', '', '', '', '');
styleMyElement (myPlayerWindow, {position: 'relative', width: '640px', height: '416px', backgroundColor: '#F4F4F4', zIndex: '99999'});
if (ytFeatherBeta) {
modifyMyElement (ytPlayerWindow, 'div', '', true);
styleMyElement (ytPlayerWindow, {height: '100%'});
}
appendMyElement (ytPlayerWindow, myPlayerWindow);
/* Get Videos */
if (ytVideosContent) {
var ytVideoFormats = {
'5': 'Very Low Definition FLV',
'17': 'Very Low Definition 3GP',
'18': 'Low Definition MP4',
'22': 'High Definition MP4',
'34': 'Low Definition FLV',
'35': 'Standard Definition FLV',
'36': 'Low Definition 3GP',
'37': 'Full High Definition MP4',
'38': 'Ultra High Definition MP4',
'43': 'Low Definition WebM',
'44': 'Standard Definition WebM',
'45': 'High Definition WebM',
'46': 'Full High Definition WebM',
'82': 'Low Definition 3D MP4',
'83': 'Standard Definition 3D MP4',
'84': 'High Definition 3D MP4',
'85': 'Full High Definition 3D MP4',
'100': 'Low Definition 3D WebM',
'101': 'Standard Definition 3D WebM',
'102': 'High Definition 3D WebM'
};
var ytVideoList = {};
var ytVideoFound = false;
var ytVideos = ytVideosContent.split(',');
var ytVideoParse, ytVideoCodeParse, ytVideoCode, myVideoCode, ytVideo;
for (var i = 0; i < ytVideos.length; i++) {
if (!ytVideos[i].match(/^url/)) {
ytVideoParse = ytVideos[i].match(/(.*)(url=.*$)/);
if (ytVideoParse) ytVideos[i] = ytVideoParse[2] + '&' + ytVideoParse[1];
}
ytVideoCodeParse = ytVideos[i].match (/itag=(\d{1,3})/);
ytVideoCode = (ytVideoCodeParse) ? ytVideoCodeParse[1] : null;
if (ytVideoCode) {
myVideoCode = ytVideoFormats[ytVideoCode];
if (myVideoCode) {
ytVideo = ytVideos[i].replace (/url=/, '').replace(/&$/, '').replace(/&itag=\d{1,3}/, '');
if (ytVideo.match(/type=.*?&/)) ytVideo = ytVideo.replace(/type=.*?&/, '');
else ytVideo = ytVideo.replace(/&type=.*$/, '');
if (ytVideo.match(/&sig=/)) ytVideo = ytVideo.replace (/&sig=/, '&signature=');
else {
var ytSig = ytVideo.match(/&s=(.*?)(&|$)/);
if (ytSig) {
var s = ytSig[1].split('');
s = s.slice(79, 85).reverse().join('') + s[87] + s.slice(61, 78).reverse().join('') + s[0] + s.slice(4, 60).reverse().join('');
ytVideo = ytVideo.replace(/&s=.*?(&|$)/, '&signature=' + s + '$1');
}
else ytVideo = '';
}
ytVideo = cleanMyContent (ytVideo, true);
if (ytVideo && ytVideo.indexOf('http') == 0) {
if (!ytVideoFound) ytVideoFound = true;
ytVideoList[myVideoCode] = ytVideo;
}
}
}
}
if (ytVideoFound) {
/* Get Watch Sidebar */
var ytSidebarWindow = getMyElement ('', 'div', 'id', 'watch7-sidebar', -1, false);
if (!ytSidebarWindow) ytSidebarWindow = getMyElement ('', 'div', 'id', 'rc', -1, false);
/* Create Player */
var ytDefaultVideo = 'Low Definition MP4';
player = {
'playerSocket': ytPlayerWindow,
'playerWindow': myPlayerWindow,
'videoList': ytVideoList,
'videoPlay': ytDefaultVideo,
'videoThumb': ytVideoThumb,
'videoTitle': ytVideoTitle,
'playerWidth': 640,
'playerHeight': 416,
'playerWideWidth': 970,
'playerWideHeight': 532,
'sidebarWindow': ytSidebarWindow,
'sidebarMarginNormal': -390,
'sidebarMarginWide': 10
};
if (!ytSidebarWindow || page.url.indexOf('list=') != -1) feature['widesize'] = false;
option['autoget'] = true;
option['definitions'] = ['Ultra High Definition', 'Full High Definition', 'High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
option['containers'] = ['MP4', 'WebM', 'FLV', '3GP', 'Any'];
createMyPlayer ();
}
else {
if (ytVideosContent.indexOf('conn=rtmp') != -1) showMyMessage ('!support');
else showMyMessage ('!videos');
}
}
else {
var ytVideoAvailable = getMyElement ('', 'div', 'id', 'player-unavailable', -1, false);
if (ytVideoAvailable && ytVideoAvailable.className.indexOf('hid') == -1) removeMyElement(ytPlayerWindow, myPlayerWindow);
else showMyMessage ('!content');
}
}
}
// =====DailyMotion===== //
else if (page.url.indexOf('dailymotion.com/video') != -1) {
/* Get Player Window */
var dmPlayerWindow = getMyElement ('', 'div', 'id', 'player_main', -1, false);
if (!dmPlayerWindow) {
showMyMessage ('!player');
}
else {
/* Get Video Thumbnail */
var dmVideoThumb = getMyContent (page.url, 'meta\\s+property="og:image"\\s+content="(.*?)"', false);
/* Get Videos Content */