Now, Greasemonkey can usually do such things using the beforescriptexecute event and @run-at document-start . Please note: only Firefox seems to support this event, and therefore this will not work in Chrome. See here and here for more tedious approaches.
To change this init() function before calling it, use the checkForBadJavascripts() function, which is defined below.
You would call it like this:
Where function\s+init( must be unique to the <script> tag you are targeting. (Note that addJS_Node() also defined below.)
For example, visit this page in jsBin . You will see 3 lines of text, two of which are added by JS.
Now install the following script and go to the page. You will see that the GM script removed one bad <script> and replaced the other with our "good" JS.
source share