Fuck Erya

解除尔雅通识课在自动暂停播放的限制并添加自动播放下一集的功能

当前为 2016-05-21 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name			Fuck Erya
// @namespace		[email protected]
// @description		解除尔雅通识课在自动暂停播放的限制并添加自动播放下一集的功能
// @author			依然独特
// @version			1.0.4
// @grant			none
// @run-at			document-start
// @require			https://greasyfork.org/scripts/18715-hooks/code/Hooks.js?version=126794
// @include			*://tsk.erya100.com/courseAction!toCourseVideo*
// @include			*://*tsk.erya100.com/courseAction!toCourseVideo*
// @include			*://tsk*.erya100.com/courseAction!toCourseVideo*
// @include			*://*tsk*.erya100.com/courseAction!toCourseVideo*
// @match			*://tsk.erya100.com/courseAction!toCourseVideo*
// @match			*://*tsk.erya100.com/courseAction!toCourseVideo*
// @match			*://tsk*.erya100.com/courseAction!toCourseVideo*
// @include			*://*tsk*.erya100.com/courseAction!toCourseVideo*
// @license			BSD 2-Clause License
// @homepageURL		https://gist.github.com/xymopen/79e80a9322d7a1f35f16
// ==/UserScript==

( function() {
	var TAG = "[Fuck Erya]";
	
	function hookJQuery( onPlayerInit, contextWindow ) {
		contextWindow = contextWindow || window;
		
		// CXPlayer extends jQuery for its own APIs
		// so hook jQuery to modify these APIs.
		Hooks.set( contextWindow, "jQuery", function( target, propertyName, undefined, jQuery ) {
			Hooks.set( jQuery.fn, "cxplayer", function( target, propertyName, oldValue, newValue ) {
				return Hooks.apply( newValue, function( target, thisArg, argv ) {
					var config = argv[ 0 ], $player;
					
					config.datas.isAutoPlayNext = true;
					config.datas.isDefaultPlay = true;
					
					$player = target.apply( thisArg, argv );
					
					if ( config.events &&
						config.events.onAnswerRight &&
						!config.events.onAnswerRight.toString()
							.replace( /(function .*?\(.*?\))/g, "" ).trim()		// remove function signifigure
							.replace( /^\{|\}$/g, "" )
							.replace( /\/\/.*(\r|\n|(\r\n))/g,"" )				// remove single line comment
							.replace( /\/\*.*\*\//mg,"" )						// remove multiple line comment
							.match( /^\s*$/ )
					) {
						contextWindow.alert( "onAnswerRight() is not empty. It's unsafe to block the resource URL." );
					}
					
					if ( "function" === typeof onPlayerInit ) {
						onPlayerInit( $player, config );
					}

					return $player;
				} );
			} );
				
			Hooks.set( jQuery.fn, "pauseMovie", function( target, methodName, oldValue, newValue ) {
				return Hooks.apply( newValue, function( target, thisArg, argv ) { } );
			} );
			
			return jQuery;
		} );
	};
	
	hookJQuery( function( $player, config ) {
		// Automatically play the next episode
		$player.bind( "onEnd", function( event, index, config ) {
			// Wait for the player to synchronize your playback progress
			$player.bind( "onSendProgressSuccess", function go() {
			$player.unbind( "onSendProgressSuccess", go );
				$player.goPlay( index + 1 );
			} );
		} );
	} );
} )();