健康打卡自动化

Automatically completes the health daily report

当前为 2021-10-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name dailyReport Automator
  3. // @name:zh 健康打卡自动化
  4. // @name:zh-CN 健康打卡自动化
  5. // @namespace http://stu3.zstu.edu.cn/webroot/decision
  6. // @version 0.01
  7. // @description Automatically completes the health daily report
  8. // @description:zh-cn 每日健康打卡自动化
  9. // @author Chaos4Yarn
  10. // @match http://stu3.zstu.edu.cn/webroot/decision/*
  11. // @match http://stu3.zstu.edu.cn/webroot/decision
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. //======================CONFIG======================
  16. // Credentials for auto-login
  17. var username = "2018329621030";
  18. var password = "Ymq19991105";
  19. //==================================================
  20.  
  21. function $(id){
  22. return document.getElementById(id);
  23. }
  24. function $$(classname){
  25. return document.getElementsByClassName(classname);
  26. }
  27. function $$$(name){
  28. return document.getElementsByName(name);
  29. }
  30.  
  31.  
  32. (function() {
  33. 'use strict';
  34. window.onload = function() {
  35. if(username=="username"){
  36. // username check
  37. alert("Please edit the script and set your username & password! \n请编辑脚本,指定你的用户名和密码!");
  38. alert("The script will now terminate. \n脚本执行中断。");
  39. return false;
  40. }
  41. if(window.location.pathname === "/webroot/decision/login"){
  42. // 账号密码
  43. $$("bi-input")[0].value = username;
  44. $$("bi-input")[1].value = password;
  45. // 登录(不可用)按钮点击
  46. var clickevt = document.createEvent("MouseEvents");
  47. clickevt.initEvent("click", true, true);
  48. $$("login-button")[0].dispatchEvent(clickevt);
  49.  
  50. } else {
  51. // 打开 健康申报标签栏
  52. var open = document.createEvent("Event");
  53. open.initEvent("click", true, true);
  54. $$("bi-expander")[0].dispatchEvent(open);
  55. setTimeout(function() {
  56. $$("dec-frame-platform-list-item-active")[0].dispatchEvent(open);
  57. }, 0);
  58. // 定时器,加载完毕,打开健康申报页面
  59. var timer;
  60. timer = setInterval(function() {
  61. if ($$("bi-iframe bi-card")[1].contentWindow.document.getElementsByClassName("linkspan").length) {
  62. $$("bi-iframe bi-card")[1].contentWindow.document.getElementsByClassName("linkspan")[0].dispatchEvent(open);
  63. clearInterval(timer);
  64. // 自动填充数据
  65. var timer2;
  66. timer2 = setInterval(function() {
  67. var el = dataFormat("x-text");
  68. if (el.length) {
  69. clearInterval(timer2);
  70. // 自动填充数据
  71. autoFillData();
  72. }
  73. },500)
  74. }
  75. },500)
  76. function dataFormat(className) {
  77. return $$("bi-iframe bi-card")[1].contentWindow.document.getElementsByClassName(className);
  78. }
  79. function tdDataFormat(id) {
  80. return $$("bi-iframe bi-card")[1].contentWindow.document.getElementById(id);
  81. }
  82. // 自动填充数据
  83. function autoFillData() {
  84. // 省市区
  85. dataFormat("fr-trigger-texteditor")[0].value = "浙江省"
  86. tdDataFormat("D9-0-0").setAttribute("cv", "浙江省")
  87. dataFormat("fr-trigger-texteditor")[1].value = "杭州市"
  88. tdDataFormat("E9-0-0").setAttribute("cv", "杭州市")
  89. dataFormat("fr-trigger-texteditor")[2].value = "江干区"
  90. tdDataFormat("F9-0-0").setAttribute("cv", "江干区")
  91. dataFormat("fr-texteditor")[0].value = "浙江理工大学"
  92. tdDataFormat("D10-0-0").setAttribute("cv", "浙江理工大学")
  93. // radio
  94. // 是否离校 0:是,1:否
  95. // dataFormat("x-text")[1].classList.remove("fr-radio-radiooff")
  96. // dataFormat("x-text")[1].classList.add("fr-radio-radioon")
  97. // 身体状况 2:正常,3:不是
  98. dataFormat("x-text")[2].classList.remove("fr-radio-radiooff")
  99. dataFormat("x-text")[2].classList.add("fr-radio-radioon")
  100. tdDataFormat("D18-0-0").setAttribute("cv", "正常")
  101. // 今日上午测量体温 8:37度以下,9:37-37.2度,10:37.3度以上
  102. dataFormat("x-text")[8].classList.remove("fr-radio-radiooff")
  103. dataFormat("x-text")[8].classList.add("fr-radio-radioon")
  104. tdDataFormat("D20-0-0").setAttribute("cv", "37度以下")
  105. // 昨日下午测量体温 11:37度以下,12:37-37.2度,13:37.3度以上
  106. dataFormat("x-text")[11].classList.remove("fr-radio-radiooff")
  107. dataFormat("x-text")[11].classList.add("fr-radio-radioon")
  108. tdDataFormat("D21-0-0").setAttribute("cv", "37度以下")
  109. // 是否接种新冠疫苗 21:是 全部,22:是 第一次,23:否
  110. // dataFormat("x-text")[23].classList.remove("fr-radio-radiooff")
  111. // dataFormat("x-text")[23].classList.add("fr-radio-radioon")
  112. // 1.杭州健康码 24:绿色
  113. dataFormat("x-text")[24].classList.remove("fr-radio-radiooff")
  114. dataFormat("x-text")[24].classList.add("fr-radio-radioon")
  115. tdDataFormat("F26-0-0").setAttribute("cv", "绿色")
  116. // 2.通信大数据行程卡 29:绿色
  117. dataFormat("x-text")[29].classList.remove("fr-radio-radiooff")
  118. dataFormat("x-text")[29].classList.add("fr-radio-radioon")
  119. tdDataFormat("F27-0-0").setAttribute("cv", "绿色")
  120. // 3.是否属于近28日内境返回人员 34:是,35:否
  121. dataFormat("x-text")[35].classList.remove("fr-radio-radiooff")
  122. dataFormat("x-text")[35].classList.add("fr-radio-radioon")
  123. tdDataFormat("F28-0-0").setAttribute("cv", "否")
  124. // 4.学生及同住家庭成员是否存在确诊/疑似病例 36:是,37:否
  125. dataFormat("x-text")[37].classList.remove("fr-radio-radiooff")
  126. dataFormat("x-text")[37].classList.add("fr-radio-radioon")
  127. tdDataFormat("F29-0-0").setAttribute("cv", "否")
  128. // 5.学生及同住家庭成员:近14天是否到过中高风险地区 38:是,39:否
  129. dataFormat("x-text")[39].classList.remove("fr-radio-radiooff")
  130. dataFormat("x-text")[39].classList.add("fr-radio-radioon")
  131. tdDataFormat("F30-0-0").setAttribute("cv", "否")
  132. // 6.学生及同住家庭成员:近十四天是否接触中高风险地区返回人员 40:是,41:否
  133. dataFormat("x-text")[41].classList.remove("fr-radio-radiooff")
  134. dataFormat("x-text")[41].classList.add("fr-radio-radioon")
  135. tdDataFormat("F32-0-0").setAttribute("cv", "否")
  136. // 7.近14天内是否做过核酸检测 42:否,43:阴性,44:阳性
  137. dataFormat("x-text")[42].classList.remove("fr-radio-radiooff")
  138. dataFormat("x-text")[42].classList.add("fr-radio-radioon")
  139. tdDataFormat("F34-0-0").setAttribute("cv", "否")
  140. // 家人/同住人员是否有出现发热、干咳等症状 45:是,46:否
  141. dataFormat("x-text")[46].classList.remove("fr-radio-radiooff")
  142. dataFormat("x-text")[46].classList.add("fr-radio-radioon")
  143. tdDataFormat("F36-0-0").setAttribute("cv", "否")
  144. // 是否曾离开所居住城市 47:是,48:否
  145. dataFormat("x-text")[48].classList.remove("fr-radio-radiooff")
  146. dataFormat("x-text")[48].classList.add("fr-radio-radioon")
  147. tdDataFormat("F38-0-0").setAttribute("cv", "否")
  148. // 是否属于近14天内从福建省厦门市、泉州市、莆田市、晋江市,哈尔滨市返回? 49:是,50:否
  149. dataFormat("x-text")[50].classList.remove("fr-radio-radiooff")
  150. dataFormat("x-text")[50].classList.add("fr-radio-radioon")
  151. tdDataFormat("F40-0-0").setAttribute("cv", "否")
  152. // 提交数据(自动,可选择打开)
  153. // var submit = document.createEvent("Event");
  154. // submit.initEvent("click", true, true);
  155. // dataFormat("fr-btn-up fr-btn-noicon")[0].dispatchEvent(submit);
  156. }
  157. }
  158. }
  159. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址