if (window.location.hostname === "www.eposcard.co.jp") { const rssUrl = window.location.pathname === "/index.html" ? "https://www.eposcard.co.jp/articles/rss/category/%E5%A4%A7%E5%88%87%E3%81%AA%E3%81%8A%E7%9F%A5%E3%82%89%E3%81%9B?exclude_body=1&size=3" : "https://www.eposcard.co.jp/articles/rss/category/%E5%A4%A7%E5%88%87%E3%81%AA%E3%81%8A%E7%9F%A5%E3%82%89%E3%81%9B?exclude_body=1&size=2"; fetch(rssUrl) .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.text(); }) .then(str => (new window.DOMParser()).parseFromString(str, "text/xml")) .then(xml => { const items = xml.getElementsByTagName("item"); const maxItems = window.location.pathname.startsWith("/memberservice/") ? 2 : 3; const fragment = document.createDocumentFragment(); for (let i = 0; i < Math.min(items.length, maxItems); i++) { const title = items[i].getElementsByTagName("title")[0].textContent; const pubDate = items[i].getElementsByTagName("pubDate")[0].textContent; const link = items[i].getElementsByTagName("link")[0].textContent; const date = new Date(pubDate); const formattedDate = `${date.getFullYear()}/${(date.getMonth() + 1).toString().padStart(2, '0')}/${date.getDate().toString().padStart(2, '0')}`; const article = document.createElement("div"); article.className = "articleCasette"; const a = document.createElement("a"); a.href = link; const cell1 = document.createElement("div"); cell1.className = "cell"; const cell2 = document.createElement("div"); cell2.className = "cell"; const timeElem = document.createElement("time"); timeElem.setAttribute("datetime", formattedDate); timeElem.textContent = formattedDate; cell2.appendChild(timeElem); const cell3 = document.createElement("div"); cell3.className = "cell"; cell3.textContent = title; a.appendChild(cell1); a.appendChild(cell2); a.appendChild(cell3); article.appendChild(a); fragment.appendChild(article); } if (items.length > 0) { document.getElementById("articlesContainer").appendChild(fragment); } }) .catch(error => { console.error('Fetch error:', error); }); }