// ==UserScript== // @name 超星网课助手(测试版) // @namespace wyn665817@163.com // @description 自动挂机看尔雅MOOC,支持后台、切换窗口不暂停,视频自动切换,屏蔽视频内的题目,倍速播放、进度条拖动、快进快退 // @author wyn665817 // @version 0.0.1 // @grant none // @run-at document-end // @match *://*.chaoxing.com/* // @license MIT // @downloadURL none // ==/UserScript== var setting = { // 5E3 == 5000,表示毫秒数 time: 5E3 // 默认响应速度为5秒,不建议小于3秒 // 1代表开启,0代表关闭 ,video: 1 // 视频支持后台、切换窗口不暂停,支持多视频,默认开启 // 仅开启video时,修改此处才会生效 ,drag: 0 // 倍速播放、进度条拖动、快进快退,使用此功能会出现不良记录(慎用),默认关闭 }; (function() { var url = location.pathname; if (url.indexOf('ananas/modules/video/index.html') > 0) { hookTest(); } })(); function hookTest() { var $video = top.$('.ans-job-icon', parent.document).next('iframe[src*="/video/index.html"]'), tip = top.$('object', document).attr('id'); if ($video.not('.ans-job-finished iframe').eq(0).contents().find('object').attr('id') == tip) { setting.tip = 1; } hookJQuery(); } function hookJQuery() { var Hooks = varHooks(); Hooks.set(window, 'jQuery', function(target, propertyName, ignored, jQuery) { Hooks.set(jQuery.fn, 'cxplayer', function(target, propertyName, oldValue, newValue) { return Hooks.apply(newValue, function(target, thisArg, args) { var config = args[0]; config.datas.isAutoChgLine = true; config.datas.isAutoPlayNext = true; if (setting.tip) { config.datas.isDefaultPlay = true; } config.enableSwitchWindow = 1; config.datas.currVideoInfo.resourceUrl = '/richvideo/initdatawithviewer?'; if (setting.drag) { config.datas.currVideoInfo.getVideoUrl = config.datas.currVideoInfo.getVideoUrl.replace(/&drag=false&/, '&drag=true&'); } return Hooks.Reply.apply(arguments); }); }); return Hooks.Reply.set(arguments); }); } function varHooks() { /** * Hooks.js v1.1.3 | xymopen * xuyiming.open@outlook.com * https://github.com/xymopen/JS_Utilities/blob/master/Hooks.js */ var Hooks = { apply: function apply(target, onApply) { if ('function' === typeof target && 'function' === typeof onApply) { return function() { return onApply.call(this, target, this, arguments); }; } else { throw new TypeError(); } }, property: function property(target, propertyName, onGet, onSet) { var descriptor, oldValue; if (Object.prototype.hasOwnProperty.call(target, propertyName)) { descriptor = Object.getOwnPropertyDescriptor(target, propertyName); if (Object.prototype.hasOwnProperty.call(descriptor, 'value')) { oldValue = descriptor.value; delete descriptor.value; delete descriptor.writable; } else if (Object.prototype.hasOwnProperty.call(descriptor, 'get')) { oldValue = descriptor.get.call(target); } else { oldValue = undefined; } } else { descriptor = { 'configurable': true, 'enumerable': true }; oldValue = undefined; } descriptor.get = function get() { return onGet.call(this, target, propertyName, oldValue); }; descriptor.set = function set(newValue) { oldValue = onSet.call(this, target, propertyName, oldValue, newValue); return oldValue; }; Object.defineProperty(target, propertyName, descriptor); }, set: function set(target, propertyName, onSet) { return Hooks.property(target, propertyName, function(target, propertyName, oldValue) { return Hooks.Reply.set(arguments); }, onSet); } }; Hooks.Reply = { apply: function apply(param) { return param[0].apply(param[1], param[2]); }, set: function(param) { return param[param.length - 1]; } }; return Hooks; }