Fix JS execution errors while generating the PHP screenshot.

While generating the PHP screenshot, we are deleting all chrome.
However, since we were doing it as soon as content was available,
when the JS from the page executed, it was triggering errors because
of missing navigation elements.

This patch fixes it by modifying the DOM only after it has been
fully initialized.