hexo-theme-solitude 1.1.0 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +56 -19
  2. package/README_EN.md +98 -0
  3. package/_config.yml +124 -124
  4. package/layout/page/about.ejs +3 -1
  5. package/layout/page/circle.ejs +1 -1
  6. package/layout/page/echarts.ejs +1 -14
  7. package/layout/page/links.ejs +1 -1
  8. package/layout/page/rss.ejs +10 -8
  9. package/layout/partial/compoment/about/award.ejs +1 -1
  10. package/layout/partial/compoment/circle/angle.ejs +1 -1
  11. package/layout/partial/compoment/circle/content.ejs +8 -8
  12. package/layout/partial/compoment/dorakika/rightmenu.ejs +1 -1
  13. package/layout/partial/compoment/inject/body.ejs +1 -3
  14. package/layout/partial/compoment/inject/head.ejs +3 -4
  15. package/layout/partial/compoment/links/angle.ejs +2 -2
  16. package/layout/partial/compoment/post/award.ejs +30 -22
  17. package/layout/partial/compoment/post/copyright.ejs +10 -8
  18. package/layout/partial/compoment/post/postMeta.ejs +11 -9
  19. package/layout/partial/footer.ejs +8 -3
  20. package/layout/partial/nav.ejs +1 -1
  21. package/layout/post.ejs +3 -3
  22. package/package.json +2 -2
  23. package/scripts/helper/charts.js +45 -34
  24. package/scripts/helper/related_post.js +10 -3
  25. package/scripts/tags/fold.js +2 -3
  26. package/scripts/tags/note.js +6 -2
  27. package/scripts/tags/tabs.js +1 -1
  28. package/source/css/main.css +24 -159
  29. package/source/img/default.png +0 -0
  30. package/source/img/logo-horizontal_version.png +0 -0
  31. package/source/img/pwa/16.png +0 -0
  32. package/source/img/pwa/180.png +0 -0
  33. package/source/img/pwa/192.png +0 -0
  34. package/source/img/pwa/32.png +0 -0
  35. package/source/img/pwa/512.png +0 -0
  36. package/source/img/pwa/logo.png +0 -0
  37. package/source/img/pwa/siteicon/splash-1125x2436.png +0 -0
  38. package/source/img/pwa/siteicon/splash-1136x640.png +0 -0
  39. package/source/img/pwa/siteicon/splash-1170x2532.png +0 -0
  40. package/source/img/pwa/siteicon/splash-1179x2556.png +0 -0
  41. package/source/img/pwa/siteicon/splash-1242x2208.png +0 -0
  42. package/source/img/pwa/siteicon/splash-1242x2688.png +0 -0
  43. package/source/img/pwa/siteicon/splash-1248x2778.png +0 -0
  44. package/source/img/pwa/siteicon/splash-1290x2796.png +0 -0
  45. package/source/img/pwa/siteicon/splash-1334x750.png +0 -0
  46. package/source/img/pwa/siteicon/splash-1536x2048.png +0 -0
  47. package/source/img/pwa/siteicon/splash-1620x2160.png +0 -0
  48. package/source/img/pwa/siteicon/splash-1668x2224.png +0 -0
  49. package/source/img/pwa/siteicon/splash-1668x2388.png +0 -0
  50. package/source/img/pwa/siteicon/splash-1792x828.png +0 -0
  51. package/source/img/pwa/siteicon/splash-2048x1536.png +0 -0
  52. package/source/img/pwa/siteicon/splash-2048x2732.png +0 -0
  53. package/source/img/pwa/siteicon/splash-2160x1620.png +0 -0
  54. package/source/img/pwa/siteicon/splash-2208x1242.png +0 -0
  55. package/source/img/pwa/siteicon/splash-2224x1668.png +0 -0
  56. package/source/img/pwa/siteicon/splash-2388x1668.png +0 -0
  57. package/source/img/pwa/siteicon/splash-2436x1125.png +0 -0
  58. package/source/img/pwa/siteicon/splash-2532x1170.png +0 -0
  59. package/source/img/pwa/siteicon/splash-2556x1179.png +0 -0
  60. package/source/img/pwa/siteicon/splash-2688x1242.png +0 -0
  61. package/source/img/pwa/siteicon/splash-2732x2048.png +0 -0
  62. package/source/img/pwa/siteicon/splash-2778x1248.png +0 -0
  63. package/source/img/pwa/siteicon/splash-2796x1290.png +0 -0
  64. package/source/img/pwa/siteicon/splash-640x1136.png +0 -0
  65. package/source/img/pwa/siteicon/splash-750x1334.png +0 -0
  66. package/source/img/pwa/siteicon/splash-828x1792.png +0 -0
  67. package/source/img/solitude-show.jpg +0 -0
  68. package/source/js/extend/covercolor/local.js +104 -94
  69. package/source/js/main.js +19 -16
  70. package/source/lib/chuckle-post-ai.js +1 -1
  71. package/scripts/filter/katex.js +0 -25
  72. package/scripts/tags/expand.js +0 -4
  73. package/scripts/tags/hide.js +0 -70
  74. package/source/js/extend/covercolor/web.js +0 -137
@@ -1 +1 @@
1
- function ChucklePostAI(t){function e(t){const e=document.querySelector(".post-ai");e&&e.parentElement.removeChild(e);const o=window.location.href;if(t.eliminate&&t.eliminate.length&&t.eliminate.some((t=>o.includes(t))))return;if(t.whitelist&&t.whitelist.length&&!t.whitelist.some((t=>o.includes(t))))return;let n="";n=!t.auto_mount&&t.el?document.querySelector(t.el?t.el:"#post #article-container"):function(){function t(e){let o=1;for(const n of e.children)o+=t(n);return o}function e(t){if(["IFRAME","FOOTER","HEADER","BLOCKQUOTE"].includes(t.tagName))return!0;const e=["aplayer","comment"];return Array.from(t.classList).some((t=>e.some((e=>t.includes(e)))))}function o(t){const o={H1:1.5,H2:1,H3:.5,P:1};let n=0,i=null;function r(t){if(e(t))return;let a=0;for(const e of t.children)e.tagName in o&&(a+=o[e.tagName]);a>n&&(n=a,i=t);for(const e of t.children)r(e)}return r(t),i}function n(){const n=[document.body];let i=0,r=null;for(;n.length>0;){const o=n.shift();if(e(o))continue;const a=t(o);a>i&&(i=a,r=o);for(const t of o.children)n.push(t)}return o(r)}return n()}();const i=document.querySelector(t.title_el)?document.querySelector(t.title_el).textContent:document.title;if(!n)return;const r={name:"ChatGPT",introduce:"我是文章辅助AI: ChatGPT,点击下方的按钮,让我生成本文简介、推荐相关文章等。",version:"GPT-4",button:["介绍自己","推荐相关文章","生成AI简介","矩阵穿梭"],...t.interface};!function(){const e="qx-ai-style";if(document.getElementById(e))return;const o=document.createElement("style");o.id=e,o.textContent=t.css||":root{--ai-font-color:#353535;--ai-post-bg:#f1f3f8;--ai-content-bg:#fff;--ai-content-border:1px solid #e3e8f7;--ai-border:1px solid #e3e8f7bd;--ai-tag-bg:rgba(48,52,63,0.80);--ai-cursor:#333;--ai-btn-bg:rgba(48,52,63,0.75);--ai-title-color:#4c4948;--ai-btn-color:#fff;--ai-speech-content:#fff;}[data-theme=dark],.theme-dark,body.dark,body.dark-theme{--ai-font-color:rgba(255,255,255,0.9);--ai-post-bg:#30343f;--ai-content-bg:#1d1e22;--ai-content-border:1px solid #42444a;--ai-border:1px solid #3d3d3f;--ai-tag-bg:#1d1e22;--ai-cursor:rgb(255,255,255,0.9);--ai-btn-bg:#1d1e22;--ai-title-color:rgba(255,255,255,0.86);--ai-btn-color:rgb(255,255,255,0.9);--ai-speech-content:#1d1e22;}#post-ai.post-ai{background:var(--ai-post-bg);border-radius:12px;padding:10px 12px 11px;line-height:1.3;border:var(--ai-border);margin-top:10px;margin-bottom:6px;transition:all 0.3s;-webkit-transition:all 0.3s;-moz-transition:all 0.3s;-ms-transition:all 0.3s;-o-transition:all 0.3s;}#post-ai .ai-title{display:flex;color:var(--ai-title-color);border-radius:8px;align-items:center;padding:0 6px;position:relative;}#post-ai .ai-title i{font-weight:800;}#post-ai .ai-title-text{font-weight:bold;margin-left:8px;font-size:17px;}#post-ai .ai-tag{font-size:12px;background-color:var(--ai-tag-bg);color:var(--ai-btn-color);border-radius:4px;margin-left:auto;line-height:1;padding:4px 5px;border:var(--ai-border);}#post-ai .ai-explanation{margin-top:10px;padding:8px 12px;background:var(--ai-content-bg);border-radius:8px;border:var(--ai-content-border);font-size:15.5px;line-height:1.4;color:var(--ai-font-color);}#post-ai .ai-cursor{display:inline-block;width:7px;background:var(--ai-cursor);height:16px;margin-bottom:-2px;opacity:0.95;margin-left:3px;transition:all 0.3s;-webkit-transition:all 0.3s;-moz-transition:all 0.3s;-ms-transition:all 0.3s;-o-transition:all 0.3s;}#post-ai .ai-btn-box{font-size:15.5px;width:100%;display:flex;flex-direction:row;flex-wrap:wrap;}#post-ai .ai-btn-item{padding:5px 10px;margin:10px 16px 0px 5px;width:fit-content;line-height:1;background:var(--ai-btn-bg);border:var(--ai-border);color:var(--ai-btn-color);border-radius:6px 6px 6px 0;-webkit-border-radius:6px 6px 6px 0;-moz-border-radius:6px 6px 6px 0;-ms-border-radius:6px 6px 6px 0;-o-border-radius:6px 6px 6px 0;user-select:none;transition:all 0.3s;-webkit-transition:all 0.3s;-moz-transition:all 0.3s;-ms-transition:all 0.3s;-o-transition:all 0.3s;cursor:pointer;}#post-ai .ai-btn-item:hover{background:#49b0f5dc;}#post-ai .ai-recommend{display:flex;flex-direction:row;flex-wrap:wrap;}#post-ai .ai-recommend-item{width:50%;margin-top:2px;}#post-ai .ai-recommend-item a{border-bottom:2px solid #4c98f7;padding:0 .2em;color:#4c98f7;font-weight:700;text-decoration:none;transition:all 0.3s;-webkit-transition:all 0.3s;-moz-transition:all 0.3s;-ms-transition:all 0.3s;-o-transition:all 0.3s;}#post-ai .ai-recommend-item a:hover{background-color:#49b1f5;border-bottom:2px solid #49b1f5;color:#fff;border-radius:5px;}@media screen and (max-width:768px){#post-ai .ai-btn-box{justify-content:center;}}#post-ai .ai-title>svg{width:21px;height:fit-content;}#post-ai .ai-title>svg path{fill:var(--ai-font-color);}#post-ai .ai-Toggle{font-size:12px;border:var(--ai-border);background:var(--ai-btn-bg);color:var(--ai-btn-color);padding:3px 4px;border-radius:4px;margin-left:6px;cursor:pointer;-webkit-transition:.3s;-moz-transition:.3s;-o-transition:.3s;-ms-transition:.3s;transition:.3s;font-weight:bolder;pointer-events:none;opacity:0;}#post-ai .ai-Toggle:hover{background:#49b0f5dc;}#post-ai .ai-speech-box{width:21px;height:21px;background:var(--ai-font-color);margin-left:7px;border-radius:50%;display:flex;flex-direction:row;flex-wrap:wrap;align-content:center;justify-content:center;pointer-events:none;opacity:0;-webkit-transition:.3s;-moz-transition:.3s;-o-transition:.3s;-ms-transition:.3s;transition:.3s;cursor:pointer;}#post-ai .ai-speech-content{width:8px;background:var(--ai-speech-content);height:8px;border-radius:50%;-webkit-transition:.3s;-moz-transition:.3s;-o-transition:.3s;-ms-transition:.3s;transition:.3s;}#post-ai .ai-speech-box:hover .ai-speech-content{background:#49b0f5;}@keyframes ai_breathe{0%{transform:scale(0.9);-webkit-transform:scale(0.9);-moz-transform:scale(0.9);-ms-transform:scale(0.9);-o-transform:scale(0.9);}50%{transform:scale(1);-webkit-transform:scale(1);-moz-transform:scale(1);-ms-transform:scale(1);-o-transform:scale(1);}}",t.additional_css&&(o.textContent+=t.additional_css),document.head.appendChild(o)}();const a=document.createElement("div");a.className="post-ai",a.setAttribute("id","post-ai"),n.insertBefore(a,n.firstChild),a.innerHTML=`<div class="ai-title">\n <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="21px" height="21px" viewBox="0 0 48 48">\n <g id="&#x673A;&#x5668;&#x4EBA;" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><path d="M34.717885,5.03561087 C36.12744,5.27055371 37.079755,6.60373651 36.84481,8.0132786 L35.7944,14.3153359 L38.375,14.3153359 C43.138415,14.3153359 47,18.1768855 47,22.9402569 L47,34.4401516 C47,39.203523 43.138415,43.0650727 38.375,43.0650727 L9.625,43.0650727 C4.861585,43.0650727 1,39.203523 1,34.4401516 L1,22.9402569 C1,18.1768855 4.861585,14.3153359 9.625,14.3153359 L12.2056,14.3153359 L11.15519,8.0132786 C10.920245,6.60373651 11.87256,5.27055371 13.282115,5.03561087 C14.69167,4.80066802 16.024865,5.7529743 16.25981,7.16251639 L17.40981,14.0624532 C17.423955,14.1470924 17.43373,14.2315017 17.43948,14.3153359 L30.56052,14.3153359 C30.56627,14.2313867 30.576045,14.1470924 30.59019,14.0624532 L31.74019,7.16251639 C31.975135,5.7529743 33.30833,4.80066802 34.717885,5.03561087 Z M38.375,19.4902885 L9.625,19.4902885 C7.719565,19.4902885 6.175,21.0348394 6.175,22.9402569 L6.175,34.4401516 C6.175,36.3455692 7.719565,37.89012 9.625,37.89012 L38.375,37.89012 C40.280435,37.89012 41.825,36.3455692 41.825,34.4401516 L41.825,22.9402569 C41.825,21.0348394 40.280435,19.4902885 38.375,19.4902885 Z M14.8575,23.802749 C16.28649,23.802749 17.445,24.9612484 17.445,26.3902253 L17.445,28.6902043 C17.445,30.1191812 16.28649,31.2776806 14.8575,31.2776806 C13.42851,31.2776806 12.27,30.1191812 12.27,28.6902043 L12.27,26.3902253 C12.27,24.9612484 13.42851,23.802749 14.8575,23.802749 Z M33.1425,23.802749 C34.57149,23.802749 35.73,24.9612484 35.73,26.3902253 L35.73,28.6902043 C35.73,30.1191812 34.57149,31.2776806 33.1425,31.2776806 C31.71351,31.2776806 30.555,30.1191812 30.555,28.6902043 L30.555,26.3902253 C30.555,24.9612484 31.71351,23.802749 33.1425,23.802749 Z" id="&#x5F62;&#x72B6;&#x7ED3;&#x5408;" fill="#444444" fill-rule="nonzero"></path></g></svg>\n <div class="ai-title-text">${r.name}</div>\n <div class="ai-Toggle">切换简介</div>\n <div class="ai-speech-box">\n <div class="ai-speech-content"></div>\n </div>\n <div class="ai-tag">${r.version}</div>\n </div>\n <div class="ai-explanation">${r.name}初始化中...</div>\n <div class="ai-btn-box">\n <div class="ai-btn-item">${r.button[0]}</div>\n <div class="ai-btn-item">${r.button[1]}</div>\n <div class="ai-btn-item">${r.button[2]}</div>\n <div class="ai-btn-item">${r.button[3]}</div>\n </div>`;let s=!0,l=document.querySelector(".ai-explanation"),c=document.querySelector(".post-ai"),d=document.querySelectorAll(".ai-btn-item"),m=document.querySelector(".ai-Toggle"),p=document.querySelector(".ai-speech-box"),u="",f="",g=600,h=0,b=0,y=t.speed||20,x=7.5*y,w=[],v=0,S=!1,k=new AbortController,E=k.signal,C="",I="";const L=t.summary_toggle??!0,T=t.summary_speech??!0;let A=0,$=!1,N="",O="",_=!1;const q=t.summary_num||3,j=!0,z="填入chatGPT的apiKey",P=`https://${window.location.host}/`,M=t.key?t.key:"123456",R=t=>{if(s)if(R.start||(R.start=t),v=t-R.start,v>=y){if(R.start=t,h<f-1){let t=u.charAt(h+1),e=/[,.,。!?!?]/.test(t)?x:y;l.firstElementChild&&l.removeChild(l.firstElementChild),l.innerHTML+=t;let o=document.createElement("div");o.className="ai-cursor",l.appendChild(o),h++,e===x&&(document.querySelector(".ai-explanation .ai-cursor").style.opacity="0"),h===f-1&&(G.disconnect(),l.removeChild(l.firstElementChild)),w[0]=setTimeout((()=>{requestAnimationFrame(R)}),e)}}else requestAnimationFrame(R)},G=new IntersectionObserver((t=>{let e=t[0].isIntersecting;s=e,s&&(g=0===h?200:20,w[1]=setTimeout((()=>{b&&(h=0,b=0),0===h&&(l.innerHTML=u.charAt(0)),requestAnimationFrame(R)}),g))}),{threshold:0});function H(t=!0,e="生成中. . ."){h=0,b=1,w.length&&w.forEach((t=>{t&&clearTimeout(t)})),s=!1,v=0,l.innerHTML=t?e:"请等待. . .",S||k.abort(),u="",f="",L&&(m.style.opacity="0",m.style.pointerEvents="none"),T&&(Z(),p.style.opacity="0",p.style.pointerEvents="none"),G.disconnect()}function J(e,o=!0){t.hasOwnProperty("typewriter")&&!t.typewriter?l.innerHTML=e:(H(o),u=e,f=u.length,G.observe(c))}function B(){J(r.introduce)}function F(){H(),w[2]=setTimeout((async()=>{let e=await async function(){S=!1,k=new AbortController,E=k.signal;let e="",o="",n="";const i={signal:E,method:"GET",headers:{"content-type":"application/x-www-form-urlencoded"}};if(sessionStorage.getItem("recommendList"))n=JSON.parse(sessionStorage.getItem("recommendList"));else{try{if(e=await fetch(`https://summary.tianli0.top/recommends?url=${encodeURIComponent(window.location.href)}&author=${t.rec_method?t.rec_method:"all"}`,i),S=!0,429===e.status&&J("请求过于频繁,请稍后再请求AI。"),!e.ok)throw new Error("Response not ok")}catch(t){return"AbortError"===t.name||(console.error("Error occurred:",t),J("获取推荐出错了,请稍后再试。")),S=!0,!1}n=await e.json(),sessionStorage.setItem("recommendList",JSON.stringify(n))}if(n.hasOwnProperty("success")&&!n.success)return!1;o="推荐文章:<br />",o+='<div class="ai-recommend">',n.forEach(((t,e)=>{o+=`<div class="ai-recommend-item"><span>推荐${e+1}:</span><a target="_blank" href="${t.url}" title="${t.title?t.title:"未获取到题目"}">${t.title?t.title:"未获取到题目"}</a></div>`})),o+="</div>";return o}();""===e||!1===e?J(`${r.name}未能找到任何可推荐的文章。`):e&&(l.innerHTML=e)}),200)}async function U(){H();const t=Y(n),e=await tt(t,j);e&&(J(e.summary),L&&(m.style.opacity="1",m.style.pointerEvents="auto",K()))}async function D(){H(!0,"矩阵穿梭中. . ."),S=!1,k=new AbortController,E=k.signal;let t="",e="";const o={signal:E,method:"GET",headers:{"content-type":"application/x-www-form-urlencoded"}};if(sessionStorage.getItem("matrixShuttle"))e=JSON.parse(sessionStorage.getItem("matrixShuttle"));else{try{if(t=await fetch("https://summary.tianli0.top/websites_used",o),S=!0,429===t.status&&J("请求过于频繁,请稍后再请求AI。"),!t.ok)throw new Error("Response not ok")}catch(t){return"AbortError"===t.name||(console.error("Error occurred:",t),J("矩阵穿梭失败了,请稍后再试。")),S=!0,!1}e=await t.json(),sessionStorage.setItem("matrixShuttle",JSON.stringify(e))}const n=function(t){if(0===t.length)return null;const e=function(t){const e=new Uint32Array(1);return window.crypto.getRandomValues(e),e[0]%t}(t.length);return t[e]}(e.websites);n?(J(`正在前往 ${n} ,已有 ${e.count} 个网站接入AI摘要。`),w[2]=setTimeout((()=>{window.open(`https://${n}`,"_blank")}),100*y)):J("没有可以穿梭的网站。")}function Z(t=!1){T&&(N&&(N.pause(),N.remove()),N=null,p.style.opacity="1",p.style.animation="",t&&(O=null))}function K(){T&&(p.style.opacity="1",p.style.animation="",p.style.pointerEvents="auto")}async function Q(e){if(!T)return;const o=URL.createObjectURL(e);if(N=new Audio(o),N.play(),t.pjax){function n(){N.pause(),N.remove(),document.removeEventListener("pjax:complete",n)}document.removeEventListener("pjax:complete",n),document.addEventListener("pjax:complete",n)}p.style.opacity="0.4",p.style.animation="ai_breathe .7s linear infinite",N.removeEventListener("ended",V),N.addEventListener("ended",V)}function V(){Z()}function X(e){const o=t.exclude?t.exclude:["highlight","Copyright-Notice","post-ai","post-series","mini-sandbox"];o.includes("post-ai")||o.push("post-ai");const n=["script","style","iframe","embed","video","audio","source","canvas","img","svg","hr","input","form"];let i="";for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE)i+=t.textContent.trim();else if(t.nodeType===Node.ELEMENT_NODE){let e=!1;for(let n of t.classList)if(o.includes(n)){e=!0;break}let r=n.includes(t.tagName.toLowerCase());if(!e&&!r){i+=X(t)}}return i.replace(/\s+/g,"")}function W(t){const e=t.querySelectorAll("h1, h2, h3, h4"),o=[];for(let t=0;t<e.length;t++){const n=e[t],i=n.textContent.trim();o.push(i);const r=W(n);o.push(...r)}return o.join(";")}function Y(e,o=!0){let n;if(o){const o=t.total_length||1e3,i=t.ratio_string||"5:3:2";n=`文章的各级标题:${W(e)}。文章内容的截取:${function(t,e=1e3,o="5:3:2"){if(e=Math.min(e,5e3),t.length<=e)return t;const n=o.split(":").map(Number),i=n.reduce(((t,e)=>t+e),0),r=Math.min(t.length,e),a=n.map((t=>Math.floor(r*t/i))),s=t.substring(0,a[0]),l=(t.length-300)/2;return s+t.substring(l,l+a[1])+t.substring(t.length-a[2])}(X(e),o,i)}`}else n=`${X(e)}`;return n}async function tt(t,e=!0){if(!M)return"没有获取到key,代码可能没有安装正确,详细请查看文档。";if("123456"===M)return"请购买 key 使用,如果你能看到此条内容,则说明代码安装正确。";S=!1,k=new AbortController,E=k.signal;let o="";if(sessionStorage.getItem("summary"))return JSON.parse(sessionStorage.getItem("summary"));if(e){try{if(o=await fetch("https://summary.tianli0.top/",{signal:E,method:"POST",headers:{"Content-Type":"application/json",Referer:P},body:JSON.stringify({content:t,key:M,title:i,url:window.location.href,user_openid:C})}),S=!0,429===o.status&&J("请求过于频繁,请稍后再请求AI。"),!o.ok)throw new Error("Response not ok")}catch(t){return"AbortError"===t.name||("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname?J(`${r.name}请求tianliGPT出错了,你正在本地进行调试,请前往summary.zhheo.com添加本地域名(127.0.0.1:端口)的白名单。`):J(`${r.name}请求tianliGPT出错了,请稍后再试。`)),S=!0,""}const e=await o.json();return I=e.id,sessionStorage.setItem("summary",JSON.stringify(e)),Z(!0),e}{const e=`你是一个摘要生成工具,你需要解释我发送给你的内容,不要换行,不要超过200字,只需要介绍文章的内容,不需要提出建议和缺少的东西。请用中文回答,文章内容为:${t}`,n="https://api.openai.com/v1/chat/completions";try{if(o=await fetch(n,{signal:E,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify({model:"gpt-3.5-turbo",messages:[{role:"user",content:e}]})}),S=!0,429===o.status&&J("请求过于频繁,请稍后再请求AI。"),!o.ok)throw new Error("Response not ok")}catch(t){return console.error("Error occurred:",t),J(`${r.name}请求chatGPT出错了,请稍后再试。`),S=!0,""}const i=(await o.json()).choices[0].message.content;return sessionStorage.setItem("summary",i),i}}!async function(){sessionStorage.removeItem("recommendList"),sessionStorage.removeItem("backupsSummary");for(let t=0;t<q;t++)sessionStorage.removeItem(`summary${"#".repeat(t)}`);l=document.querySelector(".ai-explanation"),c=document.querySelector(".post-ai"),d=document.querySelectorAll(".ai-btn-item");const e=[B,F,U,D];d.forEach(((o,n)=>{t.hide_shuttle&&n===d.length-1?o.style.display="none":o.addEventListener("click",(()=>{e[n]()}))})),m=document.querySelector(".ai-Toggle"),L?m.addEventListener("click",(()=>{!async function(){H(),O=null,A=(A+1)%q;const t=Y(n)+"#".repeat(A);let e="";1!==A||$||(sessionStorage.setItem("backupsSummary",sessionStorage.getItem("summary")),$=!0),sessionStorage.getItem(`summary${"#".repeat(A)}`)?(e=JSON.parse(sessionStorage.getItem(`summary${"#".repeat(A)}`)),I=e.id,0===A?sessionStorage.setItem("summary",sessionStorage.getItem("backupsSummary")):sessionStorage.setItem("summary",sessionStorage.getItem(`summary${"#".repeat(A)}`))):(sessionStorage.removeItem("summary"),e=await tt(t,j),e&&sessionStorage.setItem(`summary${"#".repeat(A)}`,JSON.stringify(e))),e&&(J(e.summary),m.style.opacity="1",m.style.pointerEvents="auto",K())}()})):m.style.display="none",p=document.querySelector(".ai-speech-box"),T?p.addEventListener("click",(()=>{!async function(){if(!I)return;let t="";if(!O||N)if(N&&N)_?(_=!1,N.play(),p.style.opacity="0.4",p.style.animation="ai_breathe .7s linear infinite"):(_=!0,N.pause(),p.style.opacity="1",p.style.animation="");else{const e={method:"GET",headers:{"Content-Type":"application/json",Referer:P}},o=new URLSearchParams({key:M,id:I});try{p.style.pointerEvents="none",p.style.opacity="0.4",t=await fetch(`https://summary.tianli0.top/audio?${o}`,e),403===t.status?console.error("403 refer与key不匹配。"):500===t.status?console.error("500 系统内部错误"):(O=await t.blob(),p.style.pointerEvents="auto",await Q(O))}catch(t){console.log("摘要语音请求出错:",t),p.style.opacity="1",p.style.pointerEvents="auto"}}else await Q(O)}()})):p.style.display="none",t.summary_directly?U():B(),C=localStorage.getItem("visitorId")||await async function(){try{const t=await import("https://openfpcdn.io/fingerprintjs/v4"),e=await t.default.load(),o=(await e.get()).visitorId;return localStorage.setItem("visitorId",o),o}catch(t){return console.error("生成ID失败"),null}}()}()}e(t),t.pjax&&document.addEventListener("pjax:complete",(()=>{setTimeout((()=>{e(t)}),0)}))}window.hasOwnProperty("aiExecuted")||(console.log("%cPost-Summary-AI 文章摘要AI生成工具:%chttps://github.com/qxchuckle/Post-Summary-AI%c","border:1px #888 solid;border-right:0;border-radius:5px 0 0 5px;padding: 5px 10px;color:white;background:#4976f5;margin:10px 0","border:1px #888 solid;border-left:0;border-radius:0 5px 5px 0;padding: 5px 10px;",""),window.aiExecuted="chuckle");
1
+ function ChucklePostAI(t){function e(t){const e=document.querySelector(".post-ai");e&&e.parentElement.removeChild(e);const o=window.location.href;if(t.eliminate&&t.eliminate.length&&t.eliminate.some((t=>o.includes(t))))return;if(t.whitelist&&t.whitelist.length&&!t.whitelist.some((t=>o.includes(t))))return;let n="";n=!t.auto_mount&&t.el?document.querySelector(t.el?t.el:"#post #article-container"):function(){function t(e){let o=1;for(const n of e.children)o+=t(n);return o}function e(t){if(["IFRAME","FOOTER","HEADER","BLOCKQUOTE"].includes(t.tagName))return!0;const e=["aplayer","comment"];return Array.from(t.classList).some((t=>e.some((e=>t.includes(e)))))}function o(t){const o={H1:1.5,H2:1,H3:.5,P:1};let n=0,i=null;function r(t){if(e(t))return;let a=0;for(const e of t.children)e.tagName in o&&(a+=o[e.tagName]);a>n&&(n=a,i=t);for(const e of t.children)r(e)}return r(t),i}function n(){const n=[document.body];let i=0,r=null;for(;n.length>0;){const o=n.shift();if(e(o))continue;const a=t(o);a>i&&(i=a,r=o);for(const t of o.children)n.push(t)}return o(r)}return n()}();const i=document.querySelector(t.title_el)?document.querySelector(t.title_el).textContent:document.title;if(!n)return;const r={name:"ChatGPT",introduce:"我是OpenAI的人工智能助手,名为ChatGPT。我是一个大型语言模型,可以理解和生成人类语言。我不是一个真实的人,我没有情感,也没有个人经历,我只是一个计算机程序。点击下方的按钮,让我生成本文简介、推荐相关文章等。",version:"GPT-4",button:["介绍自己","推荐相关文章","生成AI简介","矩阵穿梭"],...t.interface};!function(){const e="qx-ai-style";if(document.getElementById(e))return;const o=document.createElement("style");o.id=e,o.textContent=t.css||":root{--ai-font-color:#353535;--ai-post-bg:#f1f3f8;--ai-content-bg:#fff;--ai-content-border:1px solid #e3e8f7;--ai-border:1px solid #e3e8f7bd;--ai-tag-bg:rgba(48,52,63,0.80);--ai-cursor:#333;--ai-btn-bg:rgba(48,52,63,0.75);--ai-title-color:#4c4948;--ai-btn-color:#fff;--ai-speech-content:#fff;}[data-theme=dark],.theme-dark,body.dark,body.dark-theme{--ai-font-color:rgba(255,255,255,0.9);--ai-post-bg:#30343f;--ai-content-bg:#1d1e22;--ai-content-border:1px solid #42444a;--ai-border:1px solid #3d3d3f;--ai-tag-bg:#1d1e22;--ai-cursor:rgb(255,255,255,0.9);--ai-btn-bg:#1d1e22;--ai-title-color:rgba(255,255,255,0.86);--ai-btn-color:rgb(255,255,255,0.9);--ai-speech-content:#1d1e22;}#post-ai.post-ai{background:var(--ai-post-bg);border-radius:12px;padding:10px 12px 11px;line-height:1.3;border:var(--ai-border);margin-top:10px;margin-bottom:6px;transition:all 0.3s;-webkit-transition:all 0.3s;-moz-transition:all 0.3s;-ms-transition:all 0.3s;-o-transition:all 0.3s;}#post-ai .ai-title{display:flex;color:var(--ai-title-color);border-radius:8px;align-items:center;padding:0 6px;position:relative;}#post-ai .ai-title i{font-weight:800;}#post-ai .ai-title-text{font-weight:bold;margin-left:8px;font-size:17px;}#post-ai .ai-tag{font-size:12px;background-color:var(--ai-tag-bg);color:var(--ai-btn-color);border-radius:4px;margin-left:auto;line-height:1;padding:4px 5px;border:var(--ai-border);}#post-ai .ai-explanation{margin-top:10px;padding:8px 12px;background:var(--ai-content-bg);border-radius:8px;border:var(--ai-content-border);font-size:15.5px;line-height:1.4;color:var(--ai-font-color);}#post-ai .ai-cursor{display:inline-block;width:7px;background:var(--ai-cursor);height:16px;margin-bottom:-2px;opacity:0.95;margin-left:3px;transition:all 0.3s;-webkit-transition:all 0.3s;-moz-transition:all 0.3s;-ms-transition:all 0.3s;-o-transition:all 0.3s;}#post-ai .ai-btn-box{font-size:15.5px;width:100%;display:flex;flex-direction:row;flex-wrap:wrap;}#post-ai .ai-btn-item{padding:5px 10px;margin:10px 16px 0px 5px;width:fit-content;line-height:1;background:var(--ai-btn-bg);border:var(--ai-border);color:var(--ai-btn-color);border-radius:6px 6px 6px 0;-webkit-border-radius:6px 6px 6px 0;-moz-border-radius:6px 6px 6px 0;-ms-border-radius:6px 6px 6px 0;-o-border-radius:6px 6px 6px 0;user-select:none;transition:all 0.3s;-webkit-transition:all 0.3s;-moz-transition:all 0.3s;-ms-transition:all 0.3s;-o-transition:all 0.3s;cursor:pointer;}#post-ai .ai-btn-item:hover{background:#49b0f5dc;}#post-ai .ai-recommend{display:flex;flex-direction:row;flex-wrap:wrap;}#post-ai .ai-recommend-item{width:50%;margin-top:2px;}#post-ai .ai-recommend-item a{border-bottom:2px solid #4c98f7;padding:0 .2em;color:#4c98f7;font-weight:700;text-decoration:none;transition:all 0.3s;-webkit-transition:all 0.3s;-moz-transition:all 0.3s;-ms-transition:all 0.3s;-o-transition:all 0.3s;}#post-ai .ai-recommend-item a:hover{background-color:#49b1f5;border-bottom:2px solid #49b1f5;color:#fff;border-radius:5px;}@media screen and (max-width:768px){#post-ai .ai-btn-box{justify-content:center;}}#post-ai .ai-title>svg{width:21px;height:21px;}#post-ai .ai-title>svg path{fill:var(--ai-font-color);}#post-ai .ai-Toggle{font-size:12px;border:var(--ai-border);background:var(--ai-btn-bg);color:var(--ai-btn-color);padding:3px 4px;border-radius:4px;margin-left:6px;cursor:pointer;-webkit-transition:.3s;-moz-transition:.3s;-o-transition:.3s;-ms-transition:.3s;transition:.3s;font-weight:bolder;pointer-events:none;opacity:0;}#post-ai .ai-Toggle:hover{background:#49b0f5dc;}#post-ai .ai-speech-box{width:21px;height:21px;background:var(--ai-font-color);margin-left:7px;border-radius:50%;display:flex;flex-direction:row;flex-wrap:wrap;align-content:center;justify-content:center;pointer-events:none;opacity:0;-webkit-transition:.3s;-moz-transition:.3s;-o-transition:.3s;-ms-transition:.3s;transition:.3s;cursor:pointer;}#post-ai .ai-speech-content{width:8px;background:var(--ai-speech-content);height:8px;border-radius:50%;-webkit-transition:.3s;-moz-transition:.3s;-o-transition:.3s;-ms-transition:.3s;transition:.3s;}#post-ai .ai-speech-box:hover .ai-speech-content{background:#49b0f5;}@keyframes ai_breathe{0%{transform:scale(0.9);-webkit-transform:scale(0.9);-moz-transform:scale(0.9);-ms-transform:scale(0.9);-o-transform:scale(0.9);}50%{transform:scale(1);-webkit-transform:scale(1);-moz-transform:scale(1);-ms-transform:scale(1);-o-transform:scale(1);}}",t.additional_css&&(o.textContent+=t.additional_css),document.head.appendChild(o)}();const a=document.createElement("div");a.className="post-ai",a.setAttribute("id","post-ai"),n.insertBefore(a,n.firstChild),a.innerHTML=`<div class="ai-title">\n <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="21px" height="21px" viewBox="0 0 48 48">\n <g id="&#x673A;&#x5668;&#x4EBA;" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><path d="M34.717885,5.03561087 C36.12744,5.27055371 37.079755,6.60373651 36.84481,8.0132786 L35.7944,14.3153359 L38.375,14.3153359 C43.138415,14.3153359 47,18.1768855 47,22.9402569 L47,34.4401516 C47,39.203523 43.138415,43.0650727 38.375,43.0650727 L9.625,43.0650727 C4.861585,43.0650727 1,39.203523 1,34.4401516 L1,22.9402569 C1,18.1768855 4.861585,14.3153359 9.625,14.3153359 L12.2056,14.3153359 L11.15519,8.0132786 C10.920245,6.60373651 11.87256,5.27055371 13.282115,5.03561087 C14.69167,4.80066802 16.024865,5.7529743 16.25981,7.16251639 L17.40981,14.0624532 C17.423955,14.1470924 17.43373,14.2315017 17.43948,14.3153359 L30.56052,14.3153359 C30.56627,14.2313867 30.576045,14.1470924 30.59019,14.0624532 L31.74019,7.16251639 C31.975135,5.7529743 33.30833,4.80066802 34.717885,5.03561087 Z M38.375,19.4902885 L9.625,19.4902885 C7.719565,19.4902885 6.175,21.0348394 6.175,22.9402569 L6.175,34.4401516 C6.175,36.3455692 7.719565,37.89012 9.625,37.89012 L38.375,37.89012 C40.280435,37.89012 41.825,36.3455692 41.825,34.4401516 L41.825,22.9402569 C41.825,21.0348394 40.280435,19.4902885 38.375,19.4902885 Z M14.8575,23.802749 C16.28649,23.802749 17.445,24.9612484 17.445,26.3902253 L17.445,28.6902043 C17.445,30.1191812 16.28649,31.2776806 14.8575,31.2776806 C13.42851,31.2776806 12.27,30.1191812 12.27,28.6902043 L12.27,26.3902253 C12.27,24.9612484 13.42851,23.802749 14.8575,23.802749 Z M33.1425,23.802749 C34.57149,23.802749 35.73,24.9612484 35.73,26.3902253 L35.73,28.6902043 C35.73,30.1191812 34.57149,31.2776806 33.1425,31.2776806 C31.71351,31.2776806 30.555,30.1191812 30.555,28.6902043 L30.555,26.3902253 C30.555,24.9612484 31.71351,23.802749 33.1425,23.802749 Z" id="&#x5F62;&#x72B6;&#x7ED3;&#x5408;" fill="#444444" fill-rule="nonzero"></path></g></svg>\n <div class="ai-title-text">${r.name}</div>\n <div class="ai-Toggle">切换简介</div>\n <div class="ai-speech-box">\n <div class="ai-speech-content"></div>\n </div>\n <div class="ai-tag">${r.version}</div>\n </div>\n <div class="ai-explanation">${r.name}初始化中...</div>\n <div class="ai-btn-box">\n <div class="ai-btn-item">${r.button[0]}</div>\n <div class="ai-btn-item">${r.button[1]}</div>\n <div class="ai-btn-item">${r.button[2]}</div>\n <div class="ai-btn-item">${r.button[3]}</div>\n </div>`;let s=!0,l=document.querySelector(".ai-explanation"),c=document.querySelector(".post-ai"),d=document.querySelectorAll(".ai-btn-item"),m=document.querySelector(".ai-Toggle"),p=document.querySelector(".ai-speech-box"),u="",f="",g=600,h=0,b=0,y=t.speed||20,x=7.5*y,w=[],v=0,S=!1,k=new AbortController,E=k.signal,C="",I="";const L=t.summary_toggle??!0,T=t.summary_speech??!0;let A=0,$=!1,N="",O="",_=!1;const q=t.summary_num||3,j=!0,z="填入chatGPT的apiKey",P=`https://${window.location.host}/`,M=t.key?t.key:"123456",R=t=>{if(s)if(R.start||(R.start=t),v=t-R.start,v>=y){if(R.start=t,h<f-1){let t=u.charAt(h+1),e=/[,.,。!?!?]/.test(t)?x:y;l.firstElementChild&&l.removeChild(l.firstElementChild),l.innerHTML+=t;let o=document.createElement("div");o.className="ai-cursor",l.appendChild(o),h++,e===x&&(document.querySelector(".ai-explanation .ai-cursor").style.opacity="0"),h===f-1&&(G.disconnect(),l.removeChild(l.firstElementChild)),w[0]=setTimeout((()=>{requestAnimationFrame(R)}),e)}}else requestAnimationFrame(R)},G=new IntersectionObserver((t=>{let e=t[0].isIntersecting;s=e,s&&(g=0===h?200:20,w[1]=setTimeout((()=>{b&&(h=0,b=0),0===h&&(l.innerHTML=u.charAt(0)),requestAnimationFrame(R)}),g))}),{threshold:0});function H(t=!0,e="生成中. . ."){h=0,b=1,w.length&&w.forEach((t=>{t&&clearTimeout(t)})),s=!1,v=0,l.innerHTML=t?e:"请等待. . .",S||k.abort(),u="",f="",L&&(m.style.opacity="0",m.style.pointerEvents="none"),T&&(Z(),p.style.opacity="0",p.style.pointerEvents="none"),G.disconnect()}function J(e,o=!0){t.hasOwnProperty("typewriter")&&!t.typewriter?l.innerHTML=e:(H(o),u=e,f=u.length,G.observe(c))}function B(){J(r.introduce)}function F(){H(),w[2]=setTimeout((async()=>{let e=await async function(){S=!1,k=new AbortController,E=k.signal;let e="",o="",n="";const i={signal:E,method:"GET",headers:{"content-type":"application/x-www-form-urlencoded"}};if(sessionStorage.getItem("recommendList"))n=JSON.parse(sessionStorage.getItem("recommendList"));else{try{if(e=await fetch(`https://summary.tianli0.top/recommends?url=${encodeURIComponent(window.location.href)}&author=${t.rec_method?t.rec_method:"all"}`,i),S=!0,429===e.status&&J("请求过于频繁,请稍后再请求AI。"),!e.ok)throw new Error("Response not ok")}catch(t){return"AbortError"===t.name||(console.error("Error occurred:",t),J("获取推荐出错了,请稍后再试。")),S=!0,!1}n=await e.json(),sessionStorage.setItem("recommendList",JSON.stringify(n))}if(n.hasOwnProperty("success")&&!n.success)return!1;o="推荐文章:<br />",o+='<div class="ai-recommend">',n.forEach(((t,e)=>{o+=`<div class="ai-recommend-item"><span>推荐${e+1}:</span><a target="_blank" href="${t.url}" title="${t.title?t.title:"未获取到题目"}">${t.title?t.title:"未获取到题目"}</a></div>`})),o+="</div>";return o}();""===e||!1===e?J(`${r.name}未能找到任何可推荐的文章。`):e&&(l.innerHTML=e)}),200)}async function U(){H();const t=Y(n),e=await tt(t,j);e&&(J(e.summary),L&&(m.style.opacity="1",m.style.pointerEvents="auto",K()))}async function D(){H(!0,"矩阵穿梭中. . ."),S=!1,k=new AbortController,E=k.signal;let t="",e="";const o={signal:E,method:"GET",headers:{"content-type":"application/x-www-form-urlencoded"}};if(sessionStorage.getItem("matrixShuttle"))e=JSON.parse(sessionStorage.getItem("matrixShuttle"));else{try{if(t=await fetch("https://summary.tianli0.top/websites_used",o),S=!0,429===t.status&&J("请求过于频繁,请稍后再请求AI。"),!t.ok)throw new Error("Response not ok")}catch(t){return"AbortError"===t.name||(console.error("Error occurred:",t),J("矩阵穿梭失败了,请稍后再试。")),S=!0,!1}e=await t.json(),sessionStorage.setItem("matrixShuttle",JSON.stringify(e))}const n=function(t){if(0===t.length)return null;const e=function(t){const e=new Uint32Array(1);return window.crypto.getRandomValues(e),e[0]%t}(t.length);return t[e]}(e.websites);n?(J(`正在前往 ${n} ,已有 ${e.count} 个网站接入AI摘要。`),w[2]=setTimeout((()=>{window.open(`https://${n}`,"_blank")}),100*y)):J("没有可以穿梭的网站。")}function Z(t=!1){T&&(N&&(N.pause(),N.remove()),N=null,p.style.opacity="1",p.style.animation="",t&&(O=null))}function K(){T&&(p.style.opacity="1",p.style.animation="",p.style.pointerEvents="auto")}async function Q(e){if(!T)return;const o=URL.createObjectURL(e);if(N=new Audio(o),N.play(),t.pjax){function n(){N.pause(),N.remove(),document.removeEventListener("pjax:complete",n)}document.removeEventListener("pjax:complete",n),document.addEventListener("pjax:complete",n)}p.style.opacity="0.4",p.style.animation="ai_breathe .7s linear infinite",N.removeEventListener("ended",V),N.addEventListener("ended",V)}function V(){Z()}function X(e){const o=t.exclude?t.exclude:["highlight","Copyright-Notice","post-ai","post-series","mini-sandbox"];o.includes("post-ai")||o.push("post-ai");const n=["script","style","iframe","embed","video","audio","source","canvas","img","svg","hr","input","form"];let i="";for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE)i+=t.textContent.trim();else if(t.nodeType===Node.ELEMENT_NODE){let e=!1;for(let n of t.classList)if(o.includes(n)){e=!0;break}let r=n.includes(t.tagName.toLowerCase());if(!e&&!r){i+=X(t)}}return i.replace(/\s+/g,"")}function W(t){const e=t.querySelectorAll("h1, h2, h3, h4"),o=[];for(let t=0;t<e.length;t++){const n=e[t],i=n.textContent.trim();o.push(i);const r=W(n);o.push(...r)}return o.join(";")}function Y(e,o=!0){let n;if(o){const o=t.total_length||1e3,i=t.ratio_string||"5:3:2";n=`文章的各级标题:${W(e)}。文章内容的截取:${function(t,e=1e3,o="5:3:2"){if(e=Math.min(e,5e3),t.length<=e)return t;const n=o.split(":").map(Number),i=n.reduce(((t,e)=>t+e),0),r=Math.min(t.length,e),a=n.map((t=>Math.floor(r*t/i))),s=t.substring(0,a[0]),l=(t.length-300)/2;return s+t.substring(l,l+a[1])+t.substring(t.length-a[2])}(X(e),o,i)}`}else n=`${X(e)}`;return n}async function tt(t,e=!0){if(!M)return"没有获取到key,代码可能没有安装正确,详细请查看文档。";if("123456"===M)return"请购买 key 使用,如果你能看到此条内容,则说明代码安装正确。";S=!1,k=new AbortController,E=k.signal;let o="";if(sessionStorage.getItem("summary"))return JSON.parse(sessionStorage.getItem("summary"));if(e){try{if(o=await fetch("https://summary.tianli0.top/",{signal:E,method:"POST",headers:{"Content-Type":"application/json",Referer:P},body:JSON.stringify({content:t,key:M,title:i,url:window.location.href,user_openid:C})}),S=!0,429===o.status&&J("请求过于频繁,请稍后再请求AI。"),!o.ok)throw new Error("Response not ok")}catch(t){return"AbortError"===t.name||("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname?J(`${r.name}请求tianliGPT出错了,你正在本地进行调试,请前往summary.zhheo.com添加本地域名(127.0.0.1:端口)的白名单。`):J(`${r.name}请求tianliGPT出错了,请稍后再试。`)),S=!0,""}const e=await o.json();return I=e.id,sessionStorage.setItem("summary",JSON.stringify(e)),Z(!0),e}{const e=`你是一个摘要生成工具,你需要解释我发送给你的内容,不要换行,不要超过200字,只需要介绍文章的内容,不需要提出建议和缺少的东西。请用中文回答,文章内容为:${t}`,n="https://api.openai.com/v1/chat/completions";try{if(o=await fetch(n,{signal:E,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify({model:"gpt-3.5-turbo",messages:[{role:"user",content:e}]})}),S=!0,429===o.status&&J("请求过于频繁,请稍后再请求AI。"),!o.ok)throw new Error("Response not ok")}catch(t){return console.error("Error occurred:",t),J(`${r.name}请求chatGPT出错了,请稍后再试。`),S=!0,""}const i=(await o.json()).choices[0].message.content;return sessionStorage.setItem("summary",i),i}}!async function(){sessionStorage.removeItem("recommendList"),sessionStorage.removeItem("backupsSummary");for(let t=0;t<q;t++)sessionStorage.removeItem(`summary${"#".repeat(t)}`);l=document.querySelector(".ai-explanation"),c=document.querySelector(".post-ai"),d=document.querySelectorAll(".ai-btn-item");const e=[B,F,U,D];d.forEach(((o,n)=>{t.hide_shuttle&&n===d.length-1?o.style.display="none":o.addEventListener("click",(()=>{e[n]()}))})),m=document.querySelector(".ai-Toggle"),L?m.addEventListener("click",(()=>{!async function(){H(),O=null,A=(A+1)%q;const t=Y(n)+"#".repeat(A);let e="";1!==A||$||(sessionStorage.setItem("backupsSummary",sessionStorage.getItem("summary")),$=!0),sessionStorage.getItem(`summary${"#".repeat(A)}`)?(e=JSON.parse(sessionStorage.getItem(`summary${"#".repeat(A)}`)),I=e.id,0===A?sessionStorage.setItem("summary",sessionStorage.getItem("backupsSummary")):sessionStorage.setItem("summary",sessionStorage.getItem(`summary${"#".repeat(A)}`))):(sessionStorage.removeItem("summary"),e=await tt(t,j),e&&sessionStorage.setItem(`summary${"#".repeat(A)}`,JSON.stringify(e))),e&&(J(e.summary),m.style.opacity="1",m.style.pointerEvents="auto",K())}()})):m.style.display="none",p=document.querySelector(".ai-speech-box"),T?p.addEventListener("click",(()=>{!async function(){if(!I)return;let t="";if(!O||N)if(N&&N)_?(_=!1,N.play(),p.style.opacity="0.4",p.style.animation="ai_breathe .7s linear infinite"):(_=!0,N.pause(),p.style.opacity="1",p.style.animation="");else{const e={method:"GET",headers:{"Content-Type":"application/json",Referer:P}},o=new URLSearchParams({key:M,id:I});try{p.style.pointerEvents="none",p.style.opacity="0.4",t=await fetch(`https://summary.tianli0.top/audio?${o}`,e),403===t.status?console.error("403 refer与key不匹配。"):500===t.status?console.error("500 系统内部错误"):(O=await t.blob(),p.style.pointerEvents="auto",await Q(O))}catch(t){console.log("摘要语音请求出错:",t),p.style.opacity="1",p.style.pointerEvents="auto"}}else await Q(O)}()})):p.style.display="none",t.summary_directly?U():B(),C=localStorage.getItem("visitorId")||await async function(){try{const t=await import("https://openfpcdn.io/fingerprintjs/v4"),e=await t.default.load(),o=(await e.get()).visitorId;return localStorage.setItem("visitorId",o),o}catch(t){return console.error("生成ID失败"),null}}()}()}e(t),t.pjax&&document.addEventListener("pjax:complete",(()=>{setTimeout((()=>{e(t)}),0)}))}window.hasOwnProperty("aiExecuted")||(console.log("%cPost-Summary-AI 文章摘要AI生成工具:%chttps://github.com/qxchuckle/Post-Summary-AI%c","border:1px #888 solid;border-right:0;border-radius:5px 0 0 5px;padding: 5px 10px;color:white;background:#4976f5;margin:10px 0","border:1px #888 solid;border-left:0;border-radius:0 5px 5px 0;padding: 5px 10px;",""),window.aiExecuted="chuckle");
@@ -1,25 +0,0 @@
1
- const katex = require('katex');
2
-
3
- hexo.extend.filter.register('marked:extensions', function(extensions) {
4
- // Info: `extensions` is an array.
5
- extensions.push({
6
- name: 'blockMath',
7
- level: 'block',
8
- tokenizer(src) {
9
- const cap = /^\s{0,3}\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/.exec(src);
10
-
11
- if (cap !== null) {
12
- return {
13
- type: 'blockMath',
14
- raw: cap[0],
15
- math: cap[1]
16
- };
17
- }
18
-
19
- return undefined;
20
- },
21
- renderer(token) {
22
- return `<p>${katex.renderToString(token.math, {displayMode: true})}</p>\n`;
23
- }
24
- });
25
- });
@@ -1,4 +0,0 @@
1
- hexo.extend.tag.register('expand', function(summary, content){
2
- return '<details><summary>' + summary + '</summary>' + hexo.render.renderSync({ text: content, engine: 'markdown' }) +
3
- '</details>';
4
- }, {ends: true});
@@ -1,70 +0,0 @@
1
- /**
2
- * Solitude
3
- * @example
4
- * hideInline
5
- * {% hideInline content,display,bg,color %}
6
- * content不能包含當引號,可用 &apos;
7
- * hideBlock
8
- * {% hideBlock display,bg,color %}
9
- * content
10
- * {% endhideBlock %}
11
- * hideToggle
12
- * {% hideToggle display,bg,color %}
13
- * content
14
- * {% endhideToggle %}
15
- */
16
-
17
- 'use strict'
18
-
19
- function hideInline (args) {
20
- args = args.join(' ').split(',')
21
- const content = args[0]
22
- const display = args[1] || 'Click'
23
- const bg = args[2] || false
24
- const color = args[3] || false
25
- let group = 'style="'
26
-
27
- if (bg) group += `background-color: ${bg};`
28
- if (color) group += `color: ${color}`
29
- group += '"'
30
-
31
- return `<span class="hide-inline"><button type="button" class="hide-button" ${group}>${display}
32
- </button><span class="hide-content">${content}</span></span>`
33
- }
34
-
35
- function hideBlock (args, content) {
36
- args = args.join(' ').split(',')
37
- const display = args[0] || 'Click'
38
- const bg = args[1] || false
39
- const color = args[2] || false
40
- let group = 'style="'
41
-
42
- if (bg) group += `background-color: ${bg};`
43
- if (color) group += `color: ${color}`
44
- group += '"'
45
-
46
- return `<div class="hide-block"><button type="button" class="hide-button" ${group}>${display}
47
- </button><div class="hide-content">${hexo.render.renderSync({ text: content, engine: 'markdown' })}</div></div>`
48
- }
49
-
50
- function hideToggle (args, content) {
51
- args = args.join(' ').split(',')
52
- const display = args[0]
53
- const bg = args[1] || false
54
- const color = args[2] || false
55
- let group = 'style="'
56
- let border = ''
57
-
58
- if (bg) {
59
- border = `style="border: 1px solid ${bg}"`
60
- group += `background-color: ${bg};`
61
- }
62
- if (color) group += `color: ${color}`
63
- group += '"'
64
-
65
- return `<details class="toggle" ${border}><summary class="toggle-button" ${group}>${display}</summary><div class="toggle-content">${hexo.render.renderSync({ text: content, engine: 'markdown' })}</div></details>`
66
- }
67
-
68
- hexo.extend.tag.register('hideInline', hideInline)
69
- hexo.extend.tag.register('hideBlock', hideBlock, { ends: true })
70
- hexo.extend.tag.register('hideToggle', hideToggle, { ends: true })
@@ -1,137 +0,0 @@
1
- function coverColor() {
2
- var path = document.getElementById("post-cover")?.src;
3
- if (path !== undefined) {
4
- var httpRequest = new XMLHttpRequest();
5
- httpRequest.open('GET', path + '?imageAve', true);
6
- httpRequest.send();
7
- httpRequest.onreadystatechange = function () {
8
- if (httpRequest.readyState == 4 && httpRequest.status == 200) {
9
- var json = httpRequest.responseText;
10
- var obj = eval('(' + json + ')');
11
- var value = obj.RGB;
12
- value = "#" + value.slice(2)
13
- if (getContrastYIQ(value) == "light") {
14
- value = LightenDarkenColor(colorHex(value), -50)
15
- }
16
-
17
- document.documentElement.style.setProperty('--sco-main', value);
18
- document.documentElement.style.setProperty('--sco-main-op', value + '23');
19
- document.documentElement.style.setProperty('--sco-main-op-deep', value + 'dd');
20
- document.documentElement.style.setProperty('--sco-main-none', value + '00');
21
- initThemeColor()
22
- document.getElementById("coverdiv").classList.add("loaded");
23
- }
24
- };
25
- } else {
26
- document.documentElement.style.setProperty('--sco-main', 'var(--sco-theme)');
27
- document.documentElement.style.setProperty('--sco-main-op', 'var(--sco-theme-op)');
28
- document.documentElement.style.setProperty('--sco-main-op-deep', 'var(--sco-theme-op-deep)');
29
- document.documentElement.style.setProperty('--sco-main-none', 'var(--sco-theme-none)');
30
- initThemeColor()
31
- }
32
- }
33
-
34
-
35
-
36
- function colorHex(colorString) {
37
- const hexRegex = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
38
- let color = colorString;
39
-
40
- if (/^(rgb|RGB)/.test(color)) {
41
- const colorArr = color.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
42
- const hexArr = colorArr.map(c => {
43
- const hex = Number(c).toString(16);
44
- return hex.length === 1 ? "0" + hex : hex;
45
- });
46
- return "#" + hexArr.join("");
47
- } else if (hexRegex.test(color)) {
48
- const hexDigits = color.replace(/#/, "").split("");
49
- if (hexDigits.length === 6) {
50
- return color;
51
- } else if (hexDigits.length === 3) {
52
- const hexArr = hexDigits.map(c => c + c);
53
- return "#" + hexArr.join("");
54
- }
55
- }
56
- return color;
57
- }
58
-
59
-
60
-
61
- function colorRgb(str) {
62
- const HEX_SHORT_REGEX = /^#([0-9a-fA-f]{3})$/;
63
- const HEX_LONG_REGEX = /^#([0-9a-fA-f]{6})$/;
64
- const HEX_SHORT_LENGTH = 4;
65
-
66
- const sColor = str.toLowerCase();
67
- let hexValue = "";
68
-
69
- if (sColor && (HEX_SHORT_REGEX.test(sColor) || HEX_LONG_REGEX.test(sColor))) {
70
- hexValue = sColor.length === HEX_SHORT_LENGTH ?
71
- sColor.replace(/^#(.)/g, "#$1$1") :
72
- sColor;
73
-
74
- const rgbValue = hexValue.slice(1)
75
- .match(/.{2}/g)
76
- .map(val => parseInt(val, 16))
77
- .join(",");
78
-
79
- return `rgb(${rgbValue})`;
80
- } else {
81
- return sColor;
82
- }
83
- }
84
-
85
-
86
- function LightenDarkenColor(col, amt) {
87
- let usePound = false;
88
-
89
- if (col[0] === "#") {
90
- col = col.slice(1);
91
- usePound = true;
92
- }
93
-
94
- const num = parseInt(col, 16);
95
- const r = Math.min(255, Math.max(0, (num >> 16) + amt));
96
- const b = Math.min(255, Math.max(0, ((num >> 8) & 0xff) + amt));
97
- const g = Math.min(255, Math.max(0, (num & 0xff) + amt));
98
-
99
- return `${usePound ? "#" : ""}${(g | (b << 8) | (r << 16)).toString(16).padStart(6, "0")}`;
100
- }
101
-
102
-
103
- function getContrastYIQ(hexcolor) {
104
- var colorrgb = colorRgb(hexcolor);
105
- var colors = colorrgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
106
- var red = colors[1];
107
- var green = colors[2];
108
- var blue = colors[3];
109
- var brightness;
110
- brightness = (red * 299) + (green * 587) + (blue * 114);
111
- brightness = brightness / 255000;
112
- if (brightness >= 0.5) {
113
- return "light";
114
- } else {
115
- return "dark";
116
- }
117
- }
118
-
119
- function initThemeColor() {
120
- const currentTop = window.scrollY || document.documentElement.scrollTop;
121
- let themeColor;
122
- if (currentTop > 0) {
123
- themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-card-bg');
124
- } else if (PAGECONFIG.is_post) {
125
- themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-main');
126
- } else {
127
- themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-background');
128
- }
129
- changeThemeColor(themeColor);
130
- }
131
-
132
- function changeThemeColor(color) {
133
- const meta = document.querySelector('meta[name="theme-color"]');
134
- if (meta) {
135
- meta.setAttribute('content', color);
136
- }
137
- }