title: Javascript - Getting a script's own souce code from within the script
body: <p>So I have a problem where I need to get the entirety of a script's source code as a string (whether it's an inline script or a script that uses the src attribute) from within the script itself, but without knowing beforehand exactly what script it is. I can't just do an XHR for that reason. Several scripts on the page will listen for events, and when they handle them they will also run code that identifies the script's own source code. How should I do this?</p>
  
  <pre><code>function identifySelf() {
      // Some code here
      return mysource; // should return the source code of the script in which this function is defined
  }
  </code></pre>