Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当发生"弹窗答题"导致切换到下一节 bug解决 #14

Open
Goodtimp opened this issue Nov 26, 2019 · 0 comments
Open

当发生"弹窗答题"导致切换到下一节 bug解决 #14

Goodtimp opened this issue Nov 26, 2019 · 0 comments

Comments

@Goodtimp
Copy link

Goodtimp commented Nov 26, 2019

(function () {
	const MAX_DELAY = 30 // 切课时的最大延迟,单位:秒

	const sleep = (time) => new Promise((resolve) => setTimeout(resolve, time))

	SpeedFlag = 0
	VolumeFlag = 0

	const start = async function () {
		console.log('智慧树助手已启动')

		while (true) {
			console.log('正在检查')
			const delay = Math.floor(Math.random() * MAX_DELAY * 1000) + 1000

			// if (!/liuchang/.test($('.definiBox').attr('style'))) {
			// 	console.log('更改画质')
			// 	$('.line1bq').click()
			// }

			if (!/1\.5/.test($('.speedBox').attr('style')) && !SpeedFlag) {
				console.log('提升到1.5倍速')
				SpeedFlag = 1
				$('.speedTab15').click()
			}

			if ($('.volumeBox').find('.passVolume').width() != 0 && !VolumeFlag) {
				console.log('静音')
				VolumeFlag = 1
				$('.volumeIcon').click()
			}
			if ($('.popbtn_cancel')[0]) {
				console.log('发现弹题,将在' + delay / 1000 + ' 秒后点击关闭')
				await sleep(delay / 2)
				const iframe = document.getElementById('tmDialog_iframe').contentWindow
				iframe.document.querySelector('.answerOption label').click()
				await sleep(delay / 2)
				$('.popbtn_cancel').click()

			}

			else if ($('.playButton').length > 0) {
				console.log('本节完成,' + delay / 1000 + ' 秒后将切到下一课')
				await sleep(delay)
				$('.current_play').nextAll('.video')[0].click()
				console.log('已经切换到下一课')
				console.log('点击播放')
				$('.playButton').click()
				SpeedFlag = 0
				VolumeFlag = 0
			}

			await sleep(1000)
		}
	}

	start()
}())

// 由wangzexi代码改进而来,增加了两个flag用于判断。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant