中移网大工具栏

中国移动网上大学网站工具栏

  1. // ==UserScript==
  2. // @name 中移网大工具栏
  3. // @version 1
  4. // @grant none
  5. // @include *://wangda.chinamobile.com/*
  6. // @description:zh-cn 中国移动网上大学网站工具栏
  7. // @namespace https://greasyfork.org/users/76111
  8. // @description 中国移动网上大学网站工具栏
  9. // ==/UserScript==
  10. var myStart=function(){
  11. //解除右键限制
  12. function avoiderr() {
  13. return true;
  14. }
  15. let old_onerror = onerror;
  16. onerror = avoiderr;
  17.  
  18. function enableDefault(evt) {
  19. evt.stopPropagation();
  20. }
  21.  
  22. function addEvt(obj, type) {
  23. obj.addEventListener(type, enableDefault, true);
  24. }
  25.  
  26. function apply(events, node) {
  27. let length = events.length;
  28. for (let i = 0; i < length; i++) {
  29. addEvt(node, events[i]);
  30. }
  31. }
  32.  
  33. function noMouseRestrict(events) {
  34. apply(events, window);
  35. apply(events, document);
  36. }
  37.  
  38. noMouseRestrict(['contextmenu', 'selectstart', 'select', 'copy', 'beforecopy', 'cut', 'beforecut', 'paste', 'beforepaste', 'dragstart', 'dragend', 'drag', 'mousedown', 'mouseup', 'mousemove']);
  39. //解除右键限制结束
  40.  
  41. var VideoPlay=function(){
  42. var myVideo=document.getElementsByTagName("video");
  43. if(myVideo.length > 0){
  44. myVideo[0].play();
  45. }
  46. }
  47. var VideoPlayX2=function(){
  48. var myVideo=document.getElementsByTagName("video");
  49. if(myVideo.length > 0){
  50. myVideo[0].play();
  51. var spd=myVideo[0].playbackRate
  52. if(spd==3){spd=1}else{spd+=0.5};
  53. myVideo[0].playbackRate=spd;
  54. alert("播放速度:x"+spd);
  55. }else{
  56. alert("未找到播放器");
  57. }
  58. }
  59. var sleep=function(time){
  60. return new Promise((resolve) => setTimeout(resolve, time));
  61. }
  62. var CopyQuestion= async function(){
  63. alert("点击“确定”开始复制试题,期间请暂时不要操作本页面");
  64. var tempStr=document.getElementsByClassName("border right")[0].innerText;
  65. var QuestionNumber=parseInt(tempStr.substring(3,tempStr.indexOf("题")));
  66. var myStr="";
  67. for(var i=0;i<QuestionNumber+10;i++){
  68. await sleep(500);
  69. //alert(i);
  70. if (document.getElementById("D76next-0")){
  71. myStr+=document.getElementsByClassName("question-type-item")[0].innerText+"\n";
  72. document.getElementById("D76next-0").click();
  73. //console.log(i+":a");
  74. //alert("a" + myStr);
  75. }else if (document.getElementById("D76next-1")){
  76. myStr+=document.getElementsByClassName("question-type-item")[0].innerText+"\n";
  77. document.getElementById("D76next-1").click();
  78. //console.log(i+":b");
  79. } else if (document.getElementById("D76next-2")){
  80. myStr+=document.getElementsByClassName("question-type-item")[0].innerText+"\n";
  81. document.getElementById("D76next-2").click();
  82. //console.log(i+":c");
  83. //alert("a" + myStr);
  84. }else if (document.getElementById("D76next-3")){
  85. myStr+=document.getElementsByClassName("question-type-item")[0].innerText+"\n";
  86. document.getElementById("D76next-3").click();
  87. //console.log(i+":d");
  88. //alert("a" + myStr);
  89. } else if (document.getElementById("D76next-4")){
  90. myStr+=document.getElementsByClassName("question-type-item")[0].innerText+"\n";
  91. document.getElementById("D76next-4").click();
  92. //console.log(i+":e");
  93. //alert("a" + myStr);
  94. }else{
  95. myStr+=document.getElementsByClassName("question-type-item")[0].innerText+"\n";
  96. //alert(myStr);
  97. //console.log(i+":f");
  98. //document.getElementById("WangdaToolsBarDiv").innerText=myStr;
  99.  
  100. break;
  101. }
  102. //alert("b" + myStr);
  103. }
  104. //alert(myStr);
  105. var newTextArea=document.createElement("DIV");
  106. newTextArea.style="white-space: pre-line;background-color:#FEFEFE;height:200px;width:500px;float:left;position:fixed;top:35px;left:5px;border-radius:5px;border: 1px solid black;opacity:0.9;overflow:auto;box-shadow:0 4px 8px 0 rgba(0, 0, 0, 0.2);z-index:9999;";
  107. newTextArea.id="WangdaToolsBar-TextArea";
  108. newTextArea.innerText=myStr;
  109. document.body.appendChild(newTextArea);
  110. var btn=document.createElement("DIV");
  111. btn.style="background-color:#FFD700;height:26px;width:300px;float:left;position:fixed;top:235px;left:5px;border-radius:3px;padding: 1px;border: 1px solid green;text-align: center;";
  112. btn.innerText="点击此按钮,将试题复制到剪切板";
  113. btn.onclick=function(){
  114. navigator.clipboard.writeText(myStr).then(function() {
  115. /* clipboard successfully set */
  116. alert("试题已复制到剪切板");
  117. }, function() {
  118. alert("剪贴板访问错误");
  119. /* clipboard write failed */
  120. });
  121. document.body.removeChild(document.getElementById("WangdaToolsBar-TextArea"));
  122. document.body.removeChild(this);
  123. }
  124. document.body.appendChild(btn);
  125.  
  126. }
  127.  
  128. var myDiv=document.createElement("DIV");//容器
  129. myDiv.style="background-color:#FFD700;height:30px;width:330px;float:left;position:fixed;top:5px;left:4px;border-radius:5px;opacity:0.8;box-shadow:0 4px 8px 0 rgba(0, 0, 0, 0.2);z-index:9999;";
  130. myDiv.id="WangdaToolsBarDiv";
  131.  
  132. var btn0=document.createElement("DIV");
  133. btn0.style="background-color:#FFFFFF;height:26px;width:80px;float:left;position:relative;top:1px;left:5px;border-radius:3px;padding: 1px;border: 1px solid green;text-align: center;";
  134. //btn1.id="WangdaToolsBtn1"
  135. btn0.innerText="考试防切屏";
  136. btn0.onclick=function(){
  137. document.body.onblur=null;
  138. alert("已解除网大考试切屏限制");};
  139. myDiv.appendChild(btn0);
  140.  
  141. var btn1=document.createElement("DIV");
  142. btn1.style="background-color:#FFFFFF;height:26px;width:80px;float:left;position:relative;top:1px;left:5px;border-radius:3px;padding: 1px;border: 1px solid green;text-align: center;";
  143. //btn1.id="WangdaToolsBtn1"
  144. btn1.innerText="复制试题";
  145. btn1.onclick=function(){
  146. CopyQuestion();
  147. //alert("试题已复制到剪切板");
  148. };
  149. myDiv.appendChild(btn1);
  150.  
  151. var btn2=document.createElement("DIV");
  152. btn2.style="background-color:#FFFFFF;height:26px;width:80px;float:left;position:relative;top:1px;left:5px;border-radius:3px;padding: 1px;border: 1px solid green;text-align: center;";
  153. //btn1.id="WangdaToolsBtn1"
  154. btn2.innerText="刷课防暂停";
  155. btn2.onclick=function(){window.setInterval(VideoPlay(),5000);alert("已解除视频自动暂停")};
  156. myDiv.appendChild(btn2);
  157.  
  158. var btn3=document.createElement("DIV");
  159. btn3.style="background-color:#FFFFFF;height:26px;width:80px;float:left;position:relative;top:1px;left:5px;border-radius:3px;padding: 1px;border: 1px solid green;text-align: center;";
  160. //btn1.id="WangdaToolsBtn1"
  161. btn3.innerText="视频加速";
  162. btn3.onclick=function(){VideoPlayX2();};
  163. myDiv.appendChild(btn3);
  164. document.body.appendChild(myDiv);
  165. }
  166. myStart();
  167.  
  168.  
  169.  
  170.  
  171.  
  172.