Skip to content

Instantly share code, notes, and snippets.

@airportyh
Last active December 15, 2015 04:09
Show Gist options
  • Select an option

  • Save airportyh/5199939 to your computer and use it in GitHub Desktop.

Select an option

Save airportyh/5199939 to your computer and use it in GitHub Desktop.
What to do to get at global JS variables on the page from a Chrome extension.
var code = '(' + function(){
window.postMessage({
globals: Object.keys(window)
})
} + '())'
var script = document.createElement('script')
script.text = code
document.head.appendChild(script)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment