qingguo helper

hi

  1. // ==UserScript==
  2. // @name qingguo helper
  3. // @description hi
  4. // @namespace blog.sylingd.com
  5. // @include http://newjw.neusoft.edu.cn/jwweb/*
  6. // @include https://vpn.neusoft.edu.cn/proxy/*
  7. // @version 1
  8. // ==/UserScript==
  9. (function () {
  10. var url = window.location.href;
  11. //VPN兼容
  12. if (url.includes('vpn.neusoft.edu.cn')) {
  13. if (!url.includes('newjw.neusoft.edu.cn')) {
  14. return;
  15. }
  16. url = 'http://' + url.substr(url.indexOf('newjw.neusoft.edu.cn'));
  17. }
  18. //var username = '';
  19. //var password = '';
  20. //辅助选课
  21. var xkList = [
  22. '算法',
  23. 'javaScript'
  24. ];
  25. //登录页面辅助
  26. function loginHelper() {
  27. //自动填充
  28. var userInput = document.getElementById('UID').parentElement.querySelector('input');
  29. var passwordInput = document.getElementById('PWD').parentElement.querySelector('input');
  30. var vcInput = document.getElementById('imgCode').parentElement.querySelector('input') || document.getElementById('imgCode').parentElement.parentElement.nextElementSibling.querySelector('input');
  31. unsafeWindow.showvc(vcInput);
  32. vcInput.addEventListener('keyup', function () {
  33. if (this.value.length == 4) {
  34. unsafeWindow.CkValue();
  35. }
  36. });
  37. setTimeout(function() {
  38. userInput.value = username;
  39. unsafeWindow.shtitblur(userInput);
  40. passwordInput.value = password;
  41. console.log(passwordInput);
  42. unsafeWindow.shtitcus(passwordInput.nextElementSibling);
  43. unsafeWindow.shtitblur(passwordInput);
  44. unsafeWindow.chkpwd(passwordInput);
  45. vcInput.focus();
  46. }, 300);
  47. }
  48. //主页面辅助
  49. function mainHelper() {
  50. //新增快捷入口
  51. var box = document.createElement('div');
  52. box.setAttribute('style', 'display: block; position: fixed; right: 0; bottom: 0; height: 40px; min-width: 100px;');
  53. document.getElementsByTagName('body') [0].appendChild(box);
  54. //封装
  55. function createButton(title, click) {
  56. var newEl = document.createElement('button');
  57. newEl.setAttribute('style', 'display: inline-block; height: 40px; min-width: 100px;');
  58. newEl.innerHTML = title;
  59. newEl.onclick = click;
  60. box.appendChild(newEl);
  61. }
  62. createButton('进入选课', function () {
  63. document.getElementById('frmMain').src = '../wsxk/stu_xszx.aspx';
  64. });
  65. createButton('查看课表', function () {
  66. document.getElementById('frmMain').src = '../znpk/Pri_StuSel.aspx';
  67. });
  68. createButton('任选列表', function () {
  69. document.getElementById('frmMain').src = '../znpk/KBFB_RXKBSel.aspx';
  70. });
  71. createButton('所有正选', function () {
  72. window.open('../wsxk/stu_zxjg_rxyl.aspx');
  73. });
  74. createButton('查看成绩', function () {
  75. document.getElementById('frmMain').src = '../xscj/Stu_MyScore.aspx';
  76. });
  77. }
  78. //查看课表的页面中,默认选择格式1
  79. function selHelper() {
  80. document.getElementById('rad_gs2').removeAttribute('checked');
  81. document.getElementById('rad_gs1').setAttribute('checked', 'checked');
  82. document.getElementById('rad_gs1').value = '0';
  83. unsafeWindow.ChkVal();
  84. }
  85. //选课辅助
  86. function xkHelper() {
  87. var xkListReg = new RegExp('(' + xkList.join('|') + ')');
  88. if (document.querySelectorAll('#pageRpt').length > 0) {
  89. document.querySelectorAll('tr').forEach(function (el) {
  90. if (el.children.length < 7) {
  91. return;
  92. }
  93. //移动匹配课程的元素到顶端
  94. if (xkListReg.test(el.children[1].innerHTML)) {
  95. var parentTbody = el.parentElement;
  96. //课程名称匹配
  97. el.style.backgroundColor = 'rgb(249, 255, 0)'; //高亮
  98. parentTbody.insertBefore(el, parentTbody.childNodes[1]);
  99. }
  100. //将选定事件绑定
  101. if (el.children[0].querySelector('input[type="checkbox"]') !== null) {
  102. el.children[0].querySelector('input[type="checkbox"]').addEventListener('click', function (e) {
  103. if (this.checked) {
  104. var evObj = document.createEvent('MouseEvents');
  105. evObj.initEvent('click', true, false);
  106. el.lastChild.querySelector('a').dispatchEvent(evObj);
  107. }
  108. e.stopPropagation();
  109. });
  110. el.children[0].addEventListener('click', function () {
  111. var checkbox = this.querySelector('input[type="checkbox"]');
  112. if (checkbox.getAttribute('disabled') !== null) {
  113. return;
  114. }
  115. if (checkbox.checked) {
  116. checkbox.checked = false;
  117. } else {
  118. checkbox.checked = true;
  119. var evObj = document.createEvent('MouseEvents');
  120. evObj.initEvent('click', true, false);
  121. el.lastChild.querySelector('a').dispatchEvent(evObj);
  122. }
  123. }, false);
  124. }
  125. });
  126. }
  127. }
  128. //成绩分布页面,可以自定义一些东西
  129. function cjfbHelper() {
  130. var submitButton = document.querySelector('input[type="submit"]');
  131. var newButton = document.createElement('input');
  132. newButton.type = 'button';
  133. newButton.className = 'but40';
  134. newButton.value = '添加学期';
  135. newButton.addEventListener('click', function() {
  136. for (var i = 0; i <= 2; i++) {
  137. if (document.querySelector('#sel_xq option[value="' + i + '"]') === null) {
  138. var newOption = document.createElement('option');
  139. newOption.value = i;
  140. newOption.innerHTML = '第' + (i + 1) + '学期';
  141. document.getElementById('sel_xq').appendChild(newOption);
  142. }
  143. }
  144. }, false);
  145. submitButton.parentElement.insertBefore(newButton, submitButton);
  146. }
  147. if (url.includes('_data/login_home.aspx') || url.includes('_data/index_login.aspx')) {
  148. loginHelper();
  149. } else if (document.getElementById('frmMain') !== null) {
  150. mainHelper();
  151. } else if (url.includes('wsxk/stu_xszx_rpt.aspx')) {
  152. xkHelper();
  153. } else if (url.includes('znpk/Pri_StuSel.aspx')) {
  154. selHelper();
  155. } else if (url.includes('xscj/Stu_cjfb.aspx')) {
  156. cjfbHelper();
  157. }
  158. })();