Kaynağa Gözat

增加自动执行恶魔城, 赌狗任务

jack 10 ay önce
ebeveyn
işleme
91e4bc4291

+ 273 - 0
scripts/Web3TestApiAgnt.js

@@ -0,0 +1,273 @@
+// ==UserScript==
+// @name         AGNT.Hub Task Automation
+// @namespace    http://tampermonkey.net/
+// @version      0.1
+// @description  Automate AGNT.Hub tasks using current page's Cookie and Headers
+// @author       Jack
+// @match        https://quests.agnthub.ai/*
+// @grant        GM_xmlhttpRequest
+// @connect      hub-api.agnthub.ai
+// @connect      quests.agnthub.ai
+// ==/UserScript==
+
+(function () {
+  "use strict";
+
+  const executeButton = document.createElement("button");
+  executeButton.textContent = "恶魔城,启动!!";
+  executeButton.style.position = "fixed";
+  executeButton.style.top = "20px";
+  executeButton.style.left = "50%";
+  executeButton.style.padding = "10px 20px";
+  executeButton.style.backgroundColor = "#007bff";
+  executeButton.style.color = "#fff";
+  executeButton.style.border = "none";
+  executeButton.style.borderRadius = "5px";
+  executeButton.style.cursor = "pointer";
+  executeButton.style.zIndex = "10000";
+
+  executeButton.addEventListener("click", function () {
+      const currentCookie = document.cookie;
+      const responses = [];
+
+      const tasks = [
+          {
+              url: "https://hub-api.agnthub.ai/api/daily-rewards/claim",
+              headers: {
+                  "accept": "application/json, text/plain, */*",
+                  "accept-encoding": "gzip, deflate, br, zstd",
+                  "accept-language": "zh-CN,zh;q=0.9",
+                  "content-length": "0",
+                  "cookie": currentCookie,
+                  "origin": "https://quests.agnthub.ai",
+                  "priority": "u=1, i",
+                  "referer": "https://quests.agnthub.ai/",
+                  "sec-ch-ua": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
+                  "sec-ch-ua-mobile": "?0",
+                  "sec-ch-ua-platform": '"Windows"',
+                  "sec-fetch-dest": "empty",
+                  "sec-fetch-mode": "cors",
+                  "sec-fetch-site": "same-site",
+                  "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
+              }
+          },
+          {
+              url: "https://hub-api.agnthub.ai/api/tasks/make-ai-laugh/34ecad1e-94df-48ba-b5f4-242fdd9d6546",
+              headers: {
+                  "accept": "application/json, text/plain, */*",
+                  "accept-encoding": "gzip, deflate, br, zstd",
+                  "accept-language": "zh-CN,zh;q=0.9",
+                  "content-length": "0",
+                  "cookie": currentCookie,
+                  "origin": "https://quests.agnthub.ai",
+                  "priority": "u=1, i",
+                  "referer": "https://quests.agnthub.ai/",
+                  "sec-ch-ua": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
+                  "sec-ch-ua-mobile": "?0",
+                  "sec-ch-ua-platform": '"Windows"',
+                  "sec-fetch-dest": "empty",
+                  "sec-fetch-mode": "cors",
+                  "sec-fetch-site": "same-site",
+                  "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
+              }
+          }
+      ];
+
+      const tasksList = [
+          "6813de78-f821-4a84-8e8c-3aa89c15b2aa",
+          "fce2e806-a6c7-4de2-abc2-260d13bcfb2f",
+          "0bcb7d19-7c63-4933-96b0-00141ce54dbe",
+          "2f3241c5-29a0-4f47-acf3-9370baf94e74",
+          "d2b35062-40c1-48b8-bca5-c48779ccc66d",
+          "ab2fd158-b894-47bc-aadb-645259b46cc0",
+          "3861cd8e-5393-4285-b6ee-29a5ee301ee5",
+          "1a75844a-a108-4fbd-bfc3-c7476b26b73d",
+          "217e2f67-c110-4ef7-a636-8ac0623df3e8",
+          "49c1db40-8ecf-4454-af0a-fcc81b222135",
+          "2e6ff98c-132b-4886-8f38-6c89d1a7b02a",
+          "9fc278e8-4045-4130-9f52-6ce3b713318c",
+          "4f913da3-58b6-4636-a2c2-912fb01c73d4",
+          "6216f4e1-eafb-4442-a5d4-5b1830f89655",
+          "ebbba0a4-96d9-4fa4-85f9-6fb07fbc282a",
+          "5172f361-d28e-4aa2-a3ba-2adfe5057539",
+          "f81146e9-9ef9-4979-b0a0-437ea5c3e1bb",
+          "22301ec3-3a75-4758-a886-ab768312ffe5",
+          "6debaef3-844e-40f3-be6d-d99a6fd9f2a1",
+          "932d0c29-22ad-4be5-92b4-fc3a2e13aaed",
+          "05027b13-88a3-42a4-992a-0ce2a53068d4",
+          "9e0addfa-51fd-4f3b-a6f2-8dbe301265aa",
+          "4a42ba64-7822-469c-8899-bc07b5dd5d69",
+          "516d941e-b006-4744-a190-6c3207750854",
+          "bf9e7362-5eed-4110-bbe3-1289722a36b3",
+          "7eed7668-e71a-42ed-98ac-a0ded8bc0296",
+          "2cac41ba-36dd-4389-91b6-f8ee840083db",
+          "6f888d49-2b59-4ba9-a7be-199dceff45ab"
+      ];
+      console.log("开始执行任务列表");
+
+      function checkAllRequestsCompleted() {
+          if (responses.length === tasks.length + tasksList.length) {
+              showResultDialog(responses);
+          }
+      }
+
+      tasks.forEach(task => {
+          GM_xmlhttpRequest({
+              method: "POST",
+              url: task.url,
+              headers: task.headers,
+              onload: function (response) {
+                  try {
+                      const responseJson = JSON.parse(response.responseText);
+                      responses.push(responseJson.message);
+                      console.log(responseJson.message);
+                  } catch (error) {
+                      responses.push(`解析响应出错: ${error.message}`);
+                      console.error("解析响应出错:", error);
+                  }
+                  checkAllRequestsCompleted();
+              },
+              onerror: function (error) {
+                  console.error("请求失败:", error);
+                  responses.push(`请求失败:${error.status}`);
+                  checkAllRequestsCompleted();
+              }
+          });
+      });
+      console.log("零碎任务");
+      tasksList.forEach(taskId => {
+          const url = "https://hub-api.agnthub.ai/api/tasks/start/" + taskId;
+          const headers = {
+              "Accept": "application/json, text/plain, */*",
+              "Accept-Encoding": "gzip, deflate, br, zstd",
+              "Accept-Language": "zh-CN,zh;q=0.9",
+              "Content-Length": "0",
+              "Cookie": currentCookie,
+              "Origin": "https://quests.agnthub.ai",
+              "Priority": "u=1, i",
+              "Referer": "https://quests.agnthub.ai/",
+              "Sec-CH-UA": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
+              "Sec-CH-UA-Mobile": "?0",
+              "Sec-CH-UA-Platform": '"Windows"',
+              "Sec-Fetch-Dest": "empty",
+              "Sec-Fetch-Mode": "cors",
+              "Sec-Fetch-Site": "same-site",
+              "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
+          };
+
+          function retryRequest(retryCount) {
+              if (retryCount > 3) {
+                  responses.push(`请求 ${url} 失败,达到最大重试次数`);
+                  checkAllRequestsCompleted();
+                  return;
+              }
+
+              GM_xmlhttpRequest({
+                  method: "POST",
+                  url: url,
+                  headers: headers,
+                  onload: function (response) {
+                      try {
+                          if (response.status === 201) {
+                              const responseJson = JSON.parse(response.responseText);
+                              responses.push(responseJson.description);
+                              console.log(responseJson.description);
+                          } else {
+                              const responseJson = JSON.parse(response.responseText);
+                              console.log(`请求失败: ${responseJson.message}`);
+                              responses.push(`请求失败,状态码:${response.status}`);
+                              retryRequest(retryCount + 1);
+                          }
+                      } catch (error) {
+                          responses.push(`解析响应出错: ${error.message}`);
+                          console.error("解析响应出错:", error);
+                          retryRequest(retryCount + 1);
+                      }
+                      checkAllRequestsCompleted();
+                  },
+                  onerror: function (error) {
+                      console.error("请求失败:", error);
+                      responses.push(`出现错误:${error.status},重试...`);
+                      retryRequest(retryCount + 1);
+                  }
+              });
+          }
+
+          retryRequest(1);
+      });
+  });
+
+  function showResultDialog(responses) {
+      const dialog = document.createElement("div");
+      dialog.style.position = "fixed";
+      dialog.style.top = "50%";
+      dialog.style.left = "50%";
+      dialog.style.transform = "translate(-50%, -50%)";
+      dialog.style.padding = "20px";
+      dialog.style.backgroundColor = "#f9f9f9";
+      dialog.style.border = "1px solid #ddd";
+      dialog.style.borderRadius = "10px";
+      dialog.style.boxShadow = "0 4px 10px rgba(0, 0, 0, 0.1)";
+      dialog.style.zIndex = "10001";
+      dialog.style.width = "800px";
+      dialog.style.textAlign = "center";
+      dialog.style.maxHeight = "80vh";
+      dialog.style.overflowY = "auto";
+
+      const title = document.createElement("h3");
+      title.textContent = "操作完成";
+      title.style.color = "#333";
+      title.style.marginBottom = "10px";
+      dialog.appendChild(title);
+
+      const resultText = document.createElement("pre");
+      resultText.textContent = responses.join("\n\n");
+      resultText.style.whiteSpace = "pre-wrap";
+      resultText.style.overflowX = "auto";
+      resultText.style.maxHeight = "300px";
+      resultText.style.marginBottom = "15px";
+      resultText.style.padding = "10px";
+      resultText.style.border = "1px solid #eee";
+      resultText.style.borderRadius = "5px";
+      resultText.style.backgroundColor = "#fff";
+      resultText.style.width = "100%";
+      dialog.appendChild(resultText);
+
+      const buttonContainer = document.createElement("div");
+      buttonContainer.style.display = "flex";
+      buttonContainer.style.justifyContent = "center";
+      buttonContainer.style.gap = "10px";
+      buttonContainer.style.marginTop = "15px";
+      dialog.appendChild(buttonContainer);
+
+      const refreshButton = document.createElement("button");
+      refreshButton.textContent = "刷新";
+      refreshButton.style.padding = "8px 16px";
+      refreshButton.style.backgroundColor = "#007bff";
+      refreshButton.style.color = "#fff";
+      refreshButton.style.border = "none";
+      refreshButton.style.borderRadius = "5px";
+      refreshButton.style.cursor = "pointer";
+      refreshButton.addEventListener("click", function () {
+          location.reload();
+      });
+      buttonContainer.appendChild(refreshButton);
+
+      const cancelButton = document.createElement("button");
+      cancelButton.textContent = "取消";
+      cancelButton.style.padding = "8px 16px";
+      cancelButton.style.backgroundColor = "#ccc";
+      cancelButton.style.color = "#333";
+      cancelButton.style.border = "none";
+      cancelButton.style.borderRadius = "5px";
+      cancelButton.style.cursor = "pointer";
+      cancelButton.addEventListener("click", function () {
+          dialog.remove();
+      });
+      buttonContainer.appendChild(cancelButton);
+
+      document.body.appendChild(dialog);
+  }
+
+  document.body.appendChild(executeButton);
+})();

+ 160 - 0
scripts/Web3TestApiMagicNewtonRoll.js

@@ -0,0 +1,160 @@
+// ==UserScript==
+// @name         赌狗骰子
+// @namespace    http://tampermonkey.net/
+// @version      0.1
+// @description  使用自定义请求头和POST数据发起请求,并携带当前页面的Cookie
+// @author       Jack
+// @match        https://www.magicnewton.com/*
+// @grant        GM_xmlhttpRequest
+// @connect      www.magicnewton.com
+// ==/UserScript==
+
+(function () {
+    "use strict";
+  
+    const executeButton = document.createElement("button");
+    executeButton.textContent = "买定离手 6666 起机";
+    executeButton.style.position = "fixed";
+    executeButton.style.top = "20px";
+    executeButton.style.left = "50%";
+    executeButton.style.padding = "10px 20px";
+    executeButton.style.backgroundColor = "#007bff";
+    executeButton.style.color = "#fff";
+    executeButton.style.border = "none";
+    executeButton.style.borderRadius = "5px";
+    executeButton.style.cursor = "pointer";
+    executeButton.style.zIndex = "10000";
+  
+    executeButton.addEventListener("click", function () {
+      const currentCookie = document.cookie;
+      const targetUrl = "https://www.magicnewton.com/portal/api/userQuests";
+      const postData = {
+        questId: "f56c760b-2186-40cb-9cbc-3af4a3dc20e2",
+        metadata: { action: "ROLL" }
+      };
+      const responses = [];
+  
+      function makeRequest(retryCount) {
+        GM_xmlhttpRequest({
+          method: "POST",
+          url: targetUrl,
+          data: JSON.stringify(postData),
+          headers: {
+            "Content-Type": "application/json",
+            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
+            Referer: window.location.href,
+            Origin: "https://www.magicnewton.com",
+            "Sec-Fetch-Site": "same-origin",
+            "Sec-Fetch-Mode": "cors",
+            "Sec-Fetch-Dest": "empty",
+            Accept: "*/*",
+            "Accept-Encoding": "gzip, deflate, br, zstd",
+            "Accept-Language": "zh-CN,zh;q=0.9",
+            Cookie: currentCookie
+          },
+          onload: function (response) {
+            try {
+              const responseJson = JSON.parse(response.responseText);
+              responses.push(responseJson);
+  
+              if (responseJson.message === "Quest already completed") {
+                responses.push("任务已完成,不再继续请求");
+                showResultDialog(responses);
+                return;
+              }
+  
+              if (retryCount < 5) {
+                makeRequest(retryCount + 1);
+              } else {
+                responses.push("请求完成,已达到最大尝试次数");
+                showResultDialog(responses);
+              }
+            } catch (e) {
+              responses.push(`解析响应失败:${e.message}`);
+              showResultDialog(responses);
+            }
+          },
+          onerror: function (error) {
+            responses.push(`请求失败:${error.status}`);
+            showResultDialog(responses);
+          }
+        });
+      }
+  
+      makeRequest(0);
+  
+      function showResultDialog(responses) {
+        const dialog = document.createElement("div");
+        dialog.style.position = "fixed";
+        dialog.style.top = "50%";
+        dialog.style.left = "50%";
+        dialog.style.transform = "translate(-50%, -50%)";
+        dialog.style.padding = "20px";
+        dialog.style.backgroundColor = "#f9f9f9";
+        dialog.style.border = "1px solid #ddd";
+        dialog.style.borderRadius = "10px";
+        dialog.style.boxShadow = "0 4px 10px rgba(0, 0, 0, 0.1)";
+        dialog.style.zIndex = "10001";
+        dialog.style.width = "800px";
+        dialog.style.textAlign = "center";
+        dialog.style.maxHeight = "80vh";
+        dialog.style.overflowY = "auto";
+  
+        const title = document.createElement("h3");
+        title.textContent = "操作完成";
+        title.style.color = "#333";
+        title.style.marginBottom = "10px";
+        dialog.appendChild(title);
+  
+        const resultText = document.createElement("pre");
+        resultText.textContent = JSON.stringify(responses, null, 2);
+        resultText.style.whiteSpace = "pre-wrap";
+        resultText.style.overflowX = "auto";
+        resultText.style.maxHeight = "300px";
+        resultText.style.marginBottom = "15px";
+        resultText.style.padding = "10px";
+        resultText.style.border = "1px solid #eee";
+        resultText.style.borderRadius = "5px";
+        resultText.style.backgroundColor = "#fff";
+        resultText.style.width = "100%";
+        dialog.appendChild(resultText);
+  
+        const buttonContainer = document.createElement("div");
+        buttonContainer.style.display = "flex";
+        buttonContainer.style.justifyContent = "center";
+        buttonContainer.style.gap = "10px";
+        buttonContainer.style.marginTop = "15px";
+        dialog.appendChild(buttonContainer);
+  
+        const refreshButton = document.createElement("button");
+        refreshButton.textContent = "刷新";
+        refreshButton.style.padding = "8px 16px";
+        refreshButton.style.backgroundColor = "#007bff";
+        refreshButton.style.color = "#fff";
+        refreshButton.style.border = "none";
+        refreshButton.style.borderRadius = "5px";
+        refreshButton.style.cursor = "pointer";
+        refreshButton.addEventListener("click", function () {
+          location.reload();
+        });
+        buttonContainer.appendChild(refreshButton);
+  
+        const cancelButton = document.createElement("button");
+        cancelButton.textContent = "取消";
+        cancelButton.style.padding = "8px 16px";
+        cancelButton.style.backgroundColor = "#ccc";
+        cancelButton.style.color = "#333";
+        cancelButton.style.border = "none";
+        cancelButton.style.borderRadius = "5px";
+        cancelButton.style.cursor = "pointer";
+        cancelButton.addEventListener("click", function () {
+          dialog.remove();
+        });
+        buttonContainer.appendChild(cancelButton);
+  
+        document.body.appendChild(dialog);
+      }
+    });
+  
+    document.body.appendChild(executeButton);
+  })();

+ 0 - 91
scripts/download_pic.js

@@ -1,91 +0,0 @@
-// ==UserScript==
-// @name         图片下载器
-// @namespace    http://tampermonkey.net/ 
-// @version      1.1
-// @description  尝试在页面顶部添加一个按钮,点击后下载页面所有图片
-// @author       Jack
-// @match        *://*/*
-// @grant        GM_download
-// @grant        GM_addStyle
-// @require      https://cdnjs.cloudflare.com/ajax/libs/jszip/3.5.0/jszip.min.js 
-// ==/UserScript==
-
-(function () {
-    'use strict';
-
-    // 添加样式以确保按钮在页面加载时可见
-    GM_addStyle(`
-    .download-pic-button {
-        position: fixed;
-        top: 5%; /* 默认位置 */
-        left: 50%;
-        transform: translateX(-50%);
-        z-index: 10000;
-        border: none;
-        background-color: transparent; /* 背景颜色设置为透明 */
-        color: rgb(113, 100, 156); /* 字体颜色设置为指定的 RGB 值 */
-        cursor: pointer;
-        font-size: 15px;
-        padding: 0;
-    }
-`);
-
-    // 创建按钮并添加到页面顶部的中间
-    var downloadButton = document.createElement("button");
-    downloadButton.textContent = "New Btn";
-    downloadButton.className = 'download-pic-button';
-    document.body.appendChild(downloadButton);
-
-    // 点击按钮时执行的函数
-    downloadButton.onclick = function () {
-        // 将NodeList转换为数组
-        var images = Array.prototype.slice.call(document.querySelectorAll('img'));
-
-        var zip = new JSZip();
-        var imageDownloads = images.map(function (img, index) {
-            var src = img.src; // 获取图片的src属性
-            var filename = img.alt || 'image_' + index; // 使用alt属性作为文件名,如果没有alt则使用图片索引
-            var extensionMatch = src.match(/\.([^.]+)$/); // 正则表达式匹配文件扩展名
-            var extension = extensionMatch ? extensionMatch[1].toLowerCase() : 'jpg';
-
-            // 检查扩展名是否是图片格式
-            var validExtensions = ['jpg', 'jpeg', 'png', 'gif', 'svg', 'bmp', 'webp'];
-            if (validExtensions.includes(extension)) {
-                // 返回一个Promise,用于获取图片数据
-                return fetch(src).then(response => {
-                    if (!response.ok) {
-                        throw new Error('Network response was not ok for ' + src);
-                    }
-                    return response.blob();
-                }).then(blob => {
-                    // 将blob添加到zip文件中
-                    zip.file(filename + '.' + extension, blob);
-                }).catch(error => {
-                    console.error('Error fetching the image:', error);
-                });
-            }
-            // 如果不是图片格式或者不包含有效的src属性,不返回Promise,这样就不会影响Promise.all
-        });
-
-        // 使用filter去除那些非图片格式或不包含有效src的Promise
-        var validPromises = imageDownloads.filter(p => p);
-
-        // 等待所有有效的图片都添加到zip中
-        Promise.all(validPromises).then(() => {
-            // 生成zip文件并下载
-            zip.generateAsync({ type: 'blob' }).then(function (content) {
-                var filename = 'images_' + new Date().toISOString() + '.zip'; // 使用时间戳生成唯一的文件名
-                var eleLink = document.createElement('a');
-                eleLink.download = filename;
-                eleLink.style.display = 'none';
-                eleLink.href = URL.createObjectURL(content);
-                document.body.appendChild(eleLink);
-                eleLink.click();
-                document.body.removeChild(eleLink);
-            }).catch(error => {
-                console.error('Error generating the zip file:', error);
-            });
-        });
-    };
-}
-)();

+ 0 - 131
scripts/e-hentai-download.js

@@ -1,131 +0,0 @@
-// ==UserScript==
-// @name         图片下载器
-// @namespace    http://tampermonkey.net/
-// @version      1.1
-// @description  尝试在页面顶部添加一个按钮,点击后下载页面所有图片
-// @author       Jack
-// @match        *://*/*
-// @grant        GM_download
-// @grant        GM_addStyle
-// @require      https://cdnjs.cloudflare.com/ajax/libs/jszip/3.5.0/jszip.min.js
-// ==/UserScript==
-
-(function () {
-  'use strict';
-
-  // 添加样式以确保按钮在页面加载时可见
-  GM_addStyle(`
-  .download-pic-button {
-      position: fixed;
-      top: 5%; /* 默认位置 */
-      left: 50%;
-      transform: translateX(-50%);
-      z-index: 10000;
-      border: none;
-      background-color: transparent; /* 背景颜色设置为透明 */
-      color: rgb(113, 100, 156); /* 字体颜色设置为指定的 RGB 值 */
-      cursor: pointer;
-      font-size: 15px;
-      padding: 0;
-  }
-`);
-
-  // 创建按钮并添加到页面顶部的中间
-  var downloadButton = document.createElement("button");
-  downloadButton.textContent = "New Btn";
-  downloadButton.className = 'download-pic-button';
-  document.body.appendChild(downloadButton);
-
-  // 检查特定元素是否存在,并设置按钮位置
-  function checkElementAndSetButtonPosition() {
-    var targetElement = document.querySelector("body > div.o_action_manager > div > div.o_control_panel > div.o_cp_bottom > div.o_cp_bottom_left > div > div > button.btn.btn-secondary.fa.fa-download.o_list_export_xlsx");
-
-    if (targetElement) {
-      // 如果元素存在,获取元素的位置和尺寸
-      var targetRect = targetElement.getBoundingClientRect();
-      // 设置按钮的 top 值,使其与目标元素顶部对齐
-      downloadButton.style.top = `${targetRect.top + window.scrollY}px`;
-      // 设置按钮的 left 值,使其在目标元素右侧偏移量为 targetElementWidth + offset
-      var targetElementWidth = targetRect.width;
-      var offset = 10; // 你可以根据需要调整这个偏移量
-      downloadButton.style.left = `${targetRect.right + offset}px`; // 偏移量在目标元素右侧
-      downloadButton.style.transform = 'none';
-    } else {
-      // 如果元素不存在,恢复按钮的默认位置
-      downloadButton.style.top = '5%';
-      downloadButton.style.left = '50%';
-      downloadButton.style.transform = 'translateX(-50%)';
-    }
-  }
-
-  // 初始检查
-  checkElementAndSetButtonPosition();
-
-  // 监听滚动事件,以便在滚动时更新按钮位置
-  window.addEventListener('scroll', function () {
-    checkElementAndSetButtonPosition();
-  });
-
-  // 监听 DOM 变化,以便在元素被添加到页面时更新按钮位置
-  var observer = new MutationObserver(function (mutations) {
-    mutations.forEach(function (mutation) {
-      if (mutation.type === 'childList') {
-        checkElementAndSetButtonPosition();
-      }
-    });
-  });
-
-  observer.observe(document.body, { childList: true, subtree: true });
-
-  // 点击按钮时执行的函数
-  // 点击按钮时执行的函数
-  downloadButton.onclick = function () {
-    var images = document.querySelectorAll('img'); // 获取页面上所有的<img>元素
-    var zip = new JSZip();
-
-    console.log(images);
-    images.forEach(function (img) {
-      var src = img.src; // 获取图片的src属性
-      var filename = img.alt || 'image'; // 使用alt属性作为文件名,如果没有alt则默认为'image'
-
-      // 获取文件扩展名,如果没有扩展名则默认为 'jpg'
-      var extensionMatch = src.match(/\.([^.\/\?]+)$/); // 正则表达式匹配文件扩展名
-      var extension = extensionMatch ? extensionMatch[1].toLowerCase() : 'jpg';
-
-      // 检查扩展名是否是图片格式
-      var validExtensions = ['jpg', 'jpeg', 'png', 'gif', 'svg', 'bmp', 'webp'];
-      if (validExtensions.includes(extension)) {
-        // 异步获取图片数据
-        fetch(src)
-          .then(response => {
-            if (response.ok) return response.blob();
-            throw new Error('Network response was not ok.');
-          })
-          .then(blob => {
-            // 将blob添加到zip文件中
-            zip.file(filename + '.' + extension, blob);
-          })
-          .catch(error => {
-            console.error('There was a problem with the fetch operation:', error);
-          });
-      } else {
-        // 如果不是图片格式,跳过这个文件
-        console.log('Skipped non-image file:', src);
-      }
-    });
-
-    // 当所有图片都添加到zip中后,生成并下载zip文件
-    Promise.all(zip.files).then(() => {
-      zip.generateAsync({ type: 'blob' }).then(function (content) {
-        var filename = 'images_' + new Date().toISOString() + '.zip'; // 使用时间戳生成唯一的文件名
-        var eleLink = document.createElement('a');
-        eleLink.download = filename;
-        eleLink.style.display = 'none';
-        eleLink.href = URL.createObjectURL(content);
-        document.body.appendChild(eleLink);
-        eleLink.click();
-        document.body.removeChild(eleLink);
-      });
-    });
-  };
-})();