// Part 1
[...document.body.textContent.trim()].reduce((s,c,i,a)=>(c==a[(i+1)%a.length])*c+s,0)

// Part 2
[...document.body.textContent.trim()].reduce((s,c,i,a)=>(l=>c==a[(i+l/2)%l])(a.length)*c+s,0)

// Part 1
[...document.body.innerText.trim()].reduce((s,c,i,a)=>(c==a[(i+1)%a.length])*c+s,0)

// Part 2
[...document.body.innerText.trim()].reduce((s,c,i,a)=>(l=>c==a[(i+l/2)%l])(a.length)*c+s,0)

Use body.innerText instead of textContent
Use body.innerText instead of textContent

