Fuck Erya

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

Versión del día 1/11/2015. Echa un vistazo a la versión más reciente.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Necesitará instalar una extensión como Tampermonkey para instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

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

"use strict";

( function() {
	var Hooks = {
		"fn": function fn( fn, onInvoke ) {
			"use strict";

			return function() {
				return onInvoke.call( this, fn, arguments );
			};
		},

		"property": function property( object, propertyName, onGet, onSet ) {
			"use strict";

			var descriptor, value, getter;

			if ( Object.prototype.hasOwnProperty.call( object, propertyName ) ) {
				descriptor = Object.getOwnPropertyDescriptor( object, propertyName );

				if ( Object.prototype.hasOwnProperty.call( descriptor, "value" ) ) {
					value = descriptor.value;

					delete descriptor.value;
					delete descriptor.writable;
				} else if ( Object.prototype.hasOwnProperty.call( descriptor, "get" ) &&
					Object.prototype.hasOwnProperty.call( descriptor, "set" ) ) {
					value = getter.call( this );
				}

				descriptor.get = function get() {
					return onGet.call( this, value );
				};

				descriptor.set = function set( newValue ) {
					value = onSet.call( this, value, newValue );
					return value;
				};

				Object.defineProperty( object, propertyName, descriptor );
			} else {
				throw new Error( "ERR_PROPERTY_NOT_DEFINED" );
			}
		},

		"method": function method( object, methodName, onInvoke ) {
			"use strict";

			var method = object[ methodName ];

			if ( typeof method === "function" ) {
				object[ methodName ] = Hooks.fn( method, onInvoke );
			} else {
				throw new Error( "ERR_NOT_A_METHOD" );
			}
		}
	};

	// CXPlayer extends jQuery for its own APIs
	// so hook jQuery to modify these APIs.
	window.jQuery = undefined;

	Hooks.property( window, "jQuery", function( jQuery ) {
		return jQuery;
	}, function( u, jQuery ) {
		// mouseHander() plugin is used to detect MouseEvents.
		// It will pause video when it detects mouse doesn't move for 30s.
		jQuery.mouseHander = undefined;

		Hooks.property( jQuery, "mouseHander", function( p ) {
			return p;
		}, function() {
			return function() {
				/* Empty */
			};
		} );

		return jQuery;
	} );

	window.addEventListener( "load", function() {
		var $eryaPlayer = jQuery( "#eryaPlayer" );

		// Remove the event listener which pauses the video when
		// it detects your switching to another tab or application.
		if ( "onfocus" in window && "onblur" in window ) {
			window.onfocus = window.onblur = null;
		} else if ( "onfocusin" in document && "onfocusout" in document ) {
			document.onfocusin = document.onfocusout = null;
		}

		// This loop seems to insure you cann't login multi times
		// I haven't figure out what it is used for yet
		/*
		window.myInterval = function() {
			// Empty
		};
		*/

		// Automatically play the next episode
		$eryaPlayer.bind( "onEnd", function( event, index, config ) {
			// Wait for the player to synchronize your playback progress
			$eryaPlayer.bind( "onSendProgressSuccess", function go() {
				$eryaPlayer.unbind( "onSendProgressSuccess", go );
				$eryaPlayer.goPlay( index + 1 );
			} );
		} );

	}, false );
} )();