Galadriel's Mirror JS

A tiny script which can display the content of <script> tags on a page.


<pre class="galadriel-mirror"></pre>

var foo = "bar";

The <pre> tag will be filled with the text content of the script tag below it, displaying the line of JavaScript, var foo = "bar";;

Take a look at example.html in this repo to see her in action!

How it works

Galadriel's Mirror finds all tags with the class galadriel-mirror. These are now "mirror" elements. Galadriel will then search down the DOM tree for the first <script> tag she finds and display its contents in the mirror.

Please note that Galadriel will look for siblings and parents (and siblings of parents), but she will not dive into nodes of the DOM tree. So she may not work with complicated page layouts.