Created
May 9, 2019 09:24
-
-
Save JoeyBurzynski/a84e3b865ae18985fd5166c282dc3bfa to your computer and use it in GitHub Desktop.
JavaScript: Show all user-defined properties on global window object.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:document.body.appendChild(document.createElement('div')).innerHTML='<iframe id="temoin" style="display:none"></iframe>';Object.keys(window).filter(a=>!(a in window.frames[window.frames.length-1])).sort().forEach((a,i)=>console.log(i,a,window[a]));document.body.removeChild(document.querySelectorAll('#temoin')[0].parentNode);throw 'done'; | |
// JS Bookmarklet: Show all user-defined properties on global window object in chronological order. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function () { var results; var currentWindow; iframe = document.createElement('iframe'); iframe.style.display = 'none'; document.body.appendChild(iframe); currentWindow = Object.getOwnPropertyNames(window); results = currentWindow.filter(function (prop) { return !iframe.contentWindow.hasOwnProperty(prop); }); console.log(results); document.body.removeChild(iframe); }()); | |
// JavaScript Bookmarklet: Show All User-defined Properties on Global Window Object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You could also compare the window against a clean version of the window instead of trying to snapshot during runtime to compare against. I ran this in console but, you could turn it into a function. | |
// make sure it doesn't count my own properties | |
(function () { | |
var results, currentWindow, | |
// create an iframe and append to body to load a clean window object | |
iframe = document.createElement('iframe'); | |
iframe.style.display = 'none'; | |
document.body.appendChild(iframe); | |
// get the current list of properties on window | |
currentWindow = Object.getOwnPropertyNames(window); | |
// filter the list against the properties that exist in the clean window | |
results = currentWindow.filter(function(prop) { | |
return !iframe.contentWindow.hasOwnProperty(prop); | |
}); | |
// log an array of properties that are different | |
console.log(results); | |
document.body.removeChild(iframe); | |
}()); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment