-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathjson.min.js
1 lines (1 loc) · 3.24 KB
/
json.min.js
1
(()=>{var e,t,a,o={255:(e,t,a)=>{function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}var n=a(132),r=a(850);e.exports=function(e,t){e.save=function(e){var a="text/plain",s=n(),p=r(s);"json"===t.toLowerCase()?(p+=".json",a="text/json","object"===o(e)&&(e=JSON.stringify(e,void 0,4))):"md"===t.toLowerCase()&&(p+=".md");var d=new Blob([e],{type:a}),c=document.createElement("a");c.download=p,c.href=window.URL.createObjectURL(d),c.dataset.downloadurl=[a,c.download,c.href].join(":");var i=new MouseEvent("click",{canBubble:!0,cancelable:!1,view:window,detail:0,screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:null});c.dispatchEvent(i)}}},380:e=>{e.exports=function(){return new Date(new Date(new Date(new Date).toISOString()).getTime()-6e4*(new Date).getTimezoneOffset()).toISOString().slice(0,19).replace("T"," ")}},132:e=>{e.exports=function(){var e=document.getElementsByTagName("title");return e&&e.length?e[0].innerText:"ChatGPT Export"}},850:e=>{e.exports=function(e){return e.trim().toLowerCase().replace(/^[^\w\d]+|[^\w\d]+$/g,"").replace(/[\s\W-]+/g,"-")}}},n={};function r(e){var t=n[e];if(void 0!==t)return t.exports;var a=n[e]={exports:{}};return o[e](a,a.exports,r),a.exports}e=r(255),t=r(380),a=r(132),function(){for(var o={meta:{title:a(),exportedAt:t()}},n=[],r=document.querySelectorAll("[class*='min-h-[20px]']"),s=0;s<r.length;s++){var p=r[s],d={index:s},c=[],i=p.firstChild;if(i){if(i.nodeType===Node.ELEMENT_NODE){var l=i.childNodes;i.className.includes("markdown")?d.type="response":d.type="prompt",console.log("firstChild",i);for(var u=function(){var e=l[y];if(console.log("childNode",e),e.nodeType===Node.ELEMENT_NODE)switch(h=e.tagName,f=e.textContent,h){case"OL":case"UL":var t=[];e.childNodes.forEach((function(e,a){e.nodeType===Node.ELEMENT_NODE&&"LI"===e.tagName&&t.push({type:"li",data:e.textContent})})),"OL"===h&&c.push({type:"ol",data:t}),"UL"===h&&c.push({type:"ul",data:t});break;case"PRE":var a=f.split("Copy code"),o=a[0].trim(),n=a[1].trim();c.push({type:"pre",language:o,data:n});break;case"TABLE":var r=[];e.childNodes.forEach((function(e){if(e.nodeType===Node.ELEMENT_NODE&&("THEAD"===e.tagName||"TBODY"===e.tagName)){var t=[];e.childNodes.forEach((function(e){if(e.nodeType===Node.ELEMENT_NODE&&"TR"===e.tagName){var a=[];e.childNodes.forEach((function(e){e.nodeType!==Node.ELEMENT_NODE||"TD"!==e.tagName&&"TH"!==e.tagName||a.push({type:e.tagName.toLowerCase(),data:e.textContent})})),t.push({type:"tr",data:a})}})),r.push({type:e.tagName.toLowerCase(),data:t})}})),c.push({type:"table",data:r});break;case"H1":c.push({type:"h1",data:f});break;case"H2":c.push({type:"h2",data:f});break;case"H3":c.push({type:"h3",data:f});break;case"H4":c.push({type:"h4",data:f});break;case"H5":c.push({type:"h5",data:f});break;case"H6":c.push({type:"h6",data:f});break;default:c.push({type:"p",data:f})}else e.nodeType===Node.TEXT_NODE&&(f=e.textContent,c.push({type:"p",data:f}))},y=0;y<l.length;y++){var h,f;u()}}i.nodeType===Node.TEXT_NODE&&(d.type="prompt",c.push(i.textContent)),d.message=c,n.push(d)}}o.chats=n,e(console,"json"),console.save(o)}()})();