没问题!我已经把针对豆包对话、精准抓取可编辑题目、纯题目文件名的代码,压缩成了一行式书签代码,你直接复制保存到浏览器书签里就能用!
最终一行式 JS 书签(直接复制)
javascript
运行
javascript:(async function(){const e=document.querySelector('h1[data-testid="chat-title"]')?.innerText||document.querySelector('div[class*="title"]')?.innerText||document.querySelector('h1')?.innerText||"豆包对话保存",t=e.trim().replace(/[\\/:*?"<>|]/g,"_").slice(0,100),n=document.createElement("div");n.style.cssText="position:fixed;top:20px;left:50%;transform:translateX(-50%);background:#000;color:#fff;padding:15px 30px;border-radius:8px;z-index:9999;font-size:16px;",n.textContent="⏳ 正在加载页面内容...",document.body.appendChild(n),window.scrollTo(0,document.body.scrollHeight),await new Promise(e=>setTimeout(e,2e3)),n.textContent="🔍 等待图片加载完成...";const o=Array.from(document.querySelectorAll("img")),a=o.length;let i=0,l=50;n.textContent=`📷 发现 ${a} 张图片,开始分批加载...`;const r=(e,t=3e4)=>new Promise(o=>{const a=setTimeout(()=>{console.warn(`⏰ 图片加载超时:${e.src}`),o(!1)},t);e.complete?(clearTimeout(a),o(!0)):(e.onload=()=>{clearTimeout(a),o(!0)},e.onerror=()=>{clearTimeout(a),o(!1)})});for(let e=0;e<o.length;e+=l){const c=o.slice(e,e+l);n.textContent=`📷 加载进度 ${Math.floor(e/l)+1}/${Math.ceil(a/l)} | 已完成 ${i}/${a}`,await Promise.all(c.map(e=>r(e))),i+=c.length}n.textContent="✅ 图片加载完成,开始生成离线文件...";let d=document.querySelector("main")||document.body;if(!d)return void(n.textContent="❌ 未找到页面主体内容",setTimeout(()=>n.remove(),3e3));const s=d.cloneNode(!0);n.textContent="🧩 正在将图片转为Base64...",i=0;const c=Array.from(s.querySelectorAll("img"));for(const e of c)try{if(!e.src)continue;const t=await fetch(e.src,{headers:{Accept:"image/*"}}),o=await t.blob(),a=await new Promise(t=>{const n=new FileReader;n.onloadend=()=>t(n.result),n.readAsDataURL(o)});e.src=a,i++,i%50==0&&(n.textContent=`🧩 图片处理中:${i}/${c.length}`)}catch(e){console.error("图片处理失败",e)}n.textContent="📄 正在生成HTML文件...";const u=document.createElement("a"),m=URL.createObjectURL(new Blob([`<!DOCTYPE html><html><head><meta charset="UTF-8"><title>${t}</title><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.css"><script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.js"></script><script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.4/dist/contrib/auto-render.min.js" onload="renderMathInElement(document.body);"></script><style>body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;max-width:800px;margin:0 auto;padding:20px;}img{max-width:100%;height:auto;}</style></head><body><h1>${t}</h1><p>保存时间:${new Date().toLocaleString()}</p><hr>${s.innerHTML}</body></html>`.trim()],{type:"text/html;charset=utf-8"}));u.href=m,u.download=`${t}.html`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(m),n.textContent="✅ 文件已生成,开始下载!",setTimeout(()=>n.remove(),3e3),console.log("✅ 离线HTML保存成功,文件名:",t)})();
使用方法
- 浏览器新建书签
- 名称填:保存豆包对话
- 网址 / URL 栏直接粘贴上面这一整行代码
- 保存
- 打开豆包对话页,点书签,自动下载 【对话题目.html】
效果
- 文件名 = 豆包可编辑的对话题目
- 无日期、无多余字符、纯题目名称
- 图片全离线、公式正常显示
- 和你原来的功能完全一致
直接用就行!🎉
