updated gitignore
This commit is contained in:
@@ -4,6 +4,7 @@ node_modules/
|
||||
|
||||
# Build output
|
||||
dist/
|
||||
dist-temp-content-chrome/
|
||||
*.js.map
|
||||
*.d.ts
|
||||
*.d.ts.map
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
(function(){"use strict";const u=[{date:new Date("2024-01-01"),model:"claude-3-sonnet-20240229"},{date:new Date("2024-06-20"),model:"claude-3-5-sonnet-20240620"},{date:new Date("2024-10-22"),model:"claude-3-5-sonnet-20241022"},{date:new Date("2025-02-29"),model:"claude-3-7-sonnet-20250219"},{date:new Date("2025-05-14"),model:"claude-sonnet-4-20250514"},{date:new Date("2025-09-29"),model:"claude-sonnet-4-5-20250929"}];function d(n){if(n.model)return n.model;const r=new Date(n.created_at);for(let e=u.length-1;e>=0;e--){const o=u[e];if(o&&r>=o.date)return o.model}return u[0]?.model}function w(n){if(!n.chat_messages||!n.current_leaf_message_uuid)return[];const r=new Map;n.chat_messages.forEach(t=>{r.set(t.uuid,t)});const e=[];let o=n.current_leaf_message_uuid;for(;o&&r.has(o);){const t=r.get(o);if(!t||(e.unshift(t),o=t.parent_message_uuid,o&&!r.has(o)))break}return e}function p(n){let r="";if(n.content)for(const e of n.content)e.text&&(r+=e.text);else n.text&&(r=n.text);return r}function h(n,r){let e=`# ${n.name||"Untitled Conversation"}
|
||||
|
||||
`;r&&(e+=`**Created:** ${new Date(n.created_at).toLocaleString()}
|
||||
`,e+=`**Updated:** ${new Date(n.updated_at).toLocaleString()}
|
||||
`,e+=`**Model:** ${d(n)}
|
||||
|
||||
`,e+=`---
|
||||
|
||||
`);const o=w(n);for(const t of o){const a=t.sender==="human"?"**You**":"**Claude**";e+=`${a}:
|
||||
|
||||
`;const s=p(t);s&&(e+=`${s}
|
||||
|
||||
`),r&&t.created_at&&(e+=`*${new Date(t.created_at).toLocaleString()}*
|
||||
|
||||
`),e+=`---
|
||||
|
||||
`}return e}function v(n,r){let e="";r&&(e+=`${n.name||"Untitled Conversation"}
|
||||
`,e+=`Created: ${new Date(n.created_at).toLocaleString()}
|
||||
`,e+=`Updated: ${new Date(n.updated_at).toLocaleString()}
|
||||
`,e+=`Model: ${d(n)}
|
||||
|
||||
`,e+=`---
|
||||
|
||||
`);const o=w(n);let t=!1,a=!1;for(const s of o){const c=p(s);let i;s.sender==="human"?(i=t?"H":"Human",t=!0):(i=a?"A":"Assistant",a=!0),e+=`${i}: ${c}
|
||||
|
||||
`}return e.trim()}function f(n,r,e="application/json"){const o=new Blob([n],{type:e}),t=URL.createObjectURL(o),a=document.createElement("a");a.href=t,a.download=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(t)}function l(n,r,e){const o=n.replace(/[^a-z0-9]/gi,"_").toLowerCase().substring(0,50),t=r==="json"?"json":r==="markdown"?"md":"txt",a=e?`_${e.substring(0,8)}`:"";return`${o}${a}.${t}`}async function $(n,r){const e=`https://claude.ai/api/organizations/${n}/chat_conversations/${r}?tree=True&rendering_mode=messages&render_all_tools=true`,o=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});if(!o.ok)throw new Error(`Failed to fetch conversation: ${o.status}`);return await o.json()}async function x(n){const r=`https://claude.ai/api/organizations/${n}/chat_conversations`,e=await fetch(r,{credentials:"include",headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch conversations: ${e.status}`);return await e.json()}async function _(n,r,e,o){console.log("Fetching conversation:",r);const t=await $(n,r);console.log("Conversation data fetched successfully:",t);const a=d(t);t.model=a;let s,c,i;switch(e){case"markdown":s=h(t,o),c=l(t.name||"untitled","markdown",t.uuid),i="text/markdown";break;case"text":s=v(t,o),c=l(t.name||"untitled","text",t.uuid),i="text/plain";break;default:s=JSON.stringify(t,null,2),c=l(t.name||"untitled","json",t.uuid),i="application/json"}console.log("Downloading file:",c),f(s,c,i)}async function k(n,r,e){const o=await x(n);if(console.log(`Fetched ${o.length} conversations`),r==="json"){const s=`claude-all-conversations-${new Date().toISOString().split("T")[0]??"export"}.json`;return console.log("Downloading all conversations as JSON:",s),f(JSON.stringify(o,null,2),s,"application/json"),{count:o.length}}let t=0;const a=[];for(const s of o)try{console.log(`Fetching full conversation ${t+1}/${o.length}: ${s.uuid}`);const c=await $(n,s.uuid);c.model=d(c);let i,m,g;r==="markdown"?(i=h(c,e),m=l(s.name||"untitled","markdown",s.uuid),g="text/markdown"):(i=v(c,e),m=l(s.name||"untitled","text",s.uuid),g="text/plain"),f(i,m,g),t++,await new Promise(C=>setTimeout(C,500))}catch(c){const i=c instanceof Error?c.message:"Unknown error";console.error(`Failed to export conversation ${s.uuid}:`,i),a.push(`${s.name||s.uuid}: ${i}`)}return a.length>0?(console.warn("Some conversations failed to export:",a),{count:t,warnings:`Exported ${t}/${o.length} conversations. Some failed: ${a.join("; ")}`}):{count:t}}chrome.runtime.onMessage.addListener((n,r)=>n.action==="exportConversation"?(console.log("Export conversation request received:",n),(async()=>{try{return await _(n.orgId,n.conversationId,n.format,n.includeMetadata),{success:!0}}catch(e){const o=e instanceof Error?e.message:"Unknown error",t=e instanceof Error?e.stack:void 0;return console.error("Export conversation error:",e),{success:!1,error:o,details:t}}})()):n.action==="exportAllConversations"?(console.log("Export all conversations request received:",n),(async()=>{try{const e=await k(n.orgId,n.format,n.includeMetadata);return{success:!0,count:e.count,warnings:e.warnings}}catch(e){const o=e instanceof Error?e.message:"Unknown error",t=e instanceof Error?e.stack:void 0;return console.error("Export all conversations error:",e),{success:!1,error:o,details:t}}})()):!1),console.log("Claude Conversation Exporter content script loaded")})();
|
||||
Reference in New Issue
Block a user