Forráskód Böngészése

增加获取cookie脚本

jack 10 hónapja
szülő
commit
5f84b24770
2 módosított fájl, 45 hozzáadás és 1 törlés
  1. 1 1
      main.go
  2. 44 0
      scripts/copy_cookie.js

+ 1 - 1
main.go

@@ -67,7 +67,7 @@ func main() {
 		fmt.Println("脚本目录下的文件有:")
 		for _, file := range files {
 			if !file.IsDir() {
-				fmt.Printf("http://%s:%s/scripts/%s\n", ip, port, file.Name())
+				fmt.Printf("// @require      http://%s:%s/scripts/%s\n", ip, port, file.Name())
 			}
 		}
 	} else {

+ 44 - 0
scripts/copy_cookie.js

@@ -0,0 +1,44 @@
+// ==UserScript==
+// @name         获取并复制Cookie
+// @namespace    http://tampermonkey.net/
+// @version      1.0
+// @description  点击复制当前页面Cookie
+// @author       Jack
+// @match        *://*/*
+// @grant        GM_setClipboard
+// ==/UserScript==
+
+(function() {
+    'use strict';
+
+    // 创建按钮并设置样式
+    const executeButton = document.createElement("button");
+    executeButton.textContent = "Copy Cookie";
+    executeButton.style.position = "fixed";
+    executeButton.style.top = "50%";
+    executeButton.style.left = "2%";
+    executeButton.style.transform = "translateX(-50%)";
+    executeButton.style.padding = "3px 8px";
+    executeButton.style.fontSize = "10px";
+    executeButton.style.backgroundColor = "#007baf";
+    executeButton.style.color = "#fff";
+    executeButton.style.border = "none";
+    executeButton.style.borderRadius = "5px";
+    executeButton.style.cursor = "pointer";
+    executeButton.style.zIndex = "10000";
+
+    // 将按钮添加到页面中
+    document.body.appendChild(executeButton);
+
+    // 添加点击事件
+    executeButton.addEventListener('click', () => {
+        // 获取当前页面的Cookie
+        const cookies = document.cookie;
+
+        // 将Cookie复制到剪贴板
+        GM_setClipboard(cookies, { type: 'text' });
+
+        // 提示用户
+        alert('Cookie已复制到剪贴板!');
+    });
+})();