// ==UserScript== // @name U校园挂机喵 // @namespace https://bbs.tampermonkey.net.cn/ // @version 1.1.0 // @description 脱离u校园的苦海 // @author Infinite-Unexpired-Love/初雪小白 // @match https://u.unipus.cn/user/student/mycourse/* // @match https://ucontent.unipus.cn/_pc_default/*/*/courseware/*/*/*/* // @match https://ucontent.unipus.cn/_pc_default/*/*/courseware/*/*/*/*/* // @require https://cdn.staticfile.org/jquery/3.1.1/jquery.min.js // @resource customCSS https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css // @require https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js // @grant GM_addStyle // @grant GM_getResourceText // @grant unsafeWindow // ==/UserScript== let interval=300000; let autosolve=false; let review=true; let unit=1; let loop=true; let autosubmit=false; let waiting=5000; let configContent=` `; let newCSS = GM_getResourceText ("customCSS"); let myCSS=document.createElement("style"); myCSS.innerHTML= ` #config {position: fixed;left: 0;top: 100px;z-index: 999;} .portion { height: auto; margin: 10px 0; } .h3 { display: inline-block; font-size: 16px; margin: 0!important; } .portion ul,ol { list-style: none; line-height: 20px!important; margin-bottom: 0!important; padding-left: 0; } .portion ul,ol li { margin: 10px 10px; height: 20px; } .portion ul li { float: left; } .clearfix:before,.clearfix:after { content:""; display:table; } .clearfix:after { clear:both; overflow:hidden; } .clearfix { zoom:1; /* for ie6 & ie7 */ } .clear { clear:both; display:block; font-size:0; height:0; line-height:0; overflow:hidden; } ` //---------------------------- $(function(){ GM_addStyle (newCSS); $("head").append(myCSS); AddHtml(configContent); $("window").ready(function(){ if(localStorage.getItem('configContent')){ configs=JSON.parse(localStorage.getItem('configContent')); autosolve=configs[0]; review=configs[1]; autosubmit=configs[2]; loop=configs[3]; interval=configs[4]; waiting=configs[5]; unit=configs[6]; } $('.save').click(function(){ let map=[]; $('.modal').find('.modal-body').find('ul').find('input').each(function(i,e){ switch(i){ case 3:if($(e).prop('checked')) map[1]=true; default:map.push($(e).prop('checked')); } }) $('.modal').find('.modal-body').find('ol').find('input').each(function(i,e){ switch(i){ case 0:if($(e).val()==null){ map.push(5*60*1000); }else{ let val=Math.floor($(e).val()); if(val<=1) map.push(5*60*1000); else map.push(val*60*1000); } break; case 1:if($(e).val()==null){ map.push(15*1000); }else{ let val=Math.floor($(e).val()); if(val<=3) map.push(5*1000); else map.push(val*1000); } break; case 2:if($(e).val()==null){ map.push(0); }else{ let val=Math.floor($(e).val()); if(val<=0) map.push(0); else map.push(val-1); } break; } }) localStorage.setItem('configContent',JSON.stringify(map)); console.log(localStorage.getItem('configContent')); location.reload(); }) let href=location.href; if(href.match('courseCatalog')!==null){ setTimeout(function(){ let uls=[]; $('ul').each(function(i,e){ if(e.className===''){ uls.push(e); } }) if(review){ $(uls[unit]).children('.group').eq(1).click(); } else{ } },15000) } else{ let right_lis=[]; let active_index=0; let top_lis=null; let active_one=null; setTimeout(function(){ console.log('out begin!'); top_lis=$('.headerbar').children('.TabsBox').children(); $('#layoutTheme').children('#sidemenuContainer').find('.menuRightTabContent').find('li').each(function(i,e){ if(!e.classList.contains('disabled')&&e.classList.contains('group')){ right_lis.push(e); } }) active_index=getIndexOf(right_lis,'active'); active_one=getIndexOf(top_lis,'active'); console.log(active_one); console.log(right_lis); console.log(top_lis); },waiting); let timer = setInterval(function(){ console.log('interval begin!'); if($('.headerbar').children('.TabsBox').children().length===1){ right_lis[active_index+1].click(); } else{ if(active_one===top_lis.length-1){ if(active_index===right_lis.length-1){ if(loop){ console.log(11); $('#header').find('.layoutHeaderStyle--breadCrumbBox-rFgzd').children('ul').children().eq(0).children('a')[0].click(); } else clearInterval(timer); } else right_lis[active_index+1].click(); } else{ top_lis[active_one+1].click(); } } setTimeout(function(){ top_lis=$('.headerbar').children('.TabsBox').children(); active_index=getIndexOf(right_lis,'active'); active_one=getIndexOf(top_lis,'active'); },waiting); },interval); } }) }) function AddHtml(html) { document.body.insertAdjacentHTML('afterBegin', html); } function getIndexOf(list,classname){ let index=-1; $.each(list,function(i,e){ if(e.classList.contains(classname)) index=i; }) return index; } //-------------------------------------