Skip to content

Instantly share code, notes, and snippets.

@moekhalil
Created February 25, 2019 10:48
Show Gist options
  • Save moekhalil/872f1abd7cd47e44c5ad87a46d57abe2 to your computer and use it in GitHub Desktop.
Save moekhalil/872f1abd7cd47e44c5ad87a46d57abe2 to your computer and use it in GitHub Desktop.
Extract a websites custom global variables. Very not-tested.
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