Created
February 25, 2019 10:48
-
-
Save moekhalil/872f1abd7cd47e44c5ad87a46d57abe2 to your computer and use it in GitHub Desktop.
Extract a websites custom global variables. Very not-tested.
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
const getSiteVars = () => { | |
const blankWindow = window.open('about:blank'); | |
const defaultKeys = Object.keys(blankWindow); | |
blankWindow.close(); | |
return Object | |
.keys(window) | |
.reduce((all, key) => | |
blankWindow.hasOwnProperty(key) ? all : { ...all, [key]: window[key]} | |
, {} | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment