I'm injecting Javascript into a page w/ Greasemonkey, doing some processing on the body content (adding markup) then re-inserting the content. The problem is that all the events in the original content are lost, breaking things like onClick events that were added when the page initially loaded.
My original idea was to do this (using jQuery) to just re-add the script tags to the head:
$('script').each(function(s, script) { $(script).appendTo('head'); })
or just:
$('script').appendTo('head');
I thought this would cause scripts to reload/reeval, but it doesn't work.
A simple example of where I'd like to do this would be on: http://en.m.wikipedia.org/wiki/John_Hardy_%28song%29 I'd need to re-apply the this event found in application.js
$("h2.section_heading").click(function() {
// Do something
})