I am having trouble replacing the html of a webpage using a chrome extension. After a regex search and replace, I then want to replace the html of the body tag using jQuery. However, functionality on the page always breaks when I do this and I don't know why.
As an example, run this in your console on StackExchange. Once you have done so, you cannot click on the up and downvote buttons, even though all you are doing is replacing the body's html with itself.
$('body').html($('body').html());