I want to replace spices name in pages like this one: https://www.inaturalist.org/observations?locale=en&place_id=97391&preferred_place_id=8860&taxon_id=61902&view=species
So I want to replace for example ‘Chrysolina fastuosa’ to something different with this code:
var replaceArry = [
[/Chrysolina fastuosa/gi, 'Złotka jasnotowa'],
];
var numTerms = replaceArry.length;
var txtWalker = document.createTreeWalker (
document.body,
NodeFilter.SHOW_TEXT,
{ acceptNode: function (node) {
if (node.nodeValue.trim() )
return NodeFilter.FILTER_ACCEPT;
return NodeFilter.FILTER_SKIP;
}
},
false
);
var txtNode = null;
while (txtNode = txtWalker.nextNode () ) {
var oldTxt = txtNode.nodeValue;
for (var J = 0; J < numTerms; J++) {
oldTxt = oldTxt.replace (replaceArry[J][0], replaceArry[J][1]);
}
txtNode.nodeValue = oldTxt;
}
But that code don’t work on this page. This code works perfectly on headers, plain text, but not where I need it. What I need to change to make it work?