Skip to content

Instantly share code, notes, and snippets.

@krawaller
Last active December 19, 2015 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krawaller/6037874 to your computer and use it in GitHub Desktop.
Save krawaller/6037874 to your computer and use it in GitHub Desktop.
Version of Remy Sharps bookmarklet to check for globals, with the addition of ignoring global variables that are undefined and also alerting out a summary. If you want to add it to Chrome, there's a good guide here: http://crossbrowsertesting.com/faq/how-do-i-install-bookmarklet-google-chrome-mac-os
javascript:(function(){var e={},t,n={},r=(prompt("Ignore filter (comma sep)?","")||"").split(","),i=r.length,s=document.createElement("iframe"),o="";while(i--){n[r[i]]=1}for(i in window){if(window[i]!==undefined){e[i]={type:typeof window[i],val:window[i]}}}s.style.display="none";document.body.appendChild(s);s.src="about:blank";s=s.contentWindow||s.contentDocument;for(i in e){if(typeof s[i]!="undefined")delete e[i];else if(n[e[i].type])delete e[i]}t="addEventListener,document,location,navigator,window".split(",");i=t.length;while(--i){delete e[t[i]]}var u=[];for(i in e){u.push(i)}alert(u.length?"Found these globals: "+u.join(", ")+". See details in the console!":"No globals found!");console.dir(e)})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment