// ==UserScript== // @name 南工大计算机教学管理系统作业提交助手 // @namespace http://tampermonkey.net/ // @version 2.01 // @description 优化南工大计算机教学管理系统是作业提交功能 // @author PairZhu // @include http://10.3.41.240/tms/HomeworkUp/Student/UploadHomework.aspx* // @grant none // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/397854/%E5%8D%97%E5%B7%A5%E5%A4%A7%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%95%99%E5%AD%A6%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F%E4%BD%9C%E4%B8%9A%E6%8F%90%E4%BA%A4%E5%8A%A9%E6%89%8B.user.js // @updateURL https://update.greasyfork.icu/scripts/397854/%E5%8D%97%E5%B7%A5%E5%A4%A7%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%95%99%E5%AD%A6%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F%E4%BD%9C%E4%B8%9A%E6%8F%90%E4%BA%A4%E5%8A%A9%E6%89%8B.meta.js // ==/UserScript== var force_same=true;//是否强制要求文件名与作业名一致 (function() { //不要在意变量的命名方式2333 // // //获取一些需要的父元素 let father=document.getElementById("ctl00_Main_tbHwUp").getElementsByTagName('tbody')[0]; let parent=document.querySelector("#aspnetForm > table:nth-child(6) > tbody > tr > td:nth-child(1)"); let my_e; let temp=document.createElement('p'); temp.innerHTML='收起' temp.style="background-color:Green;width:30px;margin-bottom:0;margin-left:5px;text-align:center;cursor:pointer" temp.onselectstart=()=>false; temp.onclick=(e)=>{ if(e.toElement.innerText==="收起") { e.toElement.innerText="展开"; e.toElement.style.backgroundColor=''; my_e=document.querySelector("#aspnetForm > table:nth-child(6) > tbody > tr > td:nth-child(1)").removeChild(document.getElementById("myelement")); } else { e.toElement.innerText="收起"; e.toElement.style.backgroundColor="Green" my_e=document.querySelector("#aspnetForm > table:nth-child(6) > tbody > tr > td:nth-child(1)").appendChild(my_e); } } parent.appendChild(temp); temp=document.createElement('div'); temp.id='myelement'; temp.style="background-color:Green;width:150px;margin-left:5px;margin-top:0;padding-top: 2px;padding-bottom: 8px;cursor:default" temp.onselectstart=()=>false; parent.appendChild(temp); parent=document.getElementById('myelement'); //检测提交的文件是否错误 if(force_same){ let the_form=document.getElementById('aspnetForm'); the_form.onsubmit= ()=>{ for(var i=0;i=father.children.length) { for(let j of e.ele) father.appendChild(j); return; } } for(let j of e.ele) { father.insertBefore(j,father.children[i]); ++i; } } function e_remove(e,prop_e){ if(e.exist===false) return; prop_e.style.backgroundColor="#DDDDDD"; e.exist=false; for(let j of e.ele) father.removeChild(j); } function ele_change(e,prop_e){ if(e.exist==false) { e_insert(e,prop_e); } else { e_remove(e,prop_e); } } function allsubmit(){ let success_cnt=0,fail_cnt=0,cnt=0; allshow({}); let toappend=[]; for(let j of document.getElementById('hiddenFile').files) { for(var i=0;i{(e.toElement.value==='show')?allshow(e.toElement):allhide(e.toElement)}; parent.appendChild(tempe); tempe=document.createElement('br'); parent.appendChild(tempe); tempe=document.createElement('br'); parent.appendChild(tempe); let cnt=0; for(var i=0;i{ele_change(elearray[e.toElement.value],e.toElement);} if(cnt===0) { tempe.style="margin-left:5px" } parent.appendChild(tempe); ++cnt; if(cnt===3) { cnt=0; tempe=document.createElement('br'); parent.appendChild(tempe); } i-=5; } } } temp=document.createElement('p'); temp.innerHTML='

一键提交所有作业

' +' 需文件名与作业题目要求的相同。仅文件名正确的文件会被提交,其余文件不受影响。' +'

鼠标左键选择多个文件,右键选择文件夹<\p>'; temp.style="height:80px;width:140px;margin-left:5px;text-align: center;font-size: 8pt"; parent.appendChild(temp); tempe=document.createElement('input'); tempe.id="hiddenFile"; tempe.multiple=1; tempe.type='file'; tempe.style.display="none"; tempe.onchange=(e)=>{document.getElementById('fakefile').innerHTML=(e.srcElement.files.length===0)?"点此选择文件":`已选择${e.srcElement.files.length}个文件`;} parent.appendChild(tempe); tempe=document.createElement('button'); tempe.innerHTML='点此选择文件'; tempe.type='button'; tempe.style="height:40px;margin-left:5px;width:140px" tempe.id="fakefile"; tempe.onmousedown=(event)=>{ if(event.button==1) return; let hiddenFile=document.getElementById('hiddenFile'); if (event.button == 0) hiddenFile.webkitdirectory=false; if(event.button == 2) hiddenFile.webkitdirectory=true; hiddenFile.click() } tempe.onclick=()=>{}; parent.appendChild(tempe); tempe=document.createElement('button'); tempe.innerHTML='一键提交'; tempe.type='button'; tempe.style="height:30px;margin-left:42.5px;width:60px;margin-top:10px;font-size:11px;cursor:pointer" tempe.id="fakefile"; tempe.onclick=allsubmit; parent.appendChild(tempe); })();