// ==UserScript== // @name chinahrt继续教育加速DrS // @version 0.6 // @description 进入视频自动开始并静音。解除失去焦点自动暂停,后台听不也挺好吗。一般情形可用。 // @author DrS // @license AGPL License // @match *://videoadmin.chinahrt.com*/videoPlay/play* // @match *://web.chinahrt.com*/index.html#/v_video* // @grant none // @namespace https://greasyfork.org/users/849179 // @downloadURL none // ==/UserScript== $(document).ready(function (){ // (function () { // 'use strict'; //----------------函数定义----------------// function goPlayAction(addstr){ addstr = addstr || '默认调用'; player.videoPlay(); player.videoMute(); player.changePlaybackRate(4); //修改播放速度 console.log('播放静音倍速3连【'+addstr+'】'); setTimeout(function(){player.videoMute();}, 10000); } function pauseAction(addstr,waitTime){ addstr = 'pauseAction'+addstr || 'pauseAction默认调用'; waitTime = waitTime || 1000; if(videoIsEnd==true ){ document.title = '【已播完】'+document.title; } if(document.URL.search('end')>34 ||videoIsEnd==true ){ //window.close(); console.log('检测到视频结束,本次视频恢复取消等待系统进入下一视频'); document.getElementsByClassName('ths')[0].innerText='本视频已经播放过1次' document.title = '【已播完】'+document.title; waitTime=5000; videoIsEnd=false; }else{setTimeout(function(){goPlayAction(addstr)}, waitTime);} } //----------------函数定义end----------------// window.onfocus = function () { console.log('onfocus焦点监控事件已被替换') }; window.onblur = function () { console.log('onblur原始事件已被替换') }; var videoIsEnd =false; var tmp = setInterval(function () { if (player) { player.addListener('loadedmetadata', function () { setTimeout(function(){goPlayAction('初始加载')}, 1000); clearInterval(tmp); }); //player.addListener('pause',pauseAction('暂停监听')); player.addListener('ended',function(){videoIsEnd=true}); } }, 500); setInterval(function () { var playerMetaDate=player.getMetaDate(); if(playerMetaDate['paused']){ pauseAction('循环检测发现暂停'); }; } ,20000); });