5 lines
16 KiB
JavaScript
5 lines
16 KiB
JavaScript
|
|
console.log("\n %c 摘要AI 博客文章摘要AI生成工具 %c https://ai.tianli0.top/ \n","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;");var tianliGPTIsRunning=!1,tianliGPTLastRunTime=0,tianliGPTIcon=`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48px" height="48px" viewBox="0 0 48 48">
|
|||
|
|
<g id="机器人" 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="形状结合" fill-rule="nonzero"></path>
|
|||
|
|
</g>
|
|||
|
|
</svg>`,tianliGPTSystem="";class TianliGPT{insertAIDiv(i,e){this.removeExistingAIDiv();let n=document.querySelector(i);e=e||i;var t,a,o,e=document.querySelector(e);if(!n){let e=0,t=setInterval(()=>{e+=300,(n=document.querySelector(i))?clearInterval(t):2e4<=e&&(clearInterval(t),console.log("摘要AI:在网页显示摘要AI框架失败,原因是没有找到需要注入的位置。如果本不打算在此页面展示摘要AI,可以忽略此提醒。"))},300)}document.querySelector(".post-TianliGPT")&&tianliGPTIsRunning||(tianliGPTIsRunning=!0,(t=document.createElement("div")).className="post-TianliGPT","undefined"!=typeof tianliGPT_theme&&tianliGPT_theme&&t.classList.add("gpttheme_"+tianliGPT_theme.toLowerCase()),(o=document.createElement("div")).className="tianliGPT-title",t.appendChild(o),(a=document.createElement("i")).className="tianliGPT-title-icon",o.appendChild(a),a.innerHTML=tianliGPTIcon,(a=document.createElement("div")).className="tianliGPT-title-text","undefined"==typeof tianliGPT_Title?a.textContent="简而言之":a.textContent=tianliGPT_Title,o.appendChild(a),(a=document.createElement("div")).className="tianliGPT-tag",a.id="tianliGPT-tag","undefined"==typeof tianliGPT_Name?a.textContent="AI摘要":a.textContent=tianliGPT_Name,o.appendChild(a),(o=document.createElement("div")).className="tianliGPT-explanation",o.innerHTML="undefined"==typeof tianliGPT_loadingText||tianliGPT_loadingText?'AI摘要正在生成,请稍等...<span class="blinking-cursor"></span>':'<span class="blinking-cursor"></span>',t.appendChild(o),e?e.insertBefore(t,e.firstChild):n&&n.insertBefore(t,n.firstChild))}removeExistingAIDiv(){var e=document.querySelector(".post-TianliGPT");e&&e.parentElement.removeChild(e)}getVerifiedTitle(){let t=["#thread_subject",".view_tit","h1",".postlist_top h2"];var e=(document.title||"").trim(),i=function(){for(var e of t){e=document.querySelector(e);if(e&&e.textContent.trim())return(e=(e=e).cloneNode(!0)).querySelectorAll("em").forEach(e=>e.remove()),e.textContent.trim()}return null}();return i&&e.startsWith(i)?i.trim():e}getTitleAndContent(){try{let a=this.getVerifiedTitle(),o=()=>{var t=document.querySelector(tianliGPT_postSelector);if(!t)return"";var e,t=t.cloneNode(!0),i=(t.querySelectorAll(".showhide, .locked, script, style, .authi, .post-TianliGPT, .code, .terminal_frame, .share-modal, .aplayer").forEach(e=>e.remove()),"Discuz"==tianliGPTSystem&&t.querySelectorAll(".txtlist.cl, .view_reply.cl, ignore_js_op, #hm_qrcode, .readthread_box",".smplayerbox",".it618_tieclick_ajax",".attach_nopermission").forEach(e=>e.remove()),t.querySelectorAll("p, strong, font, ul, li, ol, span, td"));let n="";for(e of t.querySelectorAll("h1, h2, h3, h4, h5"))n+=e.innerText+" ";var a,o=[];for(a of i){var l=Array.from(a.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.textContent).join("").trim().replace(/https?:\/\/[^\s]+/g,"");""!==l.trim()&&o.push(l)}if(0===o.length){let e=t.innerText;e=e.replace(/\n/g," ").replace(/\s+/g," ").trim(),n+=e}else n=o.join(" ");return n.trim()},l=o();if(!l)return new Promise(i=>{let e=0,n=()=>{e++,console.log(`摘要AI:文章内容为空,第${e}次重试...`),setTimeout(()=>{if(!(l=o())&&e<2)n();else if(l){let e=a+" "+l;e=e.replace(/(\s*\n\s*)+/g," ").trim();var t="undefined"!=typeof tianliGPT_wordLimit?tianliGPT_wordLimit:1e3;i(e.slice(0,t))}else console.log("摘要AI:重试3次后内容仍为空,放弃获取。如果本不打算在此页面展示摘要AI,可以忽略此提醒。"),i("")},1e3)};n()});let e=a+" "+l;e=e.replace(/(\s*\n\s*)+/g," ").trim();var t="undefined"!=typeof tianliGPT_wordLimit?tianliGPT_wordLimit:1e3;return e.slice(0,t)}catch(e){return console.log("摘要AI:可能由于一个或多个情况在本页面没有正常运行,如果本不打算在此页面展示,可以忽略此提醒,原因出在获取文章容器中的内容失败,或者可能是在文章转换过程中失败。",e),""}}old_getTitleAndContent(){try{var i,n,a=document.title,o=document.querySelector(tianliGPT_postSelector),l=(o||(console.log("摘要AI:找不到文章容
|