0%
ty, by setting `security` option to `false`.'); } }) .catch(error => { console.error('LeanCloud Counter Error', error); }); } } else { function showTime(Counter) { var visitors = document.querySelectorAll('.leancloud_visitors'); var entries = [...visitors].map(element => { return decodeURI(element.getAttribute('id')); }); Counter('get', `/classes/Counter?where=${JSON.stringify({ url: { '$in': entries } })}`) .then(response => response.json()) .then(({ results }) => { if (results.length === 0) { document.querySelectorAll('.leancloud_visitors .leancloud-visitors-count').forEach(element => { element.innerText = 0; }); return; } for (let item of results) { let { url, time } = item; leancloudSelector(url).innerText = time; } for (let url of entries) { var element = leancloudSelector(url); if (element.innerText == '') { element.innerText = 0; } } }) .catch(error => { console.error('LeanCloud Counter Error', error); }); } } fetch('https://app-router.leancloud.cn/2/route?appId=a05sUJqbxBXDbnppdO8OVgiC-gzGzoHsz') .then(response => response.json()) .then(({ api_server }) => { var Counter = (method, url, data) => { return fetch(`https://${api_server}/1.1${url}`, { method: method, headers: { 'X-LC-Id': 'a05sUJqbxBXDbnppdO8OVgiC-gzGzoHsz', 'X-LC-Key': 'YRcXfwqMVEWtFfgTumCdt2il', 'Content-Type': 'application/json', }, body: JSON.stringify(data) }); }; if (CONFIG.page.isPost) { if (CONFIG.hostname !== location.hostname) return; addCount(Counter); } else if (document.querySelectorAll('.post-title-link').length >= 1) { showTime(Counter); } });