Greasy Fork

来自缓存

Greasy Fork is available in English.

奥鹏教育视频刷课-静音-自动下一课

奥鹏教育视频

当前为 2021-04-19 提交的版本,查看 最新版本

// ==UserScript==
// @name         奥鹏教育视频刷课-静音-自动下一课
// @namespace    http://greasyfork.icu/zh-CN/users/41249-tantiancai
// @version      0.7
// @description  奥鹏教育视频
// @author       tantiancai
// @match        *://learn.open.com.cn/StudentCenter/CourseWare/*
// @grant        none
// ==/UserScript==

(function () {
	'use strict';

	setInterval(function () {
		var videos = document.getElementsByTagName('video')
		var qrcode = document.getElementsByClassName("qrcodebox")

		// 没有视频,或者视频播放结束后,模拟点击“下一课”
		if (!IsVideo(window.parent.document)
			|| (qrcode.length > 0 && qrcode[0].style.display == "block")) {
			var doc = window.parent.document
			var next_video = doc.getElementsByClassName("progress_btn half_play")
			if (next_video.length > 0) {
				next_video[0].previousSibling.click()
			}
			else {
				next_video = doc.getElementsByClassName("progress_btn not_play")
				if (next_video.length > 0) {
					next_video[0].previousSibling.click()
				}
				else {
					// 结束
				}
			}
		}
		else {
			for (var i = 0; i < videos.length; i++) {
				var current_video = videos[i]

				// 静音
				current_video.volume = 0
				// 4倍速
				current_video.playbackRate = 4.0
				if (current_video.paused) {
					current_video.play()
				}
			}
		}
	}, 2000)

	// 15分钟后,刷新页面
	let timerId = setTimeout(function () {
		location.reload()
	}, 900000)

	function hasClass(element, cls) {
		return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
	}

	function IsVideo(doc) {
		var ret = false;
		var a = doc.getElementsByClassName("curSelectedNode")
		if (a.length > 0) {
			var status = a[0].nextSibling
			ret = hasClass(status, "progress_btn")
		}
		return ret;
	}
})();