Last active
March 22, 2018 17:47
-
-
Save xymopen/79e80a9322d7a1f35f16 to your computer and use it in GitHub Desktop.
解除尔雅通识课在自动暂停播放的限制并添加自动播放下一集的功能
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="zh-cmn-Hans"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<meta charset="UTF-8" /> | |
</head> | |
<body> | |
<p>该脚本解除尔雅通识课在后台暂停播放和一段时间无操作后暂停播放的限制并添加自动播放下一集的功能。</p> | |
<br /> | |
<p>如果你觉得验证码或小测验很讨厌,请尝试向兼容 AdBlock Plus 语法的广告过滤扩展添加这条自定义规则:</p> | |
<p><code>*://*tsk*.erya100.com/player/playerAction!getResourceUrl*</code></p> | |
<p>应用此规则后播放器可能提示“加载资源地址出错!”,这是正常现象并表明规则已正常生效。</p> | |
<p>如果此规则不起作用,请与你学校的计算机协会或类似社团求助。</p> | |
<br /> | |
<p>对于开发者:</p> | |
<p>尔雅通识课使用了超星开发的播放器,这个播放器在 <code>jQuery.fn</code> 上扩展了 <code>cxplayer()</code> 方法。此方法接受一个 <code>Object</code> 作为配置文件启动播放器。此 <code>Object</code> 的 <code>.datas.currVideoInfo.resourceUrl </code>属性指示播放器从何处取得验证码或小测验的配置信息。拦截此请求即可阻止验证码或小测验。</p> | |
<p>部分学校的尔雅通识课在配置文件中包含 <code>.events.onAnswerRight</code> 。请特别注意该参数是否有服务器通信行为。</p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Fuck Erya | |
// @name:zh-CN Fuck Erya | |
// @namespace [email protected] | |
// @description 解除尔雅通识课在自动暂停播放的限制并添加自动播放下一集的功能 | |
// @description:zh-CN 解除尔雅通识课在自动暂停播放的限制并添加自动播放下一集的功能 | |
// @author 依然独特 | |
// @version 1.0.7 | |
// @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 | |
// @homepageURL https://gist.github.com/xymopen/79e80a9322d7a1f35f16 | |
// @downloadURL https://gist.github.com/xymopen/79e80a9322d7a1f35f16/raw/Fuck%2520Erya.user.js | |
// @updateURL https://gist.github.com/xymopen/79e80a9322d7a1f35f16/raw/Fuck%2520Erya.user.js | |
// ==/UserScript== | |
( function() { | |
"use strict"; | |
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, ignored, 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 = Hooks.Reply.apply( arguments ); | |
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." ); | |
} | |
$player.bind( "onPause", function() { | |
$player.playMovie(); | |
} ); | |
onPlayerInit( $player, config ); | |
return $player; | |
} ); | |
} ); | |
Hooks.set( jQuery.fn, "pauseMovie", function( target, methodName, oldValue, newValue ) { | |
return Hooks.apply( newValue, function ( target, thisArg, argv ) { | |
/* empty */ | |
} ); | |
} ); | |
return Hooks.Reply.set( arguments ); | |
} ); | |
}; | |
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 ); | |
} ); | |
} ); | |
} ); | |
} )(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment