人口増加– tag –

1
(function() { const fetchWPP = () => { const els = document.querySelectorAll('.wpp-views-raw'); els.forEach(el => { const id = el.getAttribute('data-id'); if (!id || el.classList.contains('loaded')) return; // ブラウザのfetch機能を使い、直接APIから数字を奪取 fetch(`/wp-json/wordpress-popular-posts/v1/posts/${id}`) .then(r => r.json()) .then(d => { if (d && d.view_count) { el.innerText = Number(d.view_count).toLocaleString() + ' views'; el.classList.add('loaded'); } }).catch(e => console.log('WPP API Error')); }); }; // 読み込み時、1秒後、3秒後の3段階で実行(キャッシュ対策) fetchWPP(); setTimeout(fetchWPP, 1000); setTimeout(fetchWPP, 3000); })();