feat(browser): Cookie 备份导入——配套扩展走 chrome.cookies 官方明文通道
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
# ASO Cookie 导出助手
|
||||
|
||||
Chrome 127+ 对 Cookie 启用了应用绑定加密(app-bound encryption),浏览器外的程序(包括本应用)无法解密 Cookie 文件。Chrome 官方留给扩展的 `chrome.cookies` API 仍返回明文——这个扩展就是走这条通道,把 Cookie 导出成备份文件,再到 Inkreach Agent 里导入。
|
||||
|
||||
## 使用步骤(一次性)
|
||||
|
||||
1. 打开 Chrome,地址栏输入 `chrome://extensions/` 回车。
|
||||
2. 右上角打开「开发者模式」。
|
||||
3. 点「加载已解压的扩展程序」,选择本目录(`cookie-exporter` 文件夹)。
|
||||
4. 点浏览器工具栏里的扩展图标(拼图形状)→ 找到「ASO Cookie 导出助手」→ 点「导出全部 Cookie」,选择保存位置。
|
||||
5. 回到 Inkreach Agent:设置 → 浏览器 → 「Cookie 备份导入」→ 选择刚保存的 JSON 文件,立即生效。
|
||||
|
||||
Edge / Brave 等 Chromium 系浏览器同样适用(各自扩展页加载本目录即可)。
|
||||
|
||||
> 导出的备份文件包含明文登录凭据,用完建议删除,不要发给别人。
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "ASO Cookie 导出助手",
|
||||
"version": "1.0.0",
|
||||
"description": "把本浏览器的全部 Cookie 导出为 JSON 备份,供 Inkreach Agent 受管浏览器导入(Chrome 应用绑定加密下的官方通道)。",
|
||||
"permissions": ["cookies", "downloads"],
|
||||
"host_permissions": ["<all_urls>"],
|
||||
"action": {
|
||||
"default_popup": "popup.html"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>ASO Cookie 导出助手</title>
|
||||
<style>
|
||||
body {
|
||||
width: 280px;
|
||||
margin: 0;
|
||||
padding: 14px;
|
||||
font: 13px/1.6 system-ui, 'Segoe UI', 'Microsoft YaHei', sans-serif;
|
||||
color: #1f2328;
|
||||
background: #fff;
|
||||
}
|
||||
h1 {
|
||||
margin: 0 0 4px;
|
||||
font-size: 14px;
|
||||
}
|
||||
p {
|
||||
margin: 0 0 12px;
|
||||
color: #6b7280;
|
||||
font-size: 12px;
|
||||
}
|
||||
button {
|
||||
width: 100%;
|
||||
padding: 8px 0;
|
||||
font-size: 13px;
|
||||
color: #fff;
|
||||
background: #2563eb;
|
||||
border: 0;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
button:hover {
|
||||
background: #1d4ed8;
|
||||
}
|
||||
button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: default;
|
||||
}
|
||||
#status {
|
||||
margin-top: 10px;
|
||||
min-height: 18px;
|
||||
font-size: 12px;
|
||||
color: #374151;
|
||||
word-break: break-all;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Cookie 导出助手</h1>
|
||||
<p>导出本浏览器全部 Cookie(明文),到 Inkreach Agent 的 设置 → 浏览器 → Cookie 备份导入 里使用。</p>
|
||||
<button id="export">导出全部 Cookie</button>
|
||||
<div id="status"></div>
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,47 @@
|
||||
// 导出全部 Cookie 为 JSON 备份(chrome.cookies API 返回明文——Chrome 官方提供给扩展的通道)
|
||||
const statusEl = document.getElementById('status')
|
||||
const button = document.getElementById('export')
|
||||
|
||||
function setStatus(text) {
|
||||
statusEl.textContent = text
|
||||
}
|
||||
|
||||
button.addEventListener('click', async () => {
|
||||
button.disabled = true
|
||||
try {
|
||||
setStatus('正在读取 Cookie…')
|
||||
const cookies = await chrome.cookies.getAll({})
|
||||
if (!cookies || cookies.length === 0) {
|
||||
setStatus('未读取到任何 Cookie。')
|
||||
return
|
||||
}
|
||||
const payload = {
|
||||
format: 'aso-cookie-export',
|
||||
version: 1,
|
||||
exportedAt: new Date().toISOString(),
|
||||
cookies: cookies.map((c) => ({
|
||||
name: c.name,
|
||||
value: c.value,
|
||||
domain: c.domain,
|
||||
hostOnly: c.hostOnly === true,
|
||||
path: c.path || '/',
|
||||
secure: c.secure === true,
|
||||
httpOnly: c.httpOnly === true,
|
||||
...(typeof c.expirationDate === 'number' ? { expirationDate: c.expirationDate } : {}),
|
||||
...(c.sameSite && c.sameSite !== 'unspecified' ? { sameSite: c.sameSite } : {})
|
||||
}))
|
||||
}
|
||||
const blob = new Blob([JSON.stringify(payload)], { type: 'application/json' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const d = new Date()
|
||||
const pad = (n) => String(n).padStart(2, '0')
|
||||
const filename = `aso-cookies-${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}-${pad(d.getHours())}${pad(d.getMinutes())}.json`
|
||||
await chrome.downloads.download({ url, filename, saveAs: true })
|
||||
URL.revokeObjectURL(url)
|
||||
setStatus(`已导出 ${payload.cookies.length} 条 Cookie。回到 Inkreach Agent:设置 → 浏览器 → Cookie 备份导入,选择刚保存的文件。`)
|
||||
} catch (err) {
|
||||
setStatus('导出失败:' + (err && err.message ? err.message : String(err)))
|
||||
} finally {
|
||||
button.disabled = false
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user