// ==UserScript== // @name 学堂在线小助手注释版 // @version 0.0.9.3 // @description 解放双手,自动播放 // @author 1xin // @require http://code.jquery.com/jquery-latest.js // @noframes // @match *://*.xuetangx.com/courses/*/courseware/* // @match *://*.xuetangx.com/newcloud/dashboard* // @grant GM_addStyle // @grant GM.getValue // @grant GM_openInTab // @grant GM_notification // @namespace https://greasyfork.org/users/183871 // @downloadURL https://update.greasyfork.icu/scripts/98624/%E5%AD%A6%E5%A0%82%E5%9C%A8%E7%BA%BF%E5%B0%8F%E5%8A%A9%E6%89%8B%E6%B3%A8%E9%87%8A%E7%89%88.user.js // @updateURL https://update.greasyfork.icu/scripts/98624/%E5%AD%A6%E5%A0%82%E5%9C%A8%E7%BA%BF%E5%B0%8F%E5%8A%A9%E6%89%8B%E6%B3%A8%E9%87%8A%E7%89%88.meta.js // ==/UserScript== (function() { 'use strict'; GM_addStyle('#next_video_btn{color:#fa7d3c;}'); //获取下一个视频地址 //getUrl()获取下一个视频地址 var getNextVideoUrl = { getUrl:function(){ var next_video,next_video_url,next_unit,next_unit_ul; var active_video=$("li.active "); if (active_video.next().length > 0 ) { next_video=active_video.next().find("a"); next_video_url=next_video.attr('href'); }else{ next_unit=$("div.chapter.is-open").next(); if(next_unit.length>0){ next_unit_ul=next_unit.find('ul').children(":first").find("a"); next_video_url=next_unit_ul.attr('href'); }else{ return false; } } return next_video_url; } }; //f**k U DuCha! var nopeople={ getuserpeople:function(){ var username=$("li.nav-user--info-name").text(); var userid=$("li.nav-user--info-number").text(); //alert(userid); //if(username==1xin.hate){alert(f**k u);} -_-!bbbb } }; //增加下一个按钮,防止程序出错 //addNextButton()增加下一个视频按钮 //toNextButton()转到下一个视频地址 //addTips()提示信息 var addNextButton={ addButton:function(next_video_url){ var next_btn_html = ''; next_btn_html +='
  • '; next_btn_html += ''; next_btn_html += '跳转到下一个视频'; next_btn_html += ''; next_btn_html +='
  • '; //增加下一个视频按钮 var ul_tag = $("ul.wrapper-downloads"); if (ul_tag) { ul_tag.append(next_btn_html); } }, toNextButton:function(){ if(getNextVideoUrl.getUrl()!=false){ window.location.href=getNextVideoUrl.getUrl(); }else{ return 0; } }, addTips:function(){ var li_tag = $("ul.wrapper-downloads"); var tips_button = ''; tips_button += '
  • '; tips_button += ''; tips_button += ''; tips_button += '再次强调:答题时请关掉脚本!!'; tips_button += ''; tips_button += ''; tips_button += '
  • '; if (li_tag) { li_tag.append(tips_button); } }, addVersion:function(){ var li_tag = $("ul.wrapper-downloads"); var tips_Version = ''; tips_Version += '
  • '; tips_Version += ''; tips_Version += ''; tips_Version += '版本0.0.9.3'; tips_Version += ''; tips_Version += ''; tips_Version += '
  • '; if (li_tag) { li_tag.append(tips_Version); } } }; //视频播放 //myVideo video DOM 对象 //playVideo() 自动播放 //stopVideo() 监测是否结束,到下一个视频 //isVideoPage() 是否是视频页 //VideoQuality() 自动切换到低清,节省流量 //changeVideoSpeed() 自动二倍速播放,节省时间 //changeVideoVolume() 自动静音,节省……耳朵? var autoPlayVideo={ myVideo:null, playVideo:function(){ setTimeout(function(){ var m=autoPlayVideo.isVideoPage(); //alert(m); if(m){ try { autoPlayVideo.myVideo = document.getElementsByTagName('video')[0]; autoPlayVideo.myVideo.play(); autoPlayVideo.changeVideoQuality(); autoPlayVideo.changeVideoSpeed(); autoPlayVideo.changeVideoVolume(); autoPlayVideo.myVideo.play(); autoPlayVideo.stopVideo(); } catch(e) { //location.reload(); autoPlayVideo.myVideo.play(); } }else{ addNextButton.toNextButton(); } },2000); }, stopVideo:function(){ this.myVideo.addEventListener('ended',function(){ //alert('stop'); addNextButton.toNextButton(); }); }, isVideoPage:function(){ if(document.getElementsByTagName('video').length > 0){ return true; }else{ return false; } }, changeVideoQuality:function(){ var qualityDiv=$("div.xt_video_player_quality.xt_video_player_common.fr>ul"); var qualityButton=qualityDiv.children(":last"); qualityButton.trigger("click"); }, changeVideoSpeed:function(){ var speedDiv=$("div.xt_video_player_speed.xt_video_player_common.fr>ul"); var speedButton=speedDiv.children(":first"); speedButton.trigger("click"); }, changeVideoVolume:function(){ var VolumeDiv=$("div.xt_video_player_volume"); var VolumeButton=VolumeDiv.children(":first"); VolumeButton.trigger("click"); } }; //一键 //addScore() 获取所有成绩 //addScoreTip() 提示 //addScoreTable() 成绩表 var addOneShotButton={ addScore:function(){ var li_tag = $("div.nav-menu > ul"); var tips_button = ''; tips_button += '