Javascript replace global switch doesn't work in Chrome

The `replace()` switches are non-standard, it doesn't work in Chrome for example. The graphs in the debug toolbar don't show up because not all variables are replaced. If you use a regex instead it works in both Firefox and Chrome.