SEU lwReportEpidemicSeu dailyReport Automator

Automatically completes the health daily report during the Wuhan pneumonia pandemic.

  1. // ==UserScript==
  2. // @name SEU lwReportEpidemicSeu dailyReport Automator
  3. // @name:zh 东南大学健康打卡自动化
  4. // @name:zh-CN 东南大学健康打卡自动化
  5. // @namespace http://seu.saltfish.moe/
  6. // @version 0.20.1
  7. // @license Anti 996 License
  8. // @description Automatically completes the health daily report during the Wuhan pneumonia pandemic.
  9. // @description:zh 自动完成东南大学线上服务健康打卡过程。
  10. // @description:zh-CN 自动完成东南大学线上服务健康打卡过程。
  11. // @author SaltfishAmi
  12. // @include *://newids.seu.edu.cn/authserver/login?service=http://ehall.seu.edu.cn/qljfwapp2/sys/lwReportEpidemicSeu/index.do*
  13. // @include *://ehall.seu.edu.cn/qljfwapp2/sys/lwReportEpidemicSeu/index.do*
  14. // @grant none
  15. // ==/UserScript==
  16.  
  17. //======================CONFIG======================
  18. // Credentials for auto-login
  19. var username = "username";
  20. var password = "password";
  21. // Timeout settings in ms
  22. var timeoutBeforeLogin = 1500;
  23. var timeoutBeforeClickingAdd = 8000;
  24. var timeoutBeforeClickingSave = 3000;
  25. var timeoutBeforeClickingConfirm = 3000;
  26. //Temperature setting
  27. var temperature = String((361 + Math.floor(Math.random() * 10))/10.0);
  28. //==================================================
  29.  
  30. function $(id){
  31. return document.getElementById(id);
  32. }
  33. function $$(classname){
  34. return document.getElementsByClassName(classname);
  35. }
  36.  
  37. var clickevt = document.createEvent("MouseEvents");
  38. clickevt.initEvent("click", true, true);
  39.  
  40. (function() {
  41. 'use strict';
  42.  
  43. /**
  44. * Console History v1.5.1
  45. * console-history.js
  46. *
  47. * Licensed under the MIT License.
  48. *
  49. * Written by lesander <github.com/lesander>
  50. * For Doorbell.io <3
  51. * https://git.io/console
  52. * https://doorbell.io
  53. */
  54. /* Allow only one instance of console-history.js */
  55. if (typeof window.console.history !== 'undefined') {
  56. throw new Error('Only one instance of console-history.js can run at a time.')
  57. }
  58.  
  59. /* Store the original log functions. */
  60. window.console._log = window.console.log
  61. window.console._info = window.console.info
  62. window.console._warn = window.console.warn
  63. window.console._error = window.console.error
  64. window.console._debug = window.console.debug
  65.  
  66. /* Declare our console history variable. */
  67. window.console.history = []
  68.  
  69. /* Redirect all calls to the collector. */
  70. window.console.log = function () { return window.console._intercept('log', arguments) }
  71. window.console.info = function () { return window.console._intercept('info', arguments) }
  72. window.console.warn = function () { return window.console._intercept('warn', arguments) }
  73. window.console.error = function () { return window.console._intercept('error', arguments) }
  74. window.console.debug = function () { return window.console._intercept('debug', arguments) }
  75.  
  76. /* Give the developer the ability to intercept the message before letting
  77. console-history access it. */
  78. window.console._intercept = function (type, args) {
  79. window.console._collect(type, args)
  80. }
  81.  
  82. /* Define the main log catcher. */
  83. window.console._collect = function (type, args) {
  84. var time = new Date().toUTCString()
  85. if (!type) type = 'log'
  86. if (!args || args.length === 0) return
  87. window.console['_' + type].apply(window.console, args)
  88. var stack = false
  89. try { throw Error('') } catch (error) {
  90. var stackParts = error.stack.split('\n')
  91. stack = []
  92. for (var i = 0; i < stackParts.length; i++) {
  93. if (stackParts[i].indexOf('console-history.js') > -1 ||
  94. stackParts[i].indexOf('console-history.min.js') > -1 ||
  95. stackParts[i] === 'Error') {
  96. continue
  97. }
  98. stack.push(stackParts[i].trim())
  99. }
  100. }
  101. window.console.history.push({ type: type, timestamp: time, arguments: args, stack: stack })
  102. }
  103. /* End of console-history.js (c) 2016-2019 lesander*/
  104.  
  105. if(username=="username"){
  106. // username check
  107. alert("Please edit the script and set your username & password! \n请编辑脚本,指定你的用户名和密码!");
  108. alert("The script will now terminate. \n脚本执行中断。");
  109. return false;
  110. }
  111.  
  112. if(window.location.hostname != "ehall.seu.edu.cn"){
  113. // login
  114. // This will not work for login pages with role checking, as they have initial onClick functions of "return false".
  115. // use the url https://newids.seu.edu.cn/authserver/login?service=http://ehall.seu.edu.cn/qljfwapp2/sys/lwReportEpidemicSeu/index.do
  116. $("username").value = username;
  117. $("password").value = password;
  118.  
  119. setTimeout(function(){
  120. $$("auth_login_btn")[0].dispatchEvent(clickevt);
  121. }, timeoutBeforeLogin);
  122.  
  123. } else {
  124. //dailyreport
  125. setTimeout(function(){
  126. $$("bh-mb-16")[1].childNodes[1].dispatchEvent(clickevt);
  127. //save
  128. setTimeout(function(){
  129. $$("bh-mb-36")[3].childNodes[0].childNodes[0].childNodes[1].childNodes[1].value = temperature;
  130. $("save").dispatchEvent(clickevt);
  131. //confirm
  132. //setTimeout(function(){
  133. // $$("bh-dialog-btn")[0].dispatchEvent(clickevt);
  134. //}, timeoutBeforeClickingConfirm);
  135.  
  136. //if empty fields block the way, fuck them up by filling them with 0
  137. let coll = document.getElementsByClassName('jqx-dropdownlist-state-normal');
  138. window.console.history.forEach(function(item, index){
  139. //window.console._log(index);
  140. //window.console._log(item.arguments[0]);
  141. if(item.arguments[0].toString().substring(0,5) == "校验未通过"){
  142. var name = item.arguments[0].split(' ')[2];
  143. for(var i=0; i< coll.length; i++){
  144. if(coll[i].getAttribute('data-name') == name){
  145. coll[i].lastElementChild.value = 0;
  146. //window.console._log(coll[i]);
  147. break;
  148. }
  149. }
  150. }
  151. });
  152.  
  153. //save again
  154. //setTimeout(function(){
  155. //$$("bh-mb-36")[3].childNodes[0].childNodes[0].childNodes[1].childNodes[1].value = temperature;
  156. if(!$$("bh-dialog-btn")[0])$("save").dispatchEvent(clickevt);
  157. //confirm
  158. setTimeout(function(){
  159. $$("bh-dialog-btn")[0].dispatchEvent(clickevt);
  160. }, timeoutBeforeClickingConfirm);
  161. }, timeoutBeforeClickingSave);
  162. }, timeoutBeforeClickingAdd);
  163. }
  164. })();