一键导出Cookies

获取当前网页的Cookies,一键复制到剪贴板

当前为 2025-10-02 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         一键导出Cookies
// @namespace    http://tampermonkey.net/
// @version      1.1.0
// @description  获取当前网页的Cookies,一键复制到剪贴板
// @author       zskfree
// @match        http://*/*
// @match        https://*/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        GM_setClipboard
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    // 复制到剪贴板
    function copyToClipboard(text) {
        try {
            GM_setClipboard(text);
            alert('Cookies已复制到剪贴板!');
        } catch (err) {
            alert('复制失败,请检查脚本权限');
        }
    }

    // 创建导出按钮
    const btn = document.createElement('button');
    Object.assign(btn.style, {
        position: 'fixed',
        bottom: '15px',
        right: '15px',
        zIndex: '10000',
        width: '35px',
        height: '35px',
        borderRadius: '50%',
        backgroundColor: 'rgba(0, 0, 0, 0.4)',
        color: 'white',
        border: 'none',
        fontSize: '20px',
        cursor: 'pointer',
        display: 'flex',
        justifyContent: 'center',
        alignItems: 'center',
        boxShadow: '0 2px 5px rgba(0,0,0,0.2)',
        transition: 'background-color 0.3s'
    });
    btn.textContent = '🍪';
    btn.title = '导出并复制Cookies';

    // 悬停效果
    btn.onmouseenter = () => btn.style.backgroundColor = 'rgba(0, 0, 0, 0.6)';
    btn.onmouseleave = () => btn.style.backgroundColor = 'rgba(0, 0, 0, 0.4)';

    // 点击导出
    btn.onclick = () => {
        const cookies = document.cookie;
        cookies ? copyToClipboard(cookies) : alert('当前页面没有Cookies');
    };

    document.body.appendChild(btn);
})();