Skip to content

Commit

Permalink
fix(script): 优化智慧树最新异常检测
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed Aug 25, 2023
1 parent 97aacf0 commit b634a46
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/scripts/src/projects/zhs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,15 +640,30 @@ async function watch(
* @param definition 清晰度的类名
*/
function switchLine(definition: 'line1bq' | 'line1gq' = 'line1bq') {
$el(`.definiLines .${definition}`)?.click();
const target = $el(`.definiLines .${definition}`);
if (target) {
stopPropagationClick(target);
}
}

/**
* 切换视频清晰度
* @param playbackRate 播放速度
*/
function switchPlaybackRate(playbackRate: number) {
$el(`.speedList [rate="${playbackRate === 1 ? '1.0' : playbackRate}"]`)?.click();
const target = $el(`.speedList [rate="${playbackRate === 1 ? '1.0' : playbackRate}"]`);
if (target) {
stopPropagationClick(target);
}
}

function stopPropagationClick(el: HTMLElement) {
const func = function (e: MouseEvent) {
e.stopPropagation();
el.removeEventListener('click', func);
};
el.addEventListener('click', func);
el.click();
}

/**
Expand Down

0 comments on commit b634a46

Please sign in to comment.