Fuck Erya

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

目前為 2015-11-23 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name			Fuck Erya
// @namespace		[email protected]
// @description		解除尔雅通识课在自动暂停播放的限制并添加自动播放下一集的功能
// @author			依然独特
// @version			0.1.7
// @grant			none
// @run-at			document-start
// @include			*://*.tsk.erya100.com/courseAction!toCourseVideo*
// @include			*://*.tsk*.erya100.com/courseAction!toCourseVideo*
// @match			*://*.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 );
} )();