avatar
Hespethorn
HespethornのBlog
GitHub
Recent Posts
Website Info
Article Count :
412
Runtime :
Total Word Count :
685.2k
Last Update :
document.addEventListener('pjax:send', () => { // removeEventListener btf.removeGlobalFnEvent('pjaxSendOnce') btf.removeGlobalFnEvent('themeChange') // reset readmode const $bodyClassList = document.body.classList if ($bodyClassList.contains('read-mode')) $bodyClassList.remove('read-mode') triggerPjaxFn(window.globalFn.pjaxSend) }) document.addEventListener('pjax:complete', () => { btf.removeGlobalFnEvent('pjaxCompleteOnce') document.querySelectorAll('script[data-pjax]').forEach(item => { const newScript = document.createElement('script') const content = item.text || item.textContent || item.innerHTML || "" Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value)) newScript.appendChild(document.createTextNode(content)) item.parentNode.replaceChild(newScript, item) }) triggerPjaxFn(window.globalFn.pjaxComplete) }) document.addEventListener('pjax:error', e => { if (e.request.status === 404) { const usePjax = true true ? (usePjax ? pjax.loadUrl('/404') : window.location.href = '/404') : window.location.href = e.request.responseURL } }) })()