<p id="art1">Привет приятель</p><p id="art2">Пока мой друг</p>
const text = 'hello, world!!';
const max = 20;
let len = 0;
for (const p of document.querySelectorAll('p')) {
len += p.textContent.length;
if (len >= max) {
p.insertAdjacentText('afterend', text);
break;
}
}