I admit it that I do not really dislike the idea of putting script tags directly inside body. That means I am not a xhtml strict person. But I can't understand that why it isn't put into the design (or implementation) to locate current script node easily.
What I'm try to solve can be described with this code snippet:
Turns out the only way around is to assign an element id to the script tag: