index_dongri.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>yys Display</title>
  7. <style>
  8. .monitor-container {
  9. display: flex;
  10. flex-direction: row;
  11. }
  12. .checkbox-container {
  13. display: flex;
  14. flex-direction: column;
  15. }
  16. .operate-container {
  17. display: flex;
  18. flex-direction: column;
  19. }
  20. .status-container {
  21. display: flex;
  22. flex-direction: row;
  23. }
  24. #hint_message p {
  25. font-size: 10px; /* 设置为较小的字体大小 */
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <h2 id="title_message">Monitor Display</h2>
  31. <div class="monitor-container">
  32. <h3>请选择时间间隔:</h3>
  33. <select id="timeInterval">
  34. <option value="500">0.5 秒</option>
  35. <option value="1000" selected>1 秒</option>
  36. <option value="2000">2 秒</option>
  37. <option value="5000">5 秒</option>
  38. <option value="0">停止</option>
  39. </select>
  40. <canvas id="canvas" width="300" height="400"></canvas>
  41. <h3>待办列表:</h3>
  42. <div id="task_message" style="border: 1px solid #ccc; padding: 10px; margin-top: 10px;"></div>
  43. </div>
  44. <div class="status-container">
  45. <h3>状态:</h3>
  46. <div id="status_message" style="border: 1px solid #ccc; padding: 10px; margin-top: 10px;"></div>
  47. <h3>任务列表:</h3>
  48. <div id="hint_message"></div>
  49. <div class="checkbox-container">
  50. <label>
  51. 是否最大收集:
  52. <input type="text" id="maxCollectCheckbox" value="4,4,3,3,3,2,2,2,1,1">
  53. </label>
  54. <label>
  55. 治疗大小:
  56. <input type="text" id="cureNumberCheckbox" value="500">
  57. </label>
  58. <label>
  59. 打怪:
  60. <select id="JiNaCheckbox">
  61. <option value="None">None</option>
  62. <option value="monster">monster</option>
  63. <option value="big_monster">big_monster</option>
  64. <option value="yongbing">yongbing</option>
  65. <option value="jina" selected>jina</option>
  66. <option value="jina_call">jina_call</option>
  67. <option value="jina_onlyFight">jina_onlyFight</option>
  68. </select>
  69. </label>
  70. <label>
  71. 活动:
  72. <select id="AcitivityCheckbox">
  73. <option value="None" selected>None</option>
  74. <option value="lianmeng">lianmeng</option>
  75. <option value="cure">cure</option>
  76. <option value="only_cure">only_cure</option>
  77. </select>
  78. </label>
  79. <label>
  80. 训练方式:
  81. <select id="trainCheckbox">
  82. <option value="None">None</option>
  83. <option value="default" selected>default</option>
  84. <option value="lv1">优先lv1</option>
  85. <option value="lv8">优先lv8</option>
  86. <option value="lv9">优先lv9</option>
  87. <option value="upgrade">优先升级</option>
  88. </select>
  89. </label>
  90. <label><input type="checkbox" id="SimpleCheckbox"> 是否小号</label>
  91. <label><input type="checkbox" id="switchCheckbox"> 是否切换</label>
  92. <label><input type="checkbox" id="lineCheckbox"> 预留队列</label>
  93. <label><input type="checkbox" id="AddStrenghCheckbox"> 是否添加体力</label>
  94. <label><input type="checkbox" id="participateJijieCheckbox"> 是否参与集结</label>
  95. <label><input type="checkbox" id="autoDaily_checkbox"> 自动每日</label>
  96. <label><input type="checkbox" id="isRestart_checkbox"> 是否重启</label>
  97. <label><input type="checkbox" id="always_checkbox"> 无尽运行</label>
  98. </div>
  99. <div class="operate-container">
  100. <button class="custom-button" id="atuoRanshuang_btn" onclick="begin_ranshuang()">自动燃霜</button>
  101. <button class="custom-button" id="autoPalace_btn" onclick="auto_palace()">自动王城</button>
  102. <button class="custom-button" id="atuo_btn" onclick="begin_paticipate()">自动打熊</button>
  103. <button class="custom-button" id="resetScript_btn" onclick="reset_script()">重置脚本</button>
  104. <button class="custom-button" id="closegame_btn" onclick="close_game()">关闭游戏</button>
  105. <button class="custom-button" id="restartgame_btn" onclick="restart_game()">重新关闭并自动游戏</button>
  106. <button class="custom-button" id="atuoRun_btn" onclick="begin_auto()">自动模式</button>
  107. <button class="custom-button" id="testNewFun_btn" onclick="begin_testNewFun()">测试新功能</button>
  108. </div>
  109. </div>
  110. <script src="https://cdnjs.loli.net/ajax/libs/socket.io/4.2.0/socket.io.js"></script>
  111. <script>
  112. const socket = io();
  113. socket.on('connect', () => {
  114. console.log('Connected to server');
  115. });
  116. socket.on('disconnect', () => {
  117. console.log('Disconnected from server');
  118. });
  119. socket.on('image_data', (image_data_base64) => {
  120. const canvas = document.getElementById('canvas');
  121. const ctx = canvas.getContext('2d');
  122. const image = new Image();
  123. image.onload = () => {
  124. ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
  125. };
  126. image.src = 'data:image/jpeg;base64,' + image_data_base64;
  127. });
  128. socket.on('processing_status', (msg) => {
  129. var messageBox = document.getElementById('status_message');
  130. messageBox.innerHTML = msg;
  131. console.log(msg);
  132. });
  133. socket.on('processing_todo', (msg) => {
  134. var messageBox = document.getElementById('task_message');
  135. messageBox.innerHTML = msg;
  136. console.log(msg);
  137. });
  138. socket.on('processing_title', (msg) => {
  139. var messageBox = document.getElementById('title_message');
  140. messageBox.innerHTML = msg;
  141. });
  142. socket.on('processing_cfg', (msg) => {
  143. console.log(msg);
  144. // 获取元素
  145. const maxCollectInput = document.getElementById('maxCollectCheckbox'); // 文本输入框
  146. const cureNumberInput = document.getElementById('cureNumberCheckbox'); // 文本输入框
  147. const jiNaSelect = document.getElementById('JiNaCheckbox'); // 下拉列表
  148. const simpleCheckbox = document.getElementById('SimpleCheckbox'); // 复选框
  149. const switchCheckbox = document.getElementById('switchCheckbox'); // 复选框
  150. const lineCheckbox = document.getElementById('lineCheckbox'); // 复选框
  151. const AddStrenghCheckbox = document.getElementById('AddStrenghCheckbox'); // 复选框
  152. const participateJijieCheckbox = document.getElementById('participateJijieCheckbox'); // 复选框
  153. const AcitivitySelect = document.getElementById('AcitivityCheckbox'); // 下拉列表
  154. const autoDaily_checkbox = document.getElementById('autoDaily_checkbox'); // 复选框
  155. const isRestart_checkbox = document.getElementById('isRestart_checkbox'); // 复选框
  156. const trainSelect = document.getElementById('trainCheckbox'); // 下拉列表
  157. const always_checkbox = document.getElementById('always_checkbox'); // 复选框
  158. // 设置值
  159. maxCollectInput.value = msg['maxCollect']; // 设置文本输入框的值
  160. cureNumberInput.value = msg['cureNumber']; // 设置文本输入框的值
  161. jiNaSelect.value = msg['jina']; // 设置下拉列表的值
  162. simpleCheckbox.checked = msg['simple']; // 设置复选框的状态
  163. switchCheckbox.checked = msg['switch']; // 设置复选框的状态
  164. lineCheckbox.checked = msg['lineCheck']; // 设置复选框的状态
  165. AddStrenghCheckbox.checked = msg['add_strength']; // 设置复选框的状态
  166. AcitivitySelect.value = msg['activity']; // 设置下拉列表的值
  167. participateJijieCheckbox.checked = msg['participate_jijie']; // 设置复选框的状态
  168. autoDaily_checkbox.checked = msg['auto_daily']; // 设置复选框的状态
  169. isRestart_checkbox.checked = msg['is_restart']; // 设置复选框的状态
  170. trainSelect.value = msg['train']; // 设置下拉列表的值
  171. always_checkbox.checked = msg['always']; // 设置复选框的状态
  172. // 如果需要显示消息,可以取消注释以下代码
  173. // var messageBox = document.getElementById('title_message');
  174. // messageBox.innerHTML = msg;
  175. });
  176. socket.on('processing_hint', (msg) => {
  177. var messageBox = document.getElementById('hint_message');
  178. var data = JSON.parse(msg);
  179. var listDiv = document.createElement("div");
  180. for (var i = 0; i < data.length; i++) {
  181. var listItem = document.createElement("p");
  182. listItem.textContent = data[i];
  183. listDiv.appendChild(listItem);
  184. }
  185. messageBox.innerHTML = "";
  186. messageBox.appendChild(listDiv)
  187. });
  188. var timerId;
  189. function executeTask() {
  190. var selectElement = document.getElementById("timeInterval");
  191. var selectedValue = selectElement.value;
  192. if (selectedValue == '0'){
  193. clearInterval(timerId)
  194. var canvas = document.getElementById("canvas");
  195. var ctx = canvas.getContext("2d");
  196. ctx.clearRect(0, 0, canvas.width, canvas.height);
  197. timerId = setInterval(executeTask, 1000);
  198. }
  199. else
  200. {
  201. socket.emit('monitor_begin');
  202. clearInterval(timerId)
  203. timerId = setInterval(executeTask, parseInt(selectedValue));
  204. }
  205. }
  206. function begin_testNewFun() {
  207. socket.emit('begin_testNewFun');
  208. }
  209. function begin_auto() {
  210. const maxCollectValue = document.getElementById('maxCollectCheckbox').value; // 获取文本输入框的值
  211. const cureNumberValue = document.getElementById('cureNumberCheckbox').value; // 获取文本输入框的值
  212. const jiNaValue = document.getElementById('JiNaCheckbox').value; // 获取下拉列表的值
  213. const isSimple = document.getElementById('SimpleCheckbox').checked; // 获取复选框的状态
  214. const switchValue = document.getElementById('switchCheckbox').checked; // 获取复选框的状态
  215. const lineCheck = document.getElementById('lineCheckbox').checked; // 获取复选框的状态
  216. const isAddStrengh = document.getElementById('AddStrenghCheckbox').checked; // 获取复选框的状态
  217. const activityValue = document.getElementById('AcitivityCheckbox').value; // 获取下拉列表的值
  218. const participateJijie = document.getElementById('participateJijieCheckbox').checked; // 获取复选框的状态
  219. const autoDaily = document.getElementById('autoDaily_checkbox').checked; // 获取复选框的状态
  220. const isRestart = document.getElementById('isRestart_checkbox').checked; // 获取复选框的状态
  221. const trainValue = document.getElementById('trainCheckbox').value; // 获取下拉列表的值
  222. const always = document.getElementById('always_checkbox').checked; // 获取复选框的状态
  223. // 发出数据
  224. socket.emit('begin_auto', {
  225. maxCollect: maxCollectValue, // 发送文本输入框的值
  226. cureNumber: cureNumberValue, // 发送文本输入框的值
  227. jina: jiNaValue, // 发送下拉列表的值
  228. simple: isSimple // 发送复选框的状态
  229. ,switch:switchValue
  230. ,lineCheck:lineCheck
  231. ,add_strength:isAddStrengh
  232. ,activity:activityValue
  233. ,participate_jijie:participateJijie
  234. ,auto_daily:autoDaily
  235. ,is_restart:isRestart
  236. ,train:trainValue
  237. ,always:always
  238. });
  239. }
  240. function begin_paticipate(){
  241. socket.emit('begin_auto_participate');
  242. }
  243. function begin_ranshuang(){
  244. socket.emit('begin_auto_ranshuang')
  245. }
  246. function auto_palace()
  247. {
  248. socket.emit('auto_palace')
  249. }
  250. function restart_game()
  251. {
  252. socket.emit('restart_game');
  253. }
  254. function close_game()
  255. {
  256. socket.emit('close_game');
  257. }
  258. function get_title()
  259. {
  260. socket.emit('get_title');
  261. }
  262. function read_cfg()
  263. {
  264. socket.emit('read_cfg');
  265. }
  266. function reset_script(){
  267. socket.emit('reset_script');
  268. }
  269. function isWorkingHours() {
  270. // 检查是否为本地域名
  271. const isLocalDomain = window.location.hostname === 'localhost' ||
  272. window.location.hostname === '127.0.0.1' ||
  273. window.location.hostname === '';
  274. if (isLocalDomain) {
  275. return false;
  276. }
  277. const now = new Date();
  278. const day = now.getDay(); // 0是周日,1是周一,...,6是周六
  279. const hours = now.getHours();
  280. const minutes = now.getMinutes();
  281. // 将当前时间转换为分钟数,方便比较
  282. const currentTime = hours * 60 + minutes;
  283. // 工作日检查(周一到周五)
  284. const isWeekday = day >= 1 && day <= 5;
  285. // 工作时间段1: 9:00-11:30 (480-690分钟)
  286. const morningStart = 9 * 60; // 8:00
  287. const morningEnd = 11 * 60 + 30; // 11:30
  288. // 工作时间段2: 14:00-17:30 (840-1050分钟)
  289. const afternoonStart = 14 * 60; // 14:00
  290. const afternoonEnd = 17 * 60 + 30; // 17:30
  291. // 检查是否在工作时间段内
  292. const isWorkingTime = isWeekday &&
  293. ((currentTime >= morningStart && currentTime <= morningEnd) ||
  294. (currentTime >= afternoonStart && currentTime <= afternoonEnd));
  295. return isWorkingTime;
  296. }
  297. function updateButtonStatus() {
  298. const buttons = document.querySelectorAll('.custom-button');
  299. const isDisabled = isWorkingHours();
  300. console.log("isDisabled:", isDisabled);
  301. buttons.forEach(button => {
  302. // 排除restartgame_btn按钮
  303. if(button.id !== 'restartgame_btn') {
  304. button.disabled = isDisabled;
  305. }
  306. });
  307. }
  308. function stopPageAndCloseSocket() {
  309. // 获取当前连接的 WebSocket URL
  310. const socketUrl = socket.io.uri;
  311. // 检查是否为本地连接
  312. if (!socketUrl.includes("127.0.0.1")) {
  313. // 停止定时器
  314. clearInterval(timerId);
  315. // 关闭 WebSocket 连接
  316. socket.disconnect();
  317. // 清除画布内容(可选)
  318. var canvas = document.getElementById("canvas");
  319. var ctx = canvas.getContext("2d");
  320. ctx.clearRect(0, 0, canvas.width, canvas.height);
  321. // 可以添加其他停止页面运行的逻辑...
  322. }
  323. }
  324. document.addEventListener('DOMContentLoaded', function() {
  325. updateButtonStatus();
  326. // 每分钟检查一次时间变化
  327. setInterval(updateButtonStatus, 60000);
  328. });
  329. // 页面加载时设置5分钟后的定时器
  330. window.onload = function() {
  331. get_title();
  332. read_cfg();
  333. executeTask();
  334. setTimeout(stopPageAndCloseSocket, 600000); // 1分钟 = 60000毫秒
  335. };
  336. </script>
  337. </body>
  338. </html>