copy_cookie.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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. const button = document.createElement("button");
  13. button.textContent = "Copy Cookie";
  14. button.style.position = "fixed";
  15. button.style.top = "10%";
  16. button.style.right = "1%";
  17. button.style.transform = "translateY(-50%)";
  18. button.style.padding = "3px 8px";
  19. button.style.fontSize = "10px";
  20. button.style.backgroundColor = "#007baf";
  21. button.style.color = "#fff";
  22. button.style.border = "none";
  23. button.style.borderRadius = "5px";
  24. button.style.cursor = "pointer";
  25. button.style.zIndex = "10000";
  26. document.body.appendChild(button);
  27. button.addEventListener('click', () => {
  28. const cookies = document.cookie;
  29. GM_setClipboard(cookies, { type: 'text' });
  30. alert(`Cookie已复制到剪贴板!\n\n${cookies}`);
  31. });
  32. })();