copy_cookie.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // ==UserScript==
  2. // @name 获取并复制Cookie
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description 点击复制当前页面Cookie
  6. // @author Jack
  7. // @match *://*/*
  8. // @grant GM_setClipboard
  9. // ==/UserScript==
  10. (function() {
  11. 'use strict';
  12. // 创建按钮并设置样式
  13. const executeButton = document.createElement("button");
  14. executeButton.textContent = "Copy Cookie";
  15. executeButton.style.position = "fixed";
  16. executeButton.style.top = "50%";
  17. executeButton.style.left = "2%";
  18. executeButton.style.transform = "translateX(-50%)";
  19. executeButton.style.padding = "3px 8px";
  20. executeButton.style.fontSize = "10px";
  21. executeButton.style.backgroundColor = "#007baf";
  22. executeButton.style.color = "#fff";
  23. executeButton.style.border = "none";
  24. executeButton.style.borderRadius = "5px";
  25. executeButton.style.cursor = "pointer";
  26. executeButton.style.zIndex = "10000";
  27. // 将按钮添加到页面中
  28. document.body.appendChild(executeButton);
  29. // 添加点击事件
  30. executeButton.addEventListener('click', () => {
  31. // 获取当前页面的Cookie
  32. const cookies = document.cookie;
  33. // 将Cookie复制到剪贴板
  34. GM_setClipboard(cookies, { type: 'text' });
  35. // 提示用户
  36. alert('Cookie已复制到剪贴板!');
  37. });
  38. })();