1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
| function initialize_fc_lite() { UserConfig = { private_api_url: UserConfig?.private_api_url || "", page_turning_number: UserConfig?.page_turning_number || 20, error_img: UserConfig?.error_img || "https://fastly.jsdelivr.net/gh/willow-god/Friend-Circle-Lite@latest/static/favicon.ico" }; const e = document.getElementById("friend-circle-lite-root"); if (!e) return; e.innerHTML = ""; var newElement = document.createElement("i"); newElement.className = "fas fa-angle-double-down"; 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.appendChild(newElement)), 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 l(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()), l(t); }) .finally(() => { i.appendChild(newElement) }); } function l(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://yeppioo.vip/" target="_blank">Yeppioo</a><br></div>\n <div>订阅:${d.friends_num} 活跃:${d.active_num} 总文章数:${d.article_num}<br></div>\n <div>更新时间:${d.last_updated_time}</div>\n `), c(); o.slice(r, r + UserConfig.page_turning_number).forEach((n) => { const i = document.createElement("div"); i.className = "card"; const a = document.createElement("a"); (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"), l = document.getElementById("modal-author-name-link"), c = document.getElementById("modal-bg"); (r.innerHTML = ""), (d.src = t || UserConfig.error_img), (d.onerror = () => (d.src = UserConfig.error_img)), (c.src = t || UserConfig.error_img), (c.onerror = () => (c.src = UserConfig.error_img)), (l.innerText = n), (l.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 l = document.createElement("div"); (l.className = "card-date"), (l.innerText = "🗓️" + n.created.substring(0, 10)), i.appendChild(l); const c = document.createElement("img"); (c.className = "card-bg no-lightbox"), (c.src = n.avatar || UserConfig.error_img), (c.onerror = () => (c.src = UserConfig.error_img)), i.appendChild(c), t.appendChild(i); }), (r += UserConfig.page_turning_number), r >= o.length && (i.style.display = "none"); } function c() { const e = o[Math.floor(Math.random() * o.length)]; n.innerHTML = ` <p class="random-section-title">🎣 随机钓鱼 <a href="#" id="refresh-random-article"><i class="fa-solid fa-arrow-rotate-right"></i></a></p> <div class="random-article-container"> <div class="random-container"> <a target="_blank" href="${e.link}" class="random-title">${e.title}</a> <div class="random-author">作者: ${e.author}</div> </div> </div>`; document.getElementById("refresh-random-article").addEventListener("click", function (e) { e.preventDefault(), c(); }); } 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);
|