
成品直接下载:
点我下载延旭CK插件.zip
或者点击:https://gyx666.lanzouu.com/iMcaf324pz4j
popup.html代码如下:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>延旭CK提取器</title>
<link rel="stylesheet" href="popup.css">
</head>
<body>
<div class="container">
<h1>延旭CK提取器</h1>
<button id="extractBtn">提取Cookie</button>
<div class="button-group">
<button id="copyBtn">复制Cookie</button>
<button id="injectBtn">置入CK</button>
<button id="deleteBtn">删除Cookie</button>
</div>
<textarea id="cookieDisplay" class="cookie-display" placeholder="请点击上方按钮提取Cookie"></textarea>
<div class="copyright">作者QQ1763629364</div>
</div>
<script src="popup.js"></script>
</body>
</html> popup.css代码如下
body {
margin: 0;
padding: 0;
font-family: 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
background: linear-gradient(135deg, #f8fafc 0%, #e0e7ef 100%);
min-width: 320px;
min-height: 320px;
}
.container {
padding: 24px 18px 18px 18px;
text-align: center;
}
h1 {
font-size: 1.3rem;
color: #2d3a4b;
margin-bottom: 18px;
letter-spacing: 2px;
}
#extractBtn {
background: linear-gradient(90deg, #4f8cff 0%, #1e90ff 100%);
color: #fff;
border: none;
border-radius: 6px;
padding: 10px 28px;
font-size: 1rem;
cursor: pointer;
box-shadow: 0 2px 8px rgba(30,144,255,0.08);
transition: background 0.2s;
}
#extractBtn:hover {
background: linear-gradient(90deg, #1e90ff 0%, #4f8cff 100%);
}
.button-group {
margin-top: 12px;
display: flex;
gap: 6px;
justify-content: center;
flex-wrap: wrap;
}
#copyBtn, #injectBtn, #deleteBtn {
background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
color: #fff;
border: none;
border-radius: 6px;
padding: 8px 12px;
font-size: 0.85rem;
cursor: pointer;
box-shadow: 0 2px 6px rgba(40,167,69,0.08);
transition: background 0.2s;
}
#copyBtn:hover, #injectBtn:hover, #deleteBtn:hover {
background: linear-gradient(90deg, #20c997 0%, #28a745 100%);
}
#injectBtn {
background: linear-gradient(90deg, #ff6b35 0%, #f7931e 100%);
box-shadow: 0 2px 6px rgba(255,107,53,0.08);
}
#injectBtn:hover {
background: linear-gradient(90deg, #f7931e 0%, #ff6b35 100%);
}
#deleteBtn {
background: linear-gradient(90deg, #dc3545 0%, #c82333 100%);
box-shadow: 0 2px 6px rgba(220,53,69,0.08);
}
#deleteBtn:hover {
background: linear-gradient(90deg, #c82333 0%, #dc3545 100%);
}
.cookie-display {
margin-top: 18px;
background: #fff;
border: 1px solid #e1e5e9;
border-radius: 6px;
box-shadow: 0 1px 6px rgba(0,0,0,0.06);
padding: 12px;
min-height: 80px;
width: 100%;
box-sizing: border-box;
color: #333;
font-size: 0.9rem;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
resize: vertical;
outline: none;
}
.cookie-display:focus {
border-color: #4f8cff;
box-shadow: 0 0 0 2px rgba(79,140,255,0.1);
}
.copyright {
margin-top: 16px;
font-size: 0.8rem;
color: #6c757d;
text-align: center;
font-weight: 500;
} popup.js代码如下:
document.getElementById('extractBtn').addEventListener('click', async () => {
const cookieDisplay = document.getElementById('cookieDisplay');
cookieDisplay.value = '正在提取...';
// 获取当前活动标签页
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
const tab = tabs[0];
if (!tab || !tab.url) {
cookieDisplay.value = '无法获取当前标签页信息。';
return;
}
const url = tab.url;
// 获取该标签页下的所有cookie
chrome.cookies.getAll({url: url}, function(cookies) {
if (!cookies || cookies.length === 0) {
cookieDisplay.value = '未获取到Cookie。';
return;
}
// 格式化输出
const cookieStr = cookies.map(c => `${c.name}=${c.value}`).join('; ');
cookieDisplay.value = cookieStr;
});
});
});
// 复制Cookie功能
document.getElementById('copyBtn').addEventListener('click', async () => {
const cookieDisplay = document.getElementById('cookieDisplay');
const cookieText = cookieDisplay.value.trim();
if (!cookieText || cookieText === '请点击上方按钮提取Cookie' || cookieText === '正在提取...' || cookieText === '未获取到Cookie。' || cookieText === '无法获取当前标签页信息。') {
alert('请先提取Cookie或输入要复制的Cookie内容');
return;
}
try {
await navigator.clipboard.writeText(cookieText);
alert('Cookie已复制到剪贴板!');
} catch (err) {
// 降级方案
cookieDisplay.select();
document.execCommand('copy');
alert('Cookie已复制到剪贴板!');
}
});
// 置入CK功能
document.getElementById('injectBtn').addEventListener('click', async () => {
const cookieDisplay = document.getElementById('cookieDisplay');
const cookieText = cookieDisplay.value.trim();
if (!cookieText || cookieText === '请点击上方按钮提取Cookie' || cookieText === '正在提取...' || cookieText === '未获取到Cookie。' || cookieText === '无法获取当前标签页信息。') {
alert('请先提取Cookie或输入要置入的Cookie内容');
return;
}
// 获取当前活动标签页
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
const tab = tabs[0];
if (!tab || !tab.url) {
alert('无法获取当前标签页信息。');
return;
}
// 解析Cookie字符串
const cookiePairs = cookieText.split(';').map(pair => pair.trim());
let successCount = 0;
let totalCount = cookiePairs.length;
cookiePairs.forEach(pair => {
if (pair && pair.includes('=')) {
const [name, value] = pair.split('=', 2);
const cookieName = name.trim();
const cookieValue = value.trim();
if (cookieName && cookieValue) {
chrome.cookies.set({
url: tab.url,
name: cookieName,
value: cookieValue,
domain: new URL(tab.url).hostname
}, function(cookie) {
if (chrome.runtime.lastError) {
console.log('设置Cookie失败:', chrome.runtime.lastError.message);
} else {
successCount++;
}
// 检查是否所有Cookie都处理完毕
if (successCount + (totalCount - cookiePairs.length) === totalCount) {
if (successCount > 0) {
alert(`成功置入 ${successCount} 个Cookie!`);
} else {
alert('Cookie置入失败,请检查Cookie格式或网站权限。');
}
}
});
}
}
});
if (totalCount === 0) {
alert('Cookie格式错误,请检查输入内容。');
}
});
});
// 删除Cookie功能
document.getElementById('deleteBtn').addEventListener('click', async () => {
if (!confirm('确定要删除当前网页的所有Cookie吗?此操作不可恢复!')) {
return;
}
// 获取当前活动标签页
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
const tab = tabs[0];
if (!tab || !tab.url) {
alert('无法获取当前标签页信息。');
return;
}
const url = tab.url;
// 获取该标签页下的所有cookie
chrome.cookies.getAll({url: url}, function(cookies) {
if (!cookies || cookies.length === 0) {
alert('当前网页没有Cookie可删除。');
return;
}
let deletedCount = 0;
let totalCount = cookies.length;
cookies.forEach(cookie => {
chrome.cookies.remove({
url: url,
name: cookie.name
}, function(details) {
if (chrome.runtime.lastError) {
console.log('删除Cookie失败:', chrome.runtime.lastError.message);
} else {
deletedCount++;
}
// 检查是否所有Cookie都处理完毕
if (deletedCount + (totalCount - cookies.length) === totalCount) {
if (deletedCount > 0) {
alert(`成功删除 ${deletedCount} 个Cookie!`);
// 清空显示区域
document.getElementById('cookieDisplay').value = '';
} else {
alert('Cookie删除失败,请检查网站权限。');
}
}
});
});
});
});
}); manifest.json代码如下:
{
"manifest_version": 3,
"name": "延旭CK提取器",
"version": "1.0.0",
"description": "自动提取并显示当前网页的Cookie数据。",
"permissions": ["cookies", "activeTab", "scripting"],
"host_permissions": ["<all_urls>"],
"action": {
"default_popup": "popup.html",
"default_icon": {
"16": "logo.png",
"32": "logo.png",
"48": "logo.png",
"128": "logo.png"
}
},
"icons": {
"16": "logo.png",
"32": "logo.png",
"48": "logo.png",
"128": "logo.png"
}
} logo.PNG如下:
