I am writing JavaScript for the open source browser available for Android, for replacing text in tag tag loaded pages in a browser with some text.
This needs to be worked out, because after the page is loaded into the browser, this JavaScript is executed, and replacements are performed, and, finally, the page with the replaced text is visible in the browser.
This is the replacement part of the code:
var textnodes, node, i; textnodes = document.evaluate("//body//text()[not(ancestor::script) and not(ancestor::style)]",document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null); replace(); function replace() { for (i = 0; i < textnodes.snapshotLength; i++) { node = textnodes.snapshotItem(i); text = node.data; text = text.replace(/\'/g, "♥");
However, document.evaluate does not seem to work. Can someone help me fix this code or any suggestions to do this by replacing the body text task in some other way?
Thanks!
source share