javascript:(async()=>{try{const cid=location.pathname.match(/\/c\/([a-z0-9\-]+)/i)?.[1];if(!cid)return%20alert(%22Open%20a%20ChatGPT%20conversation%20first.%22);const%20sess=await%20fetch(%22/api/auth/session%22).then(r=%3Er.json()).catch(()=%3E({})),token=sess?.accessToken;if(!token)return%20alert(%22Could%20not%20get%20token.%22);const%20res=await%20fetch(`https://chatgpt.com/backend-api/conversation/${cid}`,{headers:{Authorization:%22Bearer%20%22+token,%22Content-Type%22:%22application/json%22}});if(!res.ok)throw%20new%20Error(%22Conversation%20fetch%20failed:%20%22+res.status);const%20data=await%20res.json(),queries=[],thoughtsList=[],sourcesList=[];const%20extractSources=o=%3E{if(!o||typeof%20o!==%22object%22)return;if(o.type===%22search_result_group%22&&Array.isArray(o.entries))o.entries.forEach(e=%3E{if(e?.type===%22search_result%22&&e.url&&e.title&&e.snippet)sourcesList.push({title:e.title,url:e.url,snippet:e.snippet})});for(const%20k%20in%20o)if(k!==%22entries%22)extractSources(o[k])};const%20extractDeep=o=%3E{if(!o||typeof%20o!==%22object%22)return;if(o.metadata?.search_model_queries?.queries)Array.isArray(o.metadata.search_model_queries.queries)&&o.metadata.search_model_queries.queries.forEach(q=%3Eq&&queries.push({q}));if(o.search_model_queries?.queries)Array.isArray(o.search_model_queries.queries)&&o.search_model_queries.queries.forEach(q=%3Eq&&queries.push({q}));if(Array.isArray(o.search_queries))o.search_queries.forEach(sq=%3Esq?.q&&queries.push({q:sq.q}));if(o.metadata&&Array.isArray(o.metadata.search_queries))o.metadata.search_queries.forEach(sq=%3Esq?.q&&queries.push({q:sq.q}));if(o.content_type===%22thoughts%22&&Array.isArray(o.thoughts))o.thoughts.forEach(t=%3Et?.content&&thoughtsList.push(t.content));for(const%20k%20in%20o){if(k===%22search_queries%22||k===%22metadata%22)continue;extractDeep(o[k])}if(o.metadata)for(const%20mk%20in%20o.metadata)extractDeep(o.metadata[mk])};extractSources(data);extractDeep(data);if(!queries.length&&!thoughtsList.length&&!sourcesList.length)return%20alert(%22No%20search%20queries,%20thoughts,%20or%20sources%20found.%22);const%20newTab=window.open(%22%22,%22_blank%22),doc=newTab.document;doc.write(%22%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3Ctitle%3EChatGPT%20Reasoning%20and%20Search%20Query%20Extractor%3C/title%3E%3C/head%3E%3Cbody%3E%3C/body%3E%3C/html%3E%22);doc.close();const%20style=doc.createElement(%22style%22);style.textContent=%22body{background:#1a1a1a;color:#f0f0f0;font-family:'Inter','Helvetica%20Neue',sans-serif;margin:0;padding:0;}#main-content{max-width:800px;margin:40px%20auto;padding:20px;}h1{font-size:24px;}button{margin-left:10px;padding:6px%2010px;border:none;border-radius:4px;background:#ffd54f;color:#000;font-weight:600;cursor:pointer;}button:hover{background:#ffca28;}a{color:#ffd54f;text-decoration:none;}a:hover{text-decoration:underline;}.header{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px;flex-wrap:wrap;gap:10px;}.query,.thought{margin:10px%200;padding:10px;background:#2a2a2a;border-radius:4px;}.query%20.text,.thought%20.text{display:flex;justify-content:space-between;align-items:center;gap:12px;}.toast{position:fixed;left:50%;top:28px;transform:translateX(-50%);background:#ffd54f;color:#000;padding:12px%2032px;border-radius:8px;opacity:0;box-shadow:0%204px%2024px%20#0007;transition:opacity%20.3s,transform%20.3s;z-index:2002;font-size:16px;font-weight:bold;pointer-events:none;}.toast.show{opacity:1;transform:translateX(-50%)%20scale(1.04);}.source-flex{display:flex;justify-content:space-between;align-items:flex-start;}.source-info{flex:1;min-width:0;}.source-copy{margin-left:16px;}.sources-header{display:flex;align-items:center;gap:12px;margin-top:22px;margin-bottom:8px;}#sidebar{position:fixed;top:0;right:0;width:250px;height:100vh;background:#232323;border-left:2px%20solid%20#222;display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:1001;box-shadow:-2px%200%2012px%200%20#0006;}#sidebar%20img{max-width:120px;margin-bottom:20px;}#sidebar%20.credit{font-size:14px;color:#ccc;text-align:center;line-height:1.5;padding:0%2014px;}@media%20(max-width:1000px){#sidebar{display:none;}#main-content{max-width:97vw;}}.pill{display:inline-block;background:#333;border:1px%20solid%20#444;border-radius:999px;padding:4px%2010px;font-size:12px;margin-left:8px;color:#ddd;}%22;doc.head.appendChild(style);const%20toast=doc.createElement(%22div%22);toast.className=%22toast%22;toast.id=%22toast%22;toast.textContent=%22Copied!%22;doc.body.appendChild(toast);const%20main=doc.createElement(%22div%22);main.id=%22main-content%22;doc.body.appendChild(main);const%20header=doc.createElement(%22div%22);header.className=%22header%22;const%20title=doc.createElement(%22h1%22);title.textContent=%22ChatGPT%20Reasoning%20and%20Search%20Query%20Extractor%22;const%20pill=doc.createElement(%22span%22);pill.className=%22pill%22;pill.textContent=%60Conversation:%20${cid}%60;title.appendChild(pill);const%20copyAllBtn=doc.createElement(%22button%22);copyAllBtn.textContent=%22Copy%20All%20Queries%22;copyAllBtn.onclick=()=%3EcopyText(queries.map(q=%3Eq.q).join(%22\n%22),doc);header.appendChild(title);header.appendChild(copyAllBtn);main.appendChild(header);if(queries.length){const%20h2=doc.createElement(%22h2%22);h2.textContent=%22Search%20/%20Model%20Queries%22;main.appendChild(h2);queries.forEach(q=%3E{const%20wrap=doc.createElement(%22div%22);wrap.className=%22query%22;const%20textLine=doc.createElement(%22div%22);textLine.className=%22text%22;const%20span=doc.createElement(%22span%22);span.textContent=q.q;span.style.wordBreak=%22break-word%22;const%20btn=doc.createElement(%22button%22);btn.textContent=%22Copy%22;btn.onclick=()=%3EcopyText(q.q,doc);textLine.appendChild(span);textLine.appendChild(btn);wrap.appendChild(textLine);main.appendChild(wrap)})}if(thoughtsList.length){const%20h2=doc.createElement(%22h2%22);h2.textContent=%22AI%20Reasoning%20/%20Thoughts%22;main.appendChild(h2);thoughtsList.forEach(thought=%3E{const%20wrap=doc.createElement(%22div%22);wrap.className=%22thought%22;const%20textLine=doc.createElement(%22div%22);textLine.className=%22text%22;const%20span=doc.createElement(%22span%22);span.textContent=thought;span.style.wordBreak=%22break-word%22;const%20btn=doc.createElement(%22button%22);btn.textContent=%22Copy%22;btn.onclick=()=%3EcopyText(thought,doc);textLine.appendChild(span);textLine.appendChild(btn);wrap.appendChild(textLine);main.appendChild(wrap)})}if(sourcesList.length){const%20sourcesHeader=doc.createElement(%22div%22);sourcesHeader.className=%22sources-header%22;const%20h2=doc.createElement(%22h2%22);h2.textContent=%22Sources%20Accessed%22;sourcesHeader.appendChild(h2);const%20copyAllUrlsBtn=doc.createElement(%22button%22);copyAllUrlsBtn.textContent=%22Copy%20All%20URLs%22;copyAllUrlsBtn.onclick=()=%3EcopyText(sourcesList.map(s=%3Es.url).join(%22\n%22),doc);sourcesHeader.appendChild(copyAllUrlsBtn);main.appendChild(sourcesHeader);sourcesList.forEach(source=%3E{const%20wrap=doc.createElement(%22div%22);wrap.className=%22query%22;wrap.style.background=%22#222%22;const%20flex=doc.createElement(%22div%22);flex.className=%22source-flex%22;const%20info=doc.createElement(%22div%22);info.className=%22source-info%22;const%20ttl=doc.createElement(%22div%22);ttl.style.fontWeight=%22bold%22;ttl.style.marginBottom=%223px%22;ttl.textContent=source.title;const%20url=doc.createElement(%22a%22);url.href=source.url;url.textContent=source.url;url.style.display=%22block%22;url.style.color=%22#ffd54f%22;url.style.marginBottom=%223px%22;url.style.wordBreak=%22break-all%22;url.target=%22_blank%22;const%20snippet=doc.createElement(%22div%22);snippet.textContent=source.snippet;snippet.style.fontSize=%2214px%22;snippet.style.color=%22#ccc%22;snippet.style.marginBottom=%225px%22;info.appendChild(ttl);info.appendChild(url);info.appendChild(snippet);const%20copyBtn=doc.createElement(%22button%22);copyBtn.textContent=%22Copy%20URL%22;copyBtn.className=%22source-copy%22;copyBtn.onclick=()=%3EcopyText(source.url,doc);flex.appendChild(info);flex.appendChild(copyBtn);wrap.appendChild(flex);main.appendChild(wrap)})}const%20sidebar=doc.createElement(%22div%22);sidebar.id=%22sidebar%22;const%20logo=doc.createElement(%22img%22);logo.src=%22https://theseopub.com/wp-content/uploads/2025/01/seopub-white-logo-transparent-400x335-1.png%22;logo.alt=%22The%20SEO%20Pub%20Logo%22;sidebar.appendChild(logo);const%20credit=doc.createElement(%22div%22);credit.className=%22credit%22;credit.innerHTML='Script%20by%20%3Cstrong%3EMike%20Friedman%3C/strong%3E.%3Cbr%3EFor%20more%20great%20AI%20SEO%20tools%20and%20tips%20visit%20%3Ca%20href=%22https://theseopub.com/%22%20target=%22_blank%22%20style=%22color:#ffd54f;%22%3EThe%20SEO%20Pub%3C/a%3E.';sidebar.appendChild(credit);doc.body.appendChild(sidebar);function%20copyText(text,targetDoc){const%20ta=targetDoc.createElement(%22textarea%22);ta.value=text;targetDoc.body.appendChild(ta);ta.select();try{targetDoc.execCommand(%22copy%22);showToast()}catch(e){alert(%22Clipboard%20copy%20failed.%22)}targetDoc.body.removeChild(ta)}function%20showToast(){const%20t=doc.getElementById(%22toast%22);t.classList.add(%22show%22);setTimeout(()=%3Et.classList.remove(%22show%22),2000)}}catch(e){alert(%22Failed%20to%20fetch%20data%20%E2%80%94%20are%20you%20logged%20in%20to%20ChatGPT?%22);console.error(e)}})();