UNPKG

yunzhui-blog

Version:

静态资源仓库

8 lines 5.51 kB
/** * Minified by jsDelivr using Terser v5.39.0. * Original file: /gh/willow-god/Friend-Circle-Lite@master/main/fclite.js * * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files */ function initialize_fc_lite(){UserConfig={private_api_url:UserConfig?.private_api_url||"",page_turning_number:UserConfig?.page_turning_number||24,error_img:UserConfig?.error_img||"https://fastly.jsdelivr.net/gh/willow-god/Friend-Circle-Lite/static/favicon.ico"};const e=document.getElementById("friend-circle-lite-root");if(!e)return;e.innerHTML="";const n=document.createElement("div");n.id="random-article",e.appendChild(n);const t=document.createElement("div");t.className="articles-container",t.id="articles-container",e.appendChild(t);const i=document.createElement("button");i.id="load-more-btn",i.innerText="再来亿点",e.appendChild(i);const a=document.createElement("div");a.id="stats-container",e.appendChild(a);let r=0,o=[];function d(){const e="friend-circle-lite-cache",n="friend-circle-lite-cache-time",t=localStorage.getItem(n),a=(new Date).getTime();if(t&&a-t<6e5){const n=JSON.parse(localStorage.getItem(e));if(n)return void c(n)}fetch(`${UserConfig.private_api_url}all.json`).then((e=>e.json())).then((t=>{localStorage.setItem(e,JSON.stringify(t)),localStorage.setItem(n,a.toString()),c(t)})).finally((()=>{i.innerText="再来亿点"}))}function c(n){o=n.article_data;const d=n.statistical_data;a.innerHTML=`\n <div>Powered by: <a href="https://github.com/willow-god/Friend-Circle-Lite" target="_blank">FriendCircleLite</a><br></div>\n <div>Designed By: <a href="https://www.liushen.fun/" target="_blank">LiuShen</a><br></div>\n <div>订阅:${d.friends_num} 活跃:${d.active_num} 总文章数:${d.article_num}<br></div>\n <div>更新时间:${d.last_updated_time}</div>\n `,l();o.slice(r,r+UserConfig.page_turning_number).forEach((n=>{const i=document.createElement("div");i.className="card";const a=document.createElement("div");a.className="card-title",a.innerText=n.title,i.appendChild(a),a.onclick=()=>window.open(n.link,"_blank");const r=document.createElement("div");r.className="card-author";const d=document.createElement("img");d.className="no-lightbox",d.src=n.avatar||UserConfig.error_img,d.onerror=()=>d.src=UserConfig.error_img,r.appendChild(d),r.appendChild(document.createTextNode(n.author)),i.appendChild(r),r.onclick=()=>{!function(n,t,i){if(!document.getElementById("fclite-modal")){const n=document.createElement("div");n.id="modal",n.className="modal",n.innerHTML='\n <div class="modal-content">\n <img id="modal-author-avatar" src="" alt="">\n <a id="modal-author-name-link"></a>\n <div id="modal-articles-container"></div>\n <img id="modal-bg" src="" alt="">\n </div>\n ',e.appendChild(n)}const a=document.getElementById("modal"),r=document.getElementById("modal-articles-container"),d=document.getElementById("modal-author-avatar"),c=document.getElementById("modal-author-name-link"),l=document.getElementById("modal-bg");r.innerHTML="",d.src=t||UserConfig.error_img,d.onerror=()=>d.src=UserConfig.error_img,l.src=t||UserConfig.error_img,l.onerror=()=>l.src=UserConfig.error_img,c.innerText=n,c.href=new URL(i).origin;const s=o.filter((e=>e.author===n));s.slice(0,4).forEach((e=>{const n=document.createElement("div");n.className="modal-article";const t=document.createElement("a");t.className="modal-article-title",t.innerText=e.title,t.href=e.link,t.target="_blank",n.appendChild(t);const i=document.createElement("div");i.className="modal-article-date",i.innerText="📅"+e.created.substring(0,10),n.appendChild(i),r.appendChild(n)})),a.style.display="block",setTimeout((()=>{a.classList.add("modal-open")}),10)}(n.author,n.avatar,n.link)};const c=document.createElement("div");c.className="card-date",c.innerText="🗓️"+n.created.substring(0,10),i.appendChild(c);const l=document.createElement("img");l.className="card-bg no-lightbox",l.src=n.avatar||UserConfig.error_img,l.onerror=()=>l.src=UserConfig.error_img,i.appendChild(l),t.appendChild(i)})),r+=UserConfig.page_turning_number,r>=o.length&&(i.style.display="none")}function l(){const e=o[Math.floor(Math.random()*o.length)];n.innerHTML=`\n <div class="random-container">\n <div class="random-container-title">随机钓鱼</div>\n <div class="random-title">${e.title}</div>\n <div class="random-author">作者: ${e.author}</div>\n </div>\n <div class="random-button-container">\n <a href="#" id="refresh-random-article">刷新</a>\n <button class="random-link-button" onclick="window.open('${e.link}', '_blank')">过去转转</button>\n </div>\n `;document.getElementById("refresh-random-article").addEventListener("click",(function(e){e.preventDefault(),l()}))}d(),i.addEventListener("click",d),window.onclick=function(n){const t=document.getElementById("modal");n.target===t&&function(){const n=document.getElementById("modal");n.classList.remove("modal-open"),n.addEventListener("transitionend",(()=>{n.style.display="none",e.removeChild(n)}),{once:!0})}()}}function whenDOMReady(){initialize_fc_lite()}whenDOMReady(),document.addEventListener("pjax:complete",initialize_fc_lite); //# sourceMappingURL=/sm/bbf094146c8e5347aaabf5d859c7918a90937eeceb043b1e32f11a11ba9540f4.map