put the code of the very last script element into pre element.
function writeLastCode(){
var $s = $('script');
document.write('<pre></pre>');
var $pre = $('pre').last();
$pre.last().text($($s[$s.length-2]).text().replace(/\t/g,' ').replace(/\n/,''));
}
/*
use like following
<script>
alert('hoge');
</script>
<script>writeLastCode();</script>
*/