Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bookmarklet to show all the JS scripts into a page
javascript:(function(){function ajax(b){if(typeof XMLHttpRequest==="undefined"){XMLHttpRequest=function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(c){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(c){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(c){}throw new Error("This browser does not support XMLHttpRequest.")}}var a=new XMLHttpRequest();if(!b.url){throw new Error("You must define 'url'")}a.open("GET",b.url);a.onreadystatechange=function(){if(a.readyState===4){if(a.status===200){var c=(a.responseXML?a.responseXML:a.responseText);if(typeof b.success==="function"){b.success(c,b)}}if(typeof b.after==="function"){b.after()}}};a.send()}var s=document.getElementsByTagName("SCRIPT"),tx="",sr=[],i,t;for(i=0;i<s.length;i++){with(s.item(i)){t=text;if(t){tx+=t}else{sr.push(src)}}}var __loadedScript=sr.length;with(window.open()){document.write('<textarea id="t">'+tx+"</textarea>");for(var i=0;i<sr.length;i++){ajax({url:sr[i],success:function(a,b){document.getElementById("t").value+="\n\n----------------------------------------------------------------------\n"+b.url+"\n----------------------------------------------------------------------\n\n"+a;__loadedScript--;if(__loadedScript===0){document.write('<script src="http://jsbeautifier.org/beautify.js"><\/script><script>with(document.getElementById("t")){value=js_beautify(value);with(style){width="99%";height="99%";borderStyle="none";}};<\/script>');document.close()}}})}};})();
// http://blog.sociomantic.com/2010/08/native-javascript-ninjutsu-ajax-with-xhr/
// basic AJAX request to get the content of the JS files
function ajax(settings) {
if (typeof XMLHttpRequest === 'undefined') {
XMLHttpRequest = function() {
try { return new ActiveXObject('Msxml2.XMLHTTP.6.0') } catch ( e ) {}
try { return new ActiveXObject('Msxml2.XMLHTTP.3.0') } catch ( e ) {}
try { return new ActiveXObject('Msxml2.XMLHTTP') } catch ( e ) {}
throw new Error('This browser does not support XMLHttpRequest.')
};
}
var xmlhttp = new XMLHttpRequest();
if (!settings.url) throw new Error("You must define 'url'");
xmlhttp.open('GET', settings.url);
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState === 4) {
if (xmlhttp.status === 200) {
var xmlresponse = (xmlhttp.responseXML ? xmlhttp.responseXML : xmlhttp.responseText);
if (typeof settings.success === "function") settings.success(xmlresponse,settings);
}
if (typeof settings.after === "function") settings.after()
}
}
xmlhttp.send();
}
// search for the script tags in the page
// inspired by the jsbeautifier.org bookmarklet
var s=document.getElementsByTagName('SCRIPT'), tx='', sr=[], i, t;
for(i=0;i<s.length;i++) {
with(s.item(i)) {
t=text;
if(t) tx+=t;
else sr.push(src)
};
}
var __loadedScript = sr.length;
with(window.open()) {
document.write('<textarea id="t">'+tx+'</textarea>');
for (var i=0;i<sr.length;i++) {
ajax({
url: sr[i],
success: function(response,settings) {
document.getElementById('t').value += "\n\n----------------------------------------------------------------------\n"+settings.url+"\n----------------------------------------------------------------------\n\n" + response;
__loadedScript--;
if (__loadedScript===0) {
// use jsbeautifier to unminify the scripts
document.write('<script src="http://jsbeautifier.org/beautify.js"></script><script>with(document.getElementById("t")){value=js_beautify(value);with(style){width="99%";height="99%";borderStyle="none";}};</script>');
document.close();
}
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment