You probably don't want to take the whole page's HTML and replace it with updated HTML, because all of the elements get torn down and recreated, which has implications for event handlers and the like.
It happens that just yesterday I answered this other question here. The answer can be applied quite easily to your situation.
Update: Since you're not moving the result into a new element, the code actually gets simpler:
walk(document.body);
function walk(node) {
var child;
switch (node.nodeType) {
case 1: // Element
for (child = node.firstChild;
child;
child = child.nextSibling) {
walk(child);
}
break;
case 3: // Text node
node.nodeValue = node.nodeValue.replace(
/[0-9]+(?:\.[0-9]+){0,1}/g,
function($0) {
msgs.push($0);
var num = parseFloat($0, 10);
if (isNaN(num)) {
return $0;
}
return num * 0.85;
}
);
break;
}
}
Live example
Note that I've modified the regexp a bit, you might want to massage it until it's how you want it. But I wanted to match decimal points only when followed by digits. (It's worth noting that not all cultures use .
as the decimal point, but you seemed to in your example, so...)