79775838

Date: 2025-09-26 11:27:08
Score: 1
Natty:
Report link
function getCustomWindowProps() {
    const iframe = document.createElement("iframe");
    document.documentElement.appendChild(iframe);
    const _window = iframe.contentWindow;
    document.documentElement.removeChild(iframe);
    const origWindowProps = new Set(Object.getOwnPropertyNames(_window));
    return Object.getOwnPropertyNames(window).filter(prop => !origWindowProps.has(prop));
}

This uses a trick of adding an empty iframe (need to add it temporarily to document so that its contentWindow is initialized...), then comparing current window with that one. This will in allow you to return only custom props added on top of current window, skipping whatever was defined by your browsers and its extensions.

For example for StackOverflow, this will currently return:

["$", "jQuery", "StackExchange", "StackOverflow", "__tr", "jQuery3710271175959070636961", "gtag", "dataLayer", "ga", "cam", "clcGamLoaderOptions", "opt", "googletag", "Stacks", "webpackChunkstackoverflow", "__svelte", "klass", "moveScroller", "styleCode", "initTagRenderer", "UniversalAuth", "Svg", "tagRendererRaw", "tagRenderer", "siteIncludesLoaded", "hljs", "apiCallbacks", "Commonmark", "markdownit"]
Reasons:
  • Blacklisted phrase (1): StackOverflow
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: p0358