I'm trying to change only a text inside a page that is using divs, but one of its inside values is the same as the inner text:
<div class="maintable" title="Magistrados">Magistrados</div>
I don't have control over the html page and I'm using a script through a chrome extension to change the text values, because this text shows a couple of times inside another divs and tags:
const juiz = document.querySelectorAll('h1, h2, h3, h4, h5, p, li, td, caption, span, a, div');
for (let i=0; i < juiz.length; i++){
if(juiz[i].innerHTML.includes('Magistrados')){
juiz[i].innerHTML = juiz[i].innerHTML.replace('Magistrados', 'Juiz')
console.log(juiz[i].innerText) //I'm using this to try debugging the results, but it shows every content and not only the text inside of each div.
}
}
But when I do this, it changes also the title inside the tag:
<div class="maintable" title="Juiz">Juiz</div>
How can I change only the text inside every div without changing the title attribute? I've searched but didn't found any case close to this.