-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse.user.js
1398 lines (1326 loc) · 76.3 KB
/
parse.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 全网VIP视频自动解析蓝光播放器(已适配苹果,安卓,PC端)
// @namespace https://www.tampermonkey.net/
// @version 1.1.8.8
// @license AGPL-3.0
// @description 无需跳转新网址,打开官网直接看,蓝光 4k 无广告 随机去水印。支持:腾讯,爱奇艺,优酷,哔哩哔哩,咪咕,乐视,搜狐,芒果,西瓜,PPTV,1905电影网,华数。支持解析失败自动切换推荐解析源。适配各种浏览器。
// @description 新增加视频嗅探,m3u8视频下载 视频下载转mp4(该功能目前只试配PC端)
// @author Tenfond
// @match *://v.qq.com/*
// @match *://m.v.qq.com/*
// @match *://www.iqiyi.com/*
// @match *://m.iqiyi.com/*
// @match *://*.youku.com/*
// @match *://*.bilibili.com/*
// @match *://*.miguvideo.com/*
// @match *://*.le.com/*
// @match *://tv.sohu.com/*
// @match *://film.sohu.com/*
// @match *://m.tv.sohu.com/*
// @match *://*.mgtv.com/*
// @match *://*.ixigua.com/*
// @match *://*.pptv.com/*
// @match *://vip.1905.com/*
// @match *://www.wasu.cn/*
// @include *://*.*/*url=http*://*.*.*/*
// @include *://*.*:*/*url=http*://*.*.*/*
// @include *://*.*/*v=http*://*.*.*/*
// @include *://*.*:*/*v=http*://*.*.*/*
// @match *://api.leduotv.com/*?vid=*
// @grant GM_getValue
// @grant GM_setValue
// @run-at document-body
// ==/UserScript==
/**
* 任务清单:
*/
// 读取配置后执行
function readSettings() {
// 获取框架循环时间,CPU性能好的可以设置为100,CPU性能不好的可以设置为1000
settings.getElementTimes = 500;
// log输出字体布局
settings.fontStyle = {
error: "font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; color: #f00;",
warn: "font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; color: #ff0;",
ok: "font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; color: #0f0;",
maxTip: "font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; font-size: 30px; background-color: #222; text-shadow: 0px 0px 12px #fff; color: #fff;"
};
if (window === top) {
/*
* (): 小括号括住的表示推荐解析 画质高 速度快
* : 无括号的表示视频带水印 或 原页面画质
* []: 方括号表示标清画质 不推荐
*/
settings.NoAD解析 = { // TODO by 17kyun.com/api.php?url= // TODO by tv.hzwdd.cn
// 你可以在这里定义自己的解析接口,脚本会自动适配。格式如下:
// "解析名称": "解析接口的链接", // TODO 注意 : 和 " 以及 , 都是英文的符号。
"PPJ蓝光解析": "https://bf.ppjbk.cn/?url=", // TODO 腾讯 (芒果)
"冰豆":"https://api.qianqi.net/vip/?url=",
"PPJ解析": "https://jx.ppjbk.cn/?url=", // TODO 腾讯 (芒果) (B站)
"PPJ弹幕解析2": "https://bf.ppjbk.cn/bf/?url=", // TODO 腾讯 (芒果)
"OK解析": "https://api.okjx.cc:3389/jx.php?url=" || "https://okjx.cc/?url=" || "https://m2090.com/?url=", // TODO 优质: 腾讯 (爱奇艺) 优酷 乐视 芒果 PPTV (华数)
"全民解析": "https://jx.quanmingjiexi.com/?url=" || "https://chaxun.truechat365.com/?url=", // TODO (腾讯)
"云解析": "https://jx.aidouer.net/?url=" || "https://jx.ppflv.com/?url=", // TODO 腾讯 [爱奇艺] 优酷 (乐视) 芒果 (1905电影网) [华数]
"天翼解析": "https://jsap.attakids.com/?url=" || "https://www.qianyicp.com/vip/vip_g.php?url=", // _4K解析: "", // TODO 腾讯 爱奇艺 (优酷) 咪咕 乐视 (芒果) 西瓜 PPTV
"虾米解析": "https://jx.xmflv.com/?url=", // TODO (土豆) (咪咕) 搜狐 (芒果)
"九八看解析": "https://jx.ap2p.cn/?url=", // (Parwix解析: "https://jx.parwix.com:4433/player/analysis.php?v=" || "https://vip.parwix.com:4433/player/?url=" || ) // TODO (西瓜) (B站) (搜狐) (芒果)
"夜幕解析": "https://www.yemu.xyz/?url=" // TODO 土豆 华数 芒果:可能有广告 // by www.yunboys.cn
};
settings.AD解析 = { // TODO (有赌博广告,请勿相信,这么简单的骗术不会有人上当吧)
"z1解析": "https://z1.m1907.cn?jx=",
"乐多解析": "https://api.leduotv.com/wp-api/ifr.php?isDp=1&vid=", // TODO (B站)
"Parwix解析": "https://jx.parwix.com:4433/player/?url=" // TODO 无水印(但不稳定): 腾讯 爱奇艺 优酷 乐视 [芒果] (PPTV) (华数)
};
start();
} else if (settings.isParse) {
top.postMessage(key.ENCRYPT("宝塔镇河妖\x00给予\x000\x00" + location.href, settings.k1, settings.k2), "*");
Object.defineProperty(console, "clear", {
value: () => console.log("%c禁止清除控制台", settings.fontStyle.error), writable: false
});
settings.parseDB = new Promise(resolve => {
window.addEventListener("message", event => {
if (event.source !== window) {
try {
let sql = key.DECRYPT(event.data, settings.k1, settings.k2).split("\x00");
if (sql[0] === "天王盖地虎") {
if (sql[1] === "给予") {
if (sql[2] === "用户数据库") {
resolve(JSON.parse(sql[3]));
}
}
}
} catch (e) {
// 排除 下标越界错误 及 指令处理错误
}
}
});
});
// 需要先监听再发送数据
top.postMessage(key.ENCRYPT("宝塔镇河妖\x00请求\x00用户数据库", settings.k1, settings.k2), "*");
start();
}
}
// 未经许可禁止抄袭算法,可以私用。
const key = (() => {
// 新方案定义私有变量。修复部分浏览器不支持 # 定义private私有变量
const password = Symbol();
const randomkey = Symbol();
// 自定义加密算法,以防数据包被破解。
class key {
// _pwd; // 火狐v68版本貌似不支持这种方式声明变量。
constructor(pwd = null) {
// num,密码偏移量
// key,排列长度偏移量
// charCode,防止内存频繁运动,定义在外部
let num = 7, charCode, key = 7;
if (pwd) {
if (typeof pwd === "string") {
for (let i = 0; i < pwd.length; i++) {
// 将pwd中 每个字 转换成 十进制ASCII值
charCode = pwd[i].charCodeAt();
// 将每个 ASCII值 中 第一个值加入到 排列长度偏移量
key += parseInt(charCode.toString()[0]);
// 用 hash算法 将 ASCII值 减去 31 作为新的值加入到num中
// 以下方法是为了防止出现负数,ASCII字符集一共有65536个字符
// num += charCode - 31 => (charCode + 65505) % 65536
num = 31 * num + (charCode + 65505) % 65536;
}
} else if (typeof pwd === "number") {
// 如果密码是数值型就使用此方法作为 密码偏移量 和 排列长度偏移量
num = key = 7 + parseInt(Math.abs(pwd));
} else {
// 如果类型不匹配就直接提出错误
console.error("Unsupported type '" + (typeof pwd) + "'. It only supports 'string' or 'number'.")
}
}
// 让排列长度偏移量的转换成8进制,取第一个数字。加上密码转换成字符字符串的方式。数值+字符串 会将数值自动转换为字符串
this[password] = key.toString(8)[0] + (num % 65536).toString();
}
encrypt(string) {
if (string) {
// subStart 排列长度的起始位置。subIndex 排列长度。 encryptPool 加密池,即去除的排列长度存放在这里。result 加密后的结果。
let subStart = string.length, subIndex = parseInt(this[password][0]) + 3, encryptPool = [], result = "";
// stringKey 加密字符偏移量的散列值的的个数。
let stringKey = subStart + parseInt(this[password].substring(1));
// stringKeyFloat 加密字符偏移量的偏移单位。stringKeyIndex 加密字符偏移量的位置
let stringKeyFloat = 65536 / stringKey, stringKeyIndex = stringKey - 1;
// 获取加密池。
while (subStart > subIndex) {
subStart -= subIndex;
encryptPool.push(string.substr(subStart, subIndex));
}
encryptPool.push(string.substring(0, subStart));
// 对加密池进行加密,并将加密的字符的结果放入 result 中。
for (let i = 0, j; i < subIndex; i++) {
for (j = 0; j < encryptPool.length; j++) {
let char = encryptPool[j][i];
if (char) {
// 将字符的 ASCII值 偏移 指定量
result += String.fromCharCode((char.charCodeAt() + parseInt(stringKeyFloat * (stringKeyIndex % 2 === 0 ? stringKeyIndex : stringKey - stringKeyIndex))) % 65536);
stringKeyIndex = stringKeyIndex === 0 ? stringKey - 1 : stringKeyIndex - 1;
} else {
break;
}
}
}
// 返回加密结果
return result;
} else {
// 如果加密字符串不存在就返回空字符串
return "";
}
}
/* 假设有7个字符
加密前 - 排列
( 1 ) ( 2 3 ) ( 4 5 ) ( 6 7 )
加密中 - 排列
︵ ︵ ︵ ︵
6 4 2 1
7 5 3 ︶
︶ ︶ ︶
加密后 - 排列
( 6 4 2 1 ) ( 7 5 3 )
解密中 - 排列
︵ ︵
6 7
4 5
2 3
1 ︶
︶
解密后 - 排列
1 2 3 4 5 6 7 8
*/
decrypt(string) {
if (string) {
// subStart 排列长度的起始位置。desubIndex 反向取加密池的长度。 decryptPool 解密池。
let subStart = 0, desubIndex = Math.ceil(string.length / (parseInt(this[password][0]) + 3)),
//NullCount 加密池中最后一个元素的元素空位。 desubIndex 反向取加密池的长度。 decryptPool 解密池,result 解密后的结果。
NullCount = string.length % (parseInt(this[password][0]) + 3), decryptPool = [], result = "";
// stringKey 加密字符偏移量的散列值的的个数。
let stringKey = string.length + parseInt(this[password].substring(1)), // stringKeyFloat 加密字符偏移量的偏移单位。stringKeyIndex 加密字符偏移量的位置
stringKeyFloat = 65536 / stringKey, stringKeyIndex;
// 获取解密池
while (string.length - subStart > desubIndex) {
decryptPool.push(string.substr(subStart, desubIndex));
subStart += desubIndex;
if (decryptPool.length === NullCount) {
desubIndex--;
}
}
decryptPool.push(string.substring(subStart));
// 对解密池进行解密 并将解密结果 加入到 result(结果) 中
for (let j = decryptPool[0].length - 1, i; j > -1; j--) {
// 为节省NullCount的空间利用,使用NullCount用来辅助计算 stringKeyIndex(加密字符偏移量的位置) 的位置
// 画图排列就知道为什么要这样做了,上面做了一个加密到解密的排列的草图
NullCount = 0;
for (i = 0; i < decryptPool.length; i++) {
let char = decryptPool[i][j];
if (char) {
NullCount += decryptPool[i].length;
// 计算得到当前字符的位置
stringKeyIndex = NullCount - decryptPool[i].length + j + 1;
// 计算得到 stringKeyIndex(加密字符偏移量的位置) 的位置
stringKeyIndex = (stringKey - stringKeyIndex % stringKey) % stringKey;
// 让加密后的偏移量,偏移回去,得到原先的字符串
result += String.fromCharCode((char.charCodeAt() - parseInt(stringKeyFloat * (stringKeyIndex % 2 === 0 ? stringKeyIndex : stringKey - stringKeyIndex)) + 65536) % 65536);
}
}
}
// 返回解密结果
return result;
} else {
// 如果解密字符串不存在就返回空字符串
return "";
}
}
// encrypt 既可以用作加密 也可以用作解密,decrypt 既可以用作解密 也可以用作加密。
static ENCRYPT() {
if (arguments) {
let strings = [], keys = [];
for (let i = 0; i < arguments.length; i++) {
// JavaScript如何用最简单的方法获取任意对象的类名?(包括自定义类) 判断对象类型?
// 欢迎支持我的原创文档 https://blog.csdn.net/qq_37759464/article/details/121764755
if (arguments[i].constructor.name === "key") {
keys.push(arguments[i]);
} else if (arguments[i].constructor.name === "String") {
strings.push(arguments[i]);
}
}
if (strings) {
if (keys) {
for (let i = 0, j; i < strings.length; i++) {
for (j = 0; j < keys.length; j++) {
strings[i] = i % 2 === 0 ? keys[j].encrypt(strings[i]) : keys[j].decrypt(strings[i]);
}
}
return strings.length === 1 ? strings[0] : strings;
} else {
if (!this[randomkey]) {
this[randomkey] = new key(parseInt(Math.random() * 1024) + 3);
}
// 为了使加密方法不一样,这里反过来
strings[i] = this[randomkey].decrypt(this[randomkey].decrypt(strings[i]));
return strings.length === 1 ? strings[0] : strings;
}
}
}
}
static DECRYPT() {
if (arguments) {
let strings = [], keys = [];
for (let i = 0; i < arguments.length; i++) {
if (arguments[i].constructor.name === "key") {
keys.push(arguments[i]);
} else if (arguments[i].constructor.name === "String") {
strings.push(arguments[i]);
}
}
if (strings) {
if (keys) {
for (let i = 0, j; i < strings.length; i++) {
for (j = keys.length - 1; j > -1; j--) {
strings[i] = i % 2 === 0 ? keys[j].decrypt(strings[i]) : keys[j].encrypt(strings[i]);
}
}
return strings.length === 1 ? strings[0] : strings;
} else {
if (!this[randomkey]) {
this[randomkey] = new key(parseInt(Math.random() * 1024) + 3);
}
strings[i] = this[randomkey].encrypt(this[randomkey].encrypt(strings[i]));
return strings.length === 1 ? strings[0] : strings;
}
}
}
}
}
return key;
})();
// 有人反馈苹果端不能看,尝试修改UA解决
if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i)) {
// 修改手机端UA,似乎改完这个UA还是没有效果。说明苹果端页面从数据请求就开始检测UA了。请手动修改浏览器UA。
Object.defineProperty(navigator, 'userAgent', {
// 这个UA会屏蔽百度搜索的广告?
value: "Mozilla/5.0 (Linux; Android 8.0; MI 6 Build/OPR1.170623.027; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/48.0.2564.116 Mobile Safari/537.36 T7/10.3 SearchCraft/2.6.3 (Baidu; P1 8.0.0)",
writable: false
});
}
let settings = {};
const root = document.querySelector(":root");
// 核心驱动代码
(() => {
if (location.search.match(/[?&]url=https?:\/\/.+\..+\..+\/.+/i) ||
location.search.match(/[?&]v=https?:\/\/.+\..+\..+\/.+/i) ||
location.href.match(/https?:\/\/api\.leduotv\.com\/.+?vid=/i)) {
settings.isParse = true;
}
if (settings.isParse || location.host.indexOf("v.qq.com") !== -1 || location.host.indexOf("iqiyi.com") !== -1 || location.host.indexOf("youku.com") !== -1 || location.host.indexOf("bilibili.com") !== -1 || location.host.indexOf("miguvideo.com") !== -1 || location.host.indexOf("le.com") !== -1 || location.host.indexOf("tv.sohu.com") !== -1 || location.host.indexOf("film.sohu.com") !== -1 || location.host.indexOf("mgtv.com") !== -1 || location.host.indexOf("ixigua.com") !== -1 || location.host.indexOf("pptv.com") !== -1 || location.host.indexOf("vip.1905.com") !== -1 || location.host.indexOf("www.wasu.com") !== -1) {
// 对符合条件的域名执行脚本
// 调用自写加密算法,生成实例类
settings.k1 = new key("Tenfond");
settings.k2 = new key(" 腾 风 ");
if (window === top) {
settings.parseDB = {
解析开关: "\x01", 弹幕开关: "\x01", DIY解析栏: "\x01"
};
for (let name in settings.parseDB) {
let data = localStorage.getItem("解析数据库." + name);
if (data !== null) {
settings.parseDB[name] = data;
}
}
// 油猴可以实现跨域存储
try {
let data = GM_getValue("弹幕开关");
if (data !== null) settings.parseDB.弹幕开关 = data;
} catch (e) {
// 排除无效函数异常
}
if (settings.parseDB.解析开关) {
if (!sessionStorage.getItem("tip设置")) {
showTip("右下角可以编辑 设置");
sessionStorage.setItem("tip设置", "\x01");
}
readSettings();
}
settings.parseDBFuntions = {
解析开关: () => {
if (!settings.parseDB.解析开关) {
location.reload();
// window 刷新时会自动清除缓存
} else {
readSettings();
settings.parseDB.解析开关 = "\x01";
}
},
弹幕开关: () => {
try {
GM_setValue("弹幕开关", settings.parseDB.弹幕开关)
} catch (error) {
// 排除无效函数异常
}
showTip("刷新页面即可生效");
},
DIY解析栏: () => {
if (typeof settings.DIY_iframeFunction === "function") {
settings.DIY_iframeFunction();
} else {
showTip("设置已生效");
}
}
};
let toolsBar = document.createElement("toolsbar");
toolsBar.style = "display: block !important; visibility: visible !important; position: fixed; z-index: 2147483647 !important; left:0; bottom: 0; width: 100%; height: 0; font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; font-size: 15px; color: #000;";
toolsBar.innerHTML = "<style>\n" +
" text{font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; font-size: 15px; color: #000; position: absolute; transform: translateY(-50%); top: 50%;}\n" +
" label.parse-switch{position: absolute; transform: translateY(-50%); top: 50%; display: inline-block; width: 44px; height: 24px; box-shadow: 0 0 0 1px #ccc; border-radius: 30px; overflow: hidden;}\n" +
" label.parse-switch>input[type=checkbox]{display: none;}\n" +
" label.parse-switch>input[type=checkbox]+bg{position: absolute; transition: background-color 0.3s; background-color: #ccc; width: 100%; height: 100%;}\n" +
" label.parse-switch>input[type=checkbox]:checked+bg{background-color: #4af}\n" +
" label.parse-switch>input[type=checkbox]+bg+span{position: absolute; transition: left 0.3s; left: 0; width: 24px; height: 24px; border-radius: 50%; background-color: #fff;}\n" +
" label.parse-switch>input[type=checkbox]:checked+bg+span{left: 20px}\n" + "\n" +
" settings>button+ul>li{position: relative; background-color: #0000; width: 100%; height: 30px;}\n" +
"</style>\n" + "<settings style='box-shadow: 0 0 6px 2px #444; position: fixed; width: 50px; height: 30px; right: 7%; bottom: 45px; border-radius: 15px;'>" +
" <button style='width: 100%; height: 100%; border-radius: 17px; background-color: #4af; border-color: #4af; text-align: center; color: #fff;'>\n" +
" 设置\n" +
" </button>\n" +
" <ul style='position:absolute; transition: all 0.5s; right: 7%; bottom: 100%; opacity: 0; width: 0; height: auto; background-color: #fffc; border: 1px solid #ccc; border-radius: 5px;'>\n" +
" </ul>\n" +
"</settings>";
let SettingsBlock = toolsBar.querySelector("settings>button+ul");
let parseDBKeys = Object.keys(settings.parseDB);
for (let i = 0; i < parseDBKeys.length; i++) {
SettingsBlock.innerHTML += "<li><text style='left: 10px'>" + parseDBKeys[i] + "</text><label class='parse-switch' style='right: 10px;'><input type='checkbox'><bg></bg><span></span></label></li>\n";
}
let SettingBlockSwitchs = SettingsBlock.querySelectorAll("li>label.parse-switch");
for (let i = 0; i < SettingBlockSwitchs.length; i++) {
let checkBox = SettingBlockSwitchs[i].querySelector("input[type=checkbox]");
checkBox.checked = Boolean(settings.parseDB[parseDBKeys[i]]);
SettingBlockSwitchs[i].querySelector("bg").addEventListener("transitionend", () => {
if (checkBox.checked !== Boolean(settings.parseDB[parseDBKeys[i]])) {
// 如果有变化才会执行,否则会重复执行,因为动画会有延迟,刚打开网页时也会触发此监听事件
if (checkBox.checked) {
settings.parseDB[parseDBKeys[i]] = "\x01";
} else {
settings.parseDB[parseDBKeys[i]] = "";
}
localStorage.setItem("解析数据库." + parseDBKeys[i], settings.parseDB[parseDBKeys[i]]);
settings.parseDBFuntions[parseDBKeys[i]]();
}
}, false);
}
let SettingsBtn = toolsBar.querySelector("settings>button");
SettingsBtn.onclick = () => {
if (SettingsBlock.style.opacity === "0") {
SettingsBtn.innerText = "关闭";
SettingsBlock.style.opacity = "1";
SettingsBlock.style.width = "200px";
} else {
SettingsBtn.innerText = "设置";
SettingsBlock.style.opacity = "0";
SettingsBlock.style.width = "0";
}
}
root.append(toolsBar);
} else {
readSettings();
}
}
})();
// 启动解析代码
function start() {
console.log("脚本运行在 " + location.href);
function detectMobile() {
return (navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/webOS/i) ||
navigator.userAgent.match(/Windows Phone/i) ||
navigator.userAgent.match(/Symbian/i) ||
navigator.userAgent.match(/BlackBerry/i) ||
navigator.userAgent.match(/hpwOS/i));
}
function doElement(cssString, doFunction, waitMS = 0) {
let Element = document.querySelector(cssString);
if (Element && Element.nodeType === 1) {
doFunction(Element);
console.log("%c已为 " + cssString + " 进行了操作", settings.fontStyle.ok);
} else if (document.readyState !== "complete" || waitMS > 0) {
console.log("正在查找 " + cssString); // TODO 10毫秒约函数执行时间
setTimeout(() => doElement(cssString, doFunction, document.readyState !== "complete" ? waitMS : waitMS - 10 - settings.getElementTimes), settings.getElementTimes);
} else {
console.log("%c未找到 " + cssString, settings.fontStyle.error);
}
}
function doElements(cssString, doFunction, waitMS = 0, index = 0) {
let Elements = document.querySelectorAll(cssString);
if (Elements[index] && Elements[index].nodeType === 1) {
doFunction(Elements);
console.log("%c已为 All[" + index + "] " + cssString + " 进行了操作", settings.fontStyle.ok);
} else if (document.readyState !== "complete" || waitMS > 0) {
console.log("正在查找 All[" + index + "] " + cssString); // TODO 10毫秒约函数执行时间
setTimeout(() => doElements(cssString, doFunction, document.readyState !== "complete" ? waitMS : waitMS - 10 - settings.getElementTimes, index), settings.getElementTimes);
} else {
console.log("%c未找到 All[" + index + "] " + cssString, settings.fontStyle.error);
}
}
function forElements(cssString, doFunction, waitMS = 0, failFunction = null) {
let forElementInterval = setInterval(() => {
if (document.readyState !== "complete" || waitMS > 0) {
let Elements = document.querySelectorAll(cssString);
if (Elements && Elements.length > 0 && Elements[0].nodeType === 1) {
doFunction(Elements, forElementInterval);
console.log("%cforElements已为 " + cssString + " 进行了操作", settings.fontStyle.ok);
}
if (document.readyState === "complete") {
waitMS = waitMS - 10 - settings.getElementTimes;
}
} else {
if (failFunction) {
failFunction();
}
console.log("已清除 forElements Interval计时器")
clearInterval(forElementInterval);
}
}, settings.getElementTimes);
}
function removeElements(ElementsStrings) {
console.log("正在检测并移除 " + ElementsStrings);
let removeElementsInterval = setInterval(() => {
if (ElementsStrings.length > 0) {
for (let i in ElementsStrings) {
try {
let Elements = eval(ElementsStrings[i]);
console.log(Elements);
if (Elements && Elements.nodeType === 1) {
console.log("%cremoveElemets 执行了移除 " + ElementsStrings[i], settings.fontStyle.ok);
Elements.parentNode.removeChild(Elements);
ElementsStrings.splice(i, 1);
} else if (Elements[0] && Elements[0].nodeType === 1) {
console.log("%cremoveElemets 执行了移除 " + ElementsStrings[i], settings.fontStyle.ok);
for (let Element of Elements) {
Element.parentNode.removeChild(Element);
}
ElementsStrings.splice(i, 1);
}
} catch (e) {
// 排除 null值未找到方法 错误
}
}
if (document.readyState === "complete") {
console.log("%cremoveElemets 移除失败 " + ElementsStrings, settings.fontStyle.error);
clearInterval(removeElementsInterval);
}
} else {
clearInterval(removeElementsInterval);
console.log("Elements 移除完毕");
}
}, 200);
}
if (window === top) {
// 自定义remove方法,暂时用不着了,新方案代替了
// Array.prototype.remove = value => {
// for (let i = 0; i < this.length; i++) {
// if (this[i] === value) {
// this.splice(i, 1);
// return i;
// }
// }
// return -1;
// }
top.addEventListener("message", event => {
if (event.source !== window) {
try {
let sql = key.DECRYPT(event.data, settings.k1, settings.k2).split("\x00");
if (sql[0] === "宝塔镇河妖") {
if (sql[1] === "函数") {
console.log("top执行了函数: " + sql[2]);
eval(sql[2]);
} else if (sql[1] === "请求") {
if (sql[2] === "用户数据库") {
event.source.postMessage(key.ENCRYPT("天王盖地虎\x00给予\x00用户数据库\x00" + JSON.stringify(settings.parseDB), settings.k1, settings.k2), "*");
}
} else if (sql[1] === "给予") {
if (sql[2] === "0") {
if (settings.address !== null) {
settings.address = sql[3];
}
console.log("%c" + settings.address, settings.fontStyle.warn);
} else if (sql[2] === "-1") {
if (settings.address === sql[3]) {
showTip("解析失败,正在更换解析源");
settings.randomSeleceParse();
}
}
} else if (sql[1] === "按下Enter获取焦点") {
onkeydown = e => {
if (e.key === 'Enter') {
event.source.focus();
}
}
}
}
} catch (e) {
console.log("%c" + e, settings.fontStyle.error);
}
}
});
if (!detectMobile()) {
if (location.host.indexOf("v.qq.com") !== -1) {
readyPlayerBox("已进入腾讯视频", ["#mask_layer", ".mod_vip_popup", "#mask_layer"], [settings.NoAD解析["PPJ蓝光解析"], settings.NoAD解析["OK解析"], settings.NoAD解析["天翼解析"], settings.NoAD解析["夜幕解析"]], "div#mod_player", null);
} else if (location.host.indexOf("iqiyi.com") !== -1) {
readyPlayerBox("已进入爱奇艺", ["#playerPopup", "div[class^=qy-header-login-pop]"], [settings.NoAD解析["PPJ蓝光解析"], settings.NoAD解析["OK解析"]], "iqpdiv.iqp-player[data-player-hook$=er],m-player", null);
} else if (location.host.indexOf("youku.com") !== -1) {
readyPlayerBox("已进入优酷视频", ["#iframaWrapper"], [settings.NoAD解析["PPJ蓝光解析"]], "div#player", null);
} else if (location.host.indexOf("bilibili.com") !== -1) {
doElements("div[role=tooltip]:not([class*=popover-])", loginTip => displayNone(["#" + loginTip[6].id]), 1000, 6);
doElement("svg[aria-hidden=true]", () => readyPlayerBox("已进入哔哩哔哩", null, [settings.NoAD解析["夜幕解析"], settings.NoAD解析["PPJ蓝光解析"]], "div.bpx-player-video-area,div.mask-container", null)); // TODO || document.getElementById("bilibiliPlayer") || document.getElementById("live-player-ctnr")
} else if (location.host.indexOf("miguvideo.com") !== -1) {
readyPlayerBox("已进入咪咕视频", null, [], "section#mod-player", null);
} else if (location.host.indexOf("le.com") !== -1) {
readyPlayerBox("已进入乐视TV", null, [settings.NoAD解析["PPJ蓝光解析"]], "#le_playbox", null);
} else if (location.host.match(/(tv|film).sohu.com/)) {
readyPlayerBox("已进入搜狐视频", null, [settings.NoAD解析["夜幕解析"]], "#player,#sohuplayer,.player-view", null);
} else if (location.host.indexOf("mgtv.com") !== -1) {
readyPlayerBox("已进入芒果TV", null, [settings.NoAD解析["PPJ解析"], settings.NoAD解析["PPJ蓝光解析"], settings.NoAD解析["OK解析"], settings.NoAD解析["虾米解析"], settings.NoAD解析["夜幕解析"]], "#mgtv-player-wrap", null);
} else if (location.host.indexOf("ixigua.com") !== -1) {
readyPlayerBox("已进入西瓜视频", null, [settings.NoAD解析["夜幕解析"]], "div.teleplayPage__playerSection", null);
} else if (location.host.indexOf("pptv.com") !== -1) {
readyPlayerBox("已进入PPTV", null, [settings.NoAD解析["PPJ蓝光解析"]], "div.w-video", null);
} else if (location.host.indexOf("vip.1905.com") !== -1) {
readyPlayerBox("已进入1905电影网", null, [settings.NoAD解析["云解析"]], "div#playBox", null);
} else if (location.host.indexOf("www.wasu.cn") !== -1) {
readyPlayerBox("已进入华数TV", null, [settings.NoAD解析["PPJ蓝光解析"]], "div#pcplayer", null);
}
} else {
if (location.host.indexOf("v.qq.com") !== -1) {
readyPlayerBox("已进入腾讯视频", [".mod_vip_popup", "[class^=app_],[class^=app-],[class*=_app_],[class*=-app-],[class$=_app],[class$=-app]", "div[dt-eid=open_app_bottom]", "div.video_function.video_function_new", "a[open-app]", "section.mod_source", "section.mod_box.mod_sideslip_h.mod_multi_figures_h,section.mod_sideslip_privileges,section.mod_game_rec"], [settings.NoAD解析["PPJ蓝光解析"], settings.NoAD解析["OK解析"]], "div.mod_play:not([style*='display: none;']) section.mod_player", null, href => {
let location = hrefToLocation(href);
href = searchToJSON(location.search);
if (href) {
if (href["cid"]) {
if (href["id"]) {
return location.protocol + '//v.qq.com/detail/' + href["cid"][0] + '/' + href["cid"] + '.html';
} else if (href["vid"]) {
return location.protocol + '//v.qq.com/x/cover/' + href["cid"] + '/' + href["vid"] + '.html';
} else {
return location.protocol + '//v.qq.com/x/cover/' + href["cid"] + '.html';
}
} else if (href["vid"]) {
return location.protocol + '//v.qq.com/x/page/' + href["vid"] + '.html';
} else if (href["lid"]) {
return location.protocol + '//v.qq.com/detail/' + href["lid"][0] + '/' + href["lid"] + '.html';
} else {
return null;
}
} else {
return null;
}
});
} else if (location.host.indexOf("iqiyi.com") !== -1) {
readyPlayerBox("已进入爱奇艺", ["div.m-iqyGuide-layer", "a[down-app-android-url]", "[name=m-extendBar]", "[class*=ChannelHomeBanner]", "section.m-hotWords-bottom"], [settings.NoAD解析["PPJ蓝光解析"], settings.NoAD解析["OK解析"]], "section.m-video-player", null);
} else if (location.host.indexOf("youku.com") !== -1) {
readyPlayerBox("已进入优酷视频", ["#iframaWrapper", ".ad-banner-wrapper", ".h5-detail-guide,.h5-detail-vip-guide", ".brief-btm"], [], "#player", null);
} else if (location.host.indexOf("bilibili.com") !== -1) {
readyPlayerBox("已进入哔哩哔哩", ["div.fe-ui-open-app-btn,div.recom-wrapper,open-app-btn", "[class*=openapp]"], [settings.NoAD解析["PPJ蓝光解析"], settings.NoAD解析["夜幕解析"]], "div#app.main-container div.player-wrapper", null, href => href.replace("m.bilibili.com", "www.bilibili.com"));
} else if (location.host.indexOf("miguvideo.com") !== -1) {
readyPlayerBox("已进入咪咕视频", ["[class^=app_],[class^=app-],[class*=_app_],[class*=-app-],[class$=_app],[class$=-app]", ".openClient", "div.group-item.programgroup .data-rate-01,div.group-item.programgroup .max-rate-01,div.group-item.programgroup .p-common"], [], "section#mod-player", null, href => href.replace("m.miguvideo.com", "www.miguvideo.com").replace("msite", "website"));
} else if (location.host.indexOf("le.com") !== -1) {
(block_show => {
block_show.innerHTML = "div.layout{visibility: visible !important; display:block !important;}div.layout>*:not(style,script,#j-vote,#j-follow){visibility: visible !important; display: block !important;}";
document.head.insertBefore(block_show, document.head.firstChild);
})(document.createElement("style"));
doElement("a.j-close-gdt", jump_over => {
jump_over.click();
return false;
});
readyPlayerBox("已进入乐视TV", ["a.leapp_btn", "div.full_gdt_bits[id^=full][data-url]", "[class*=Daoliu],[class*=daoliu],[class*=game]", "div.m-start", "[class*=icon_user]"], [settings.NoAD解析["云解析"]], "div.column.play", null);
} else if (location.host.indexOf("m.tv.sohu.com") !== -1) {
readyPlayerBox("已进入搜狐视频", ["div[class^=banner]", "div.js-oper-pos", "div[id^=ad],div[id^=ad] *", "[id*=login],[class*=login]", "[class$=-app]", "div.app-vbox.ph-vbox,div.app-vbox.app-guess-vbox", "div.twinfo_iconwrap", "div[class$=banner],div[id$=banner]"], [settings.NoAD解析["夜幕解析"]], "#player,#sohuplayer,.player-view", null, async href => {
return new Promise(resolve => {
xmlHttpRequest({
url: href, success: data => {
let result = data.responseText.match(/var videoData = \{[^\x00]+tvUrl:"(http.+)",[\r\n]/)[1];
resolve(result);
}, error: () => resolve(href)
});
});
});
} else if (location.host.indexOf("mgtv.com") !== -1) {
readyPlayerBox("已进入芒果TV", ["div.adFixedContain,div.ad-banner,div.m-list-graphicxcy.fstp-mark", "div[class^=mg-app],div#comment-id.video-comment div.ft,div.bd.clearfix,div.v-follower-info", "div.ht.mgui-btn.mgui-btn-nowelt", "div.personal", "div[data-v-41c9a64e]"], [settings.NoAD解析["PPJ解析"], settings.NoAD解析["PPJ蓝光解析"], settings.NoAD解析["云解析"], settings.NoAD解析["虾米解析"], settings.NoAD解析["夜幕解析"]], "div.video-poster,div.video-area", null);
} else if (location.host.indexOf("ixigua.com") !== -1) {
readyPlayerBox("已进入西瓜视频", ["div.xigua-download", "div.xigua-guide-button", "div.c-long-video-recommend.c-long-video-recommend-unfold"], [settings.NoAD解析["夜幕解析"]], "div.xigua-detailvideo-video", null);
} else if (location.host.indexOf("pptv.com") !== -1) {
readyPlayerBox("已进入PPTV", ["[data-darkreader-inline-bgimage][data-darkreader-inline-bgcolor]", "div[class^=pp-m-diversion]", "section#ppmob-detail-picswiper", "section.layout.layout_ads", "div.foot_app", "div[modulename=导流位]", "a[class*=user]", "div.mod_video_info div.video_func"], [settings.NoAD解析["PPJ蓝光解析"]], "section.pp-details-video", null, href => href.replace("m.pptv.com", "v.pptv.com"));
} else if (location.host.indexOf("vip.1905.com") !== -1) {
(movie_info => {
movie_info.innerHTML = "section#movie_info{padding-top: 20px !important;}";
document.head.appendChild(movie_info);
})(document.createElement("style"));
readyPlayerBox("已进入1905电影网", ["a.new_downLoad[target=_blank]", "iframe[srcdoc^='<img src=']", "section.movieList_new.club_new", ".wakeAppBtn", "[class*=login]", "section.openMembershipBtn", ".ad", ".open-app,.openApp,ul.iconList li:not(.introduceWrap),div#zhichiBtnBox", "section#hot_movie,section#exclusive_movie,section#hot_telve"], [settings.NoAD解析["云解析"]], "div.area.areaShow.clearfix_smile", null);
} else if (location.host.indexOf("www.wasu.cn") !== -1) {
readyPlayerBox("已进入华数TV", ["div.ws_poster", "div.appdown,div.player_menu_con", "div#play_and_info_fix_adv"], [settings.NoAD解析["PPJ蓝光解析"]], "div#player,div#pop", null);
}
}
function readyPlayerBox(Tip, displayNones, srcs, cssString, doFunction, doHref = null) {
if (Tip) {
console.log("%c" + Tip, settings.fontStyle.maxTip);
}
onLocationChange(() => location.reload()); // TODO 如果网页rul变了就刷新页面
if (displayNones) {
displayNone(displayNones);
}
doElement(cssString, async playerBox => {
setInterval(() => {
for (let link of document.querySelectorAll("a")) {
link.onclick = () => {
if (link.host === location.host) {
location.href = link.href;
}
}
}
}, 1500);
let iframe = document.createElement("iframe");
iframe.allowFullscreen = true;
iframe.frameBorder = "0"; // HTML5已弃用此属性,并使用style.border代替
iframe.width = "100%";
iframe.height = "100%";
iframe.style = "background-color: #000 !important; border: 0 !important; display: block !important; visibility: visible !important; opacity: 1 !important;" + " min-width: 100% !important; width: 100% !important; max-width: 100% !important; min-height: 100% !important; height: 100% !important; max-height: 100% !important;" + " position: absolute !important; left: 0px !important; top: 0px !important; z-index: 2147483647 !important; overflow: hidden;";
let iframeStartTime, tested = false, others = Object.values(settings.NoAD解析).filter(value => {
// 求出 srcs 在 NoAD解析 中的补集
return srcs.indexOf(value) === -1;
});
settings.src = (() => {
const src = Symbol();
class Src {
static async set(key, value = location.href) {
if (!key) return false;
this[src] = key;
if (typeof doHref === "function") {
let href = await doHref(value);
iframe.src = key ? key + (href ? href : value) : "";
} else {
iframe.src = key ? key + value : "";
}
iframeStartTime = new Date().getTime();
return true;
}
static get() {
return this[src];
}
}
return Src;
})();
settings.randomSeleceParse = async () => {
// arguments 代表输入的所有参数,看不懂可以百度搜索 “js 参数 arguments”
// return arguments ? arguments[Math.floor(Math.random() * arguments.length)] : null;
if (srcs.length > 0) {
let random = Math.floor(Math.random() * srcs.length);
settings.src.set(srcs[random]);
srcs.splice(random, 1);
} else {
if (tested) {
showTip("该视频可能无法解析\n请尝试使用z1解析\n如有疑问请反馈");
return false;
} else {
showTip("解析失败,正在尝试其他解析源");
srcs = others;
others = null;
tested = true;
let random = Math.floor(Math.random() * srcs.length);
settings.src.set(srcs[random]);
srcs.splice(random, 1);
}
}
}
// 获取历史解析
settings.src.set(localStorage.getItem("historyParse"));
if (!settings.src.get()) {
await settings.randomSeleceParse();
} else {
// 清除多余的一个解析api
srcs.splice(srcs.indexOf(settings.src.get()), 1);
}
playerBox.style.zIndex = "1";
iframe.onload = () => {
// 判断iframe加载完成的时间
if (new Date().getTime() - iframeStartTime < 500) {
// 如果加载时间小于半秒,并且检测网页加载出错,说明网页有问题。
xmlHttpRequest({
url: iframe.src,
error: () => {
showTip("该解析已失效,已切换推荐解析源");
settings.randomSeleceParse();
}
})
}
}
playerBox.appendChild(iframe);
console.log(iframe);
console.log("%cplayerBox已建立解析连接", settings.fontStyle.maxTip);
let DIY_iframe;
settings.DIY_iframeFunction = () => {
if (settings.parseDB.DIY解析栏) {
if (!DIY_iframe || DIY_iframe.constructor.name !== "HTMLDivElement") {
// 自定义解析地址
DIY_iframe = document.createElement("div");
DIY_iframe.style = "display: flex; background-color: #0000; font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; font-size: 15px;" + " position: fixed; height: 30px; width: 86%; transform: translateX(-50%); left: 50%; max-width: 600px; border-radius: 15px; box-shadow: 0 0 6px 2px #444; bottom: 5px;";
DIY_iframe.innerHTML = "<select style='border: 0; background-color: #ddd; text-align: center; min-width: 80px; width: 80px; height: 100%; border-bottom-left-radius: 15px; border-top-left-radius: 15px;'></select>" + "<input type='text' style='border: 0; background-color: #eee; padding-left: 10px; flex-grow: 1; width: 123px; height: 100%;' placeholder='(当前网址请留空)'>" + "<button style='background-color: #4af; border-color: #4af; text-align: center; color: #fff; min-width: 54px; width: 54px; height: 100%; border-bottom-right-radius: 15px; border-top-right-radius: 15px;'>解析</button>";
let DIY_iframe_text = DIY_iframe.querySelector("input[type=text]");
async function DIY_iframe_src() {
let newiframe = document.querySelector("iframe[id*=player]");
if (newiframe) {
iframe = newiframe;
}
settings.src.set(DIY_iframe_select.options[DIY_iframe_select.selectedIndex].value, DIY_iframe_text.value ? DIY_iframe_text.value : location.href);
// 预先设置历史解析源(用于适配不支持iframe执行脚本的浏览器)
localStorage.setItem('historyParse', settings.src.get());
}
let DIY_iframe_select = DIY_iframe.querySelector("select");
for (let name in settings.NoAD解析) {
DIY_iframe_select.innerHTML += "<option value='" + settings.NoAD解析[name] + "' style='text-align: center'>" + name + "</option>";
}
for (let name in settings.AD解析) {
DIY_iframe_select.innerHTML += "<option value='" + settings.AD解析[name] + "' style='text-align: center; color: #fa0; '>⚠" + name + "</option>";
}
DIY_iframe.querySelector("option[value='" + settings.src.get() + "']").selected = true;
settings.randomSeleceParse = async () => {
// arguments 代表输入的所有参数,看不懂可以百度搜索 “js 参数 arguments”
// return arguments ? arguments[Math.floor(Math.random() * arguments.length)] : null;
if (srcs.length > 0) {
let random = Math.floor(Math.random() * srcs.length);
settings.src.set(srcs[random]);
srcs.splice(random, 1);
DIY_iframe.querySelector("option[value='" + settings.src.get() + "']").selected = true;
} else {
if (tested) {
showTip("该视频可能无法解析\n请尝试使用z1解析\n如有疑问请反馈");
return false;
} else {
showTip("解析失败,正在尝试其他解析源");
srcs = others;
others = null;
tested = true;
let random = Math.floor(Math.random() * srcs.length);
settings.src.set(srcs[random]);
srcs.splice(random, 1);
}
}
settings.address = {"0": 0, "-1": 1};
}
DIY_iframe.querySelector("button").onclick = () => DIY_iframe_src();
DIY_iframe_text.onkeydown = DIY_iframe_select.onkeydown = event => {
if (event.key === "Enter") {
DIY_iframe_src();
}
}
doElement("toolsbar", toolsBar => {
toolsBar.appendChild(DIY_iframe);
});
} else if (DIY_iframe.style.visibility === "hidden") {
DIY_iframe.style.display = "flex";
DIY_iframe.style.visibility = "";
}
} else if (DIY_iframe && DIY_iframe.constructor.name === "HTMLDivElement" && DIY_iframe.style.visibility === "") {
DIY_iframe.style.display = "none";
DIY_iframe.style.visibility = "hidden";
}
}
settings.DIY_iframeFunction();
(waiter => {
waiter /= settings.getElementTimes;
let resetPlayerBoxInterval = setInterval(() => {
let newPlayerBox = document.querySelector(cssString);
if (newPlayerBox !== playerBox && newPlayerBox !== null || newPlayerBox !== null && newPlayerBox.querySelector("iframe[src='" + iframe.src + "']") === null) {
console.log("playerBox重新建立连接");
let src = iframe.src;
iframe.src = "";
iframe = iframe.cloneNode(true);
iframe.src = src;
newPlayerBox.style.zIndex = "1";
newPlayerBox.appendChild(iframe);
clearInterval(resetPlayerBoxInterval);
} else if (document.readyState === "complete" && waiter-- <= 0) {
clearInterval(resetPlayerBoxInterval);
}
}, settings.getElementTimes)
})(0);
if (doFunction) {
doFunction(playerBox, iframe);
}
setInterval(() => {
for (let video of document.getElementsByTagName("video")) {
if (video.src) {
video.removeAttribute("src");
video.load();
video.muted = true;
}
}
}, settings.getElementTimes);
['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange'].forEach(item => {
window.addEventListener(item, () => {
let toolsBar = document.querySelector("toolsbar");
if (document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen) {
toolsBar.style.display = 'none';
} else {
toolsBar.style.display = 'block';
}
}, true);
});
});
}
function hrefToLocation(href) {
let location = {href: href}, c = 0, start = 0, search;
for (let i = 0, port; i < href.length; i++) {
if (href[i] === "/") {
if (++c === 1) {
location.protocol = href.substring(start, i);
} else if (c === 3) {
location.host = href.substring(start + 1, i);
if (port) {
location.port = href.substring(port + 1, i);
} else {
location.hostname = location.host;
location.port = "";
}
}
if (c <= 3) {
start = i;
}
} else if (href[i] === ":" && c === 2) {
location.hostname = href.substring(start + 1, i);
port = i;
} else if (href[i] === "?" && !search) {
location.pathname = href.substring(start, i);
search = i;
} else if (href[i] === "#" && !location.hash) {
location.hash = href.substr(i);
if (location.pathname === undefined) {
location.pathname = href.substring(c, i);
} else if (search) {
location.search = href.substring(search, i);
}
break;
}
}
if (location.pathname === undefined) {
location.pathname = c === 3 ? href.substr(start) : "";
location.search = location.hash = "";
}
if (location.search === undefined) {
if (search) {
location.search = href.substr(search);
} else {
location.search = "";
}
}
if (location.hash === undefined) {
location.hash = "";
}
return location;
}
} else {
function setParseVideo() {
forElements("video", async (videos, thisInterval) => {
for (const video of videos) {
if (video.poster) video.removeAttribute("poster");
if (video.src) {
// 解析成功,清空解析列表缓存
top.postMessage(key.ENCRYPT("宝塔镇河妖\x00函数\x00settings.address = null", settings.k1, settings.k2), "*");
// 设置历史解析
top.postMessage(key.ENCRYPT("宝塔镇河妖\x00函数\x00localStorage.setItem('historyParse', settings.src.get())", settings.k1, settings.k2), "*");
// 移除广告模块
removeElements(['document.getElementById("ADplayer")', 'document.getElementById("ADtip")']);
// 等待数据得到响应,移除弹幕模块
await settings.parseDB;
if (!settings.parseDB.弹幕开关) {
console.log("正在移除弹幕功能");
removeElements(['document.querySelector("div[class$=player-video-wrap]").getElementsByTagName("div")', 'document.querySelector("div[class$=player-danmu]")', 'document.querySelector("div[class$=player-danmaku]")', 'document.querySelector("div[class*=player-comment-box]")', 'document.querySelector("div[class*=player-controller-mask]")', 'document.querySelector("[class*=player-list-icon]")', 'document.querySelector("div[class$=player-menu]")']);
}
// 判断是否移动端
if (!detectMobile()) {
let fullscreen_btn = document.querySelector("[class*=fullscreen],[class$=player-full] button[class$=full-icon]");
if (fullscreen_btn && fullscreen_btn.nodeType === 1) {
// 阻止事件冒泡
fullscreen_btn.parentNode.parentNode.onkeyup = event => event.stopPropagation();
}
video.onkeyup = event => event.stopPropagation();
top.postMessage(key.ENCRYPT("宝塔镇河妖\x00按下Enter获取焦点", settings.k1, settings.k2), "*")
onkeyup = video.onkeyup = event => {
if (event.key === "Enter") {
if (video.paused) {
video.play();
}
if (fullscreen_btn && fullscreen_btn.nodeType === 1) {
fullscreen_btn.click();
return false;
} else if (video.webkitDisplayingFullscreen) {
if (video.webkitExitFullScreen) {