lolipop 邮箱自动删除邮件工具
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

2 тижднів тому
2 тижднів тому
2 тижднів тому
2 тижднів тому
2 тижднів тому
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>邮件删除工具</title>
  5. <style>
  6. body {
  7. font-family: Arial, sans-serif;
  8. max-width: 800px;
  9. margin: 20px auto;
  10. padding: 20px;
  11. }
  12. .container {
  13. border: 1px solid #ccc;
  14. padding: 20px;
  15. border-radius: 5px;
  16. }
  17. .form-group {
  18. margin-bottom: 15px;
  19. }
  20. label {
  21. display: block;
  22. margin-bottom: 5px;
  23. }
  24. input[type="datetime-local"] {
  25. padding: 5px;
  26. width: 250px;
  27. }
  28. input[type="text"],
  29. input[type="password"] {
  30. padding: 5px;
  31. width: 250px;
  32. margin-bottom: 10px;
  33. border: 1px solid #ccc;
  34. border-radius: 4px;
  35. }
  36. button {
  37. background-color: #4CAF50;
  38. color: white;
  39. padding: 10px 20px;
  40. border: none;
  41. border-radius: 4px;
  42. cursor: pointer;
  43. }
  44. button:hover {
  45. background-color: #45a049;
  46. }
  47. #logArea {
  48. margin-top: 20px;
  49. padding: 10px;
  50. border: 1px solid #ddd;
  51. border-radius: 4px;
  52. height: 300px;
  53. overflow-y: auto;
  54. background-color: #f9f9f9;
  55. }
  56. .log-entry {
  57. margin: 5px 0;
  58. padding: 5px;
  59. border-bottom: 1px solid #eee;
  60. }
  61. .pagination-info {
  62. margin: 10px 0;
  63. padding: 5px;
  64. background-color: #f0f0f0;
  65. border-radius: 4px;
  66. font-size: 14px;
  67. color: #666;
  68. }
  69. </style>
  70. </head>
  71. <body>
  72. <div class="container">
  73. <h2>邮件删除工具</h2>
  74. <div class="form-group">
  75. <label for="email">邮箱账号:</label>
  76. <input type="text" id="email" required value="">
  77. </div>
  78. <div class="form-group">
  79. <label for="password">邮箱密码:</label>
  80. <input type="password" id="password" required value="">
  81. </div>
  82. <div class="form-group">
  83. <label for="startPage">起始页码:</label>
  84. <input type="number" id="startPage" required min="1" value="100">
  85. </div>
  86. <div class="form-group">
  87. <label for="endPage">结束页码:</label>
  88. <input type="number" id="endPage" min="1" placeholder="留空则删除到最后一页">
  89. </div>
  90. <div class="pagination-info" id="paginationInfo"></div>
  91. <button onclick="startDelete()">开始删除</button>
  92. <button onclick="testConnection()" style="background-color: #2196F3;">测试连接</button>
  93. <div id="logArea"></div>
  94. </div>
  95. <script>
  96. function addLog(message) {
  97. const logArea = document.getElementById('logArea');
  98. const logEntry = document.createElement('div');
  99. logEntry.className = 'log-entry';
  100. logEntry.textContent = `${new Date().toLocaleTimeString()} - ${message}`;
  101. logArea.insertBefore(logEntry, logArea.firstChild);
  102. }
  103. async function startDelete() {
  104. const email = document.getElementById('email').value;
  105. const password = document.getElementById('password').value;
  106. const startPage = parseInt(document.getElementById('startPage').value);
  107. const endPage = document.getElementById('endPage').value ? parseInt(document.getElementById('endPage').value) : null;
  108. if (!email || !password) {
  109. alert('请输入邮箱账号和密码');
  110. return;
  111. }
  112. if (!startPage || startPage < 1) {
  113. alert('请输入有效的起始页码');
  114. return;
  115. }
  116. if (endPage !== null && endPage < startPage) {
  117. alert('结束页码必须大于或等于起始页码');
  118. return;
  119. }
  120. console.log('Selected page range:', { startPage, endPage });
  121. addLog('开始删除邮件...');
  122. try {
  123. const response = await fetch('/start-delete', {
  124. method: 'POST',
  125. headers: {
  126. 'Content-Type': 'application/json'
  127. },
  128. body: JSON.stringify({
  129. email,
  130. password,
  131. startPage,
  132. endPage
  133. })
  134. });
  135. const result = await response.json();
  136. if (!response.ok) {
  137. throw new Error(result.message || '删除请求失败');
  138. }
  139. addLog('删除请求已发送,开始监听进度...');
  140. // Close any existing EventSource
  141. if (window.eventSource) {
  142. window.eventSource.close();
  143. }
  144. // Create new EventSource
  145. window.eventSource = new EventSource('/delete-progress');
  146. addLog('正在建立事件流连接...');
  147. window.eventSource.onopen = () => {
  148. addLog('与服务器的连接已建立');
  149. };
  150. window.eventSource.onmessage = (event) => {
  151. try {
  152. const data = JSON.parse(event.data);
  153. addLog(data.message);
  154. if (data.paginationInfo) {
  155. document.getElementById('paginationInfo').textContent = data.paginationInfo;
  156. }
  157. // Check if deletion is complete
  158. if (data.message.includes('删除完成')) {
  159. window.eventSource.close();
  160. addLog('删除操作完成,连接已关闭');
  161. }
  162. } catch (error) {
  163. console.error('Error parsing message:', error);
  164. addLog('收到未格式化消息: ' + event.data); // 如果解析失败,直接显示原始消息
  165. }
  166. };
  167. window.eventSource.onerror = (error) => {
  168. addLog('连接错误,尝试重新连接...');
  169. console.error('EventSource error:', error);
  170. // Close the connection on error and try to reconnect
  171. if (window.eventSource) {
  172. window.eventSource.close();
  173. // Try to reconnect after a short delay
  174. setTimeout(() => {
  175. addLog('尝试重新连接...');
  176. window.eventSource = new EventSource('/delete-progress');
  177. }, 3000);
  178. }
  179. };
  180. } catch (error) {
  181. addLog(`错误: ${error.message}`);
  182. }
  183. }
  184. async function testConnection() {
  185. addLog('测试连接中...');
  186. // Create test event source
  187. if (window.testEventSource) {
  188. window.testEventSource.close();
  189. }
  190. window.testEventSource = new EventSource('/delete-progress');
  191. window.testEventSource.onopen = () => {
  192. addLog('测试连接成功!');
  193. };
  194. window.testEventSource.onmessage = (event) => {
  195. addLog('收到消息: ' + event.data);
  196. };
  197. window.testEventSource.onerror = (error) => {
  198. addLog('测试连接失败');
  199. console.error('Test connection error:', error);
  200. window.testEventSource.close();
  201. };
  202. // Also call the test endpoint
  203. try {
  204. const response = await fetch('/test-event');
  205. const data = await response.json();
  206. addLog('服务器响应: ' + JSON.stringify(data));
  207. } catch (error) {
  208. addLog('请求测试端点失败: ' + error.message);
  209. }
  210. }
  211. </script>
  212. </body>
  213. </html>