-
Notifications
You must be signed in to change notification settings - Fork 17
/
douyuPlayer.ts
41 lines (38 loc) · 1011 Bytes
/
douyuPlayer.ts
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
import './douyu.less';
// 简单模拟斗鱼播放器原本逻辑
export const douyuPlayer = () => {
const videoSub = document.querySelector('.layout-Player-videoSub');
if (!window.location.search) {
window.location.search = '?rid=1';
}
if (!videoSub) {
return;
}
// 模拟异步延迟
setTimeout(() => {
videoSub.innerHTML = `
<div value="画质 ">画质</div>
<ul>
<li>原画1080P60</li>
<li>蓝光</li>
<li>超清</li>
<li class="selected-123">高清</li>
</ul>`;
const list = document.querySelectorAll('li');
list.forEach((li) => {
li.addEventListener('click', (e) => {
e.stopPropagation();
e.preventDefault();
if (e.target === li) {
// 模拟异步延迟
setTimeout(() => {
list.forEach((other) => {
other.className = '';
});
li.className = 'selected-123';
}, 100);
}
});
});
}, 1000);
};