Your script will only work correctly if it is placed after the Yod character. Consider adding an event listener for window.load to only call it when all the content is loaded:
addEventListener("load", () => {
...
});
There is no need to iterate through all the elements. You could have simply used document.documentElement.innerHTML. The only problem with this is that it will find the character in the script itself. To fix this we can use String.fromCharCode:
if (document.documentElement.innerHTML.indexOf(String.fromCharCode(1497)) >= 0)
document.location = 'https://googlehe.com';wikipedia.org/';