<script type="text/javascript">
window.onload = function(){
...
document.body.innerHTML = document.body.innerHTML.replace(/test1/g, 'test2');
});
}
</script>
$("a[href]").each(function() { this.href = this.href.replace(/test1/, "test2"); });
$("img[src]").each(function() { this.src = this.src.replace(/test1/, "test2"); });
...
document.querySelectorAll('a, div, script').forEach(el => {
if (el.textContent.includes('test1'))
el.textContent = el.textContent.replace(/test1/g, 'test2');
})