Skip to content

Instantly share code, notes, and snippets.

@fform
Created July 18, 2012 23:42
Show Gist options
  • Save fform/3139726 to your computer and use it in GitHub Desktop.
Save fform/3139726 to your computer and use it in GitHub Desktop.
Get all objects in the browser ignoring browser globals
//Gather
// First run this in a "clean" browser window to gather a list of objects the browser normall makes
(function(){
var dd = [];
for(var i in window){
dd.push(i);
};
var ddt = RegExp(dd.join('|'),'g');
console.log(ddt);
})();
//Test
// Now using the output from test, in the window you want to
// find objects, run this regex against all objects to filter.
// This will give you all the objects that scripts on the page
// have generated
//
// Keep in mind the regex below is for my browser when I wrote
// this. You'll need to generate your own list for your environment
(function(){
var df = [];
var test_list = /window|top|location|external|chrome|v8Locale|document|eventLog|logEvent|EventTracker|loadTimeData|parseHtmlSubset|global|$|chromeSend|url|parseQueryParams|findAncestorByClass|findAncestor|swapDomNodes|disableTextSelectAndDrag|isRTL|assert|getRequiredElement|appendParam|cr|ntp|i18nTemplate|WebGLFramebuffer|WebKitIntent|FormData|SVGPathSegMovetoRel|SVGAnimatedNumberList|SVGTSpanElement|WebGLProgram|outerWidth|Notation|WebKitCSSTransformValue|SVGPathSegLinetoVerticalAbs|WebGLUniformLocation|HTMLOptGroupElement|scrollX|SVGPathSegCurvetoCubicSmoothAbs|SVGAnimateElement|HTMLTextAreaElement|SVGNumberList|WebKitCSSKeyframesRule|DeviceOrientationEvent|personalbar|Document|HTMLStyleElement|SVGGlyphRefElement|HTMLAnchorElement|SVGTransformList|SQLException|screenX|HTMLProgressElement|HTMLLIElement|XPathResult|SVGTRefElement|WebGLShaderPrecisionFormat|SVGElementInstance|SVGEllipseElement|SVGFEFuncAElement|XMLHttpRequestException|toolbar|SVGAnimateMotionElement|SVGLinearGradientElement|SVGVKernElement|clientInformation|WebKitTransitionEvent|innerWidth|SVGPathSegLinetoAbs|Uint8ClampedArray|DOMStringMap|SVGMissingGlyphElement|ImageData|SVGRect|HTMLLinkElement|WebKitMutationObserver|SVGPolygonElement|XMLHttpRequestUpload|SVGNumber|UIEvent|WebKitCSSRegionRule|SVGFEMergeElement|SVGFEPointLightElement|RangeException|HTMLFrameSetElement|XMLSerializer|SVGPathSegArcAbs|OfflineAudioCompletionEvent|HTMLTableCaptionElement|WebGLContextEvent|Element|HTMLAudioElement|innerHeight|SVGFEColorMatrixElement|SVGFEFuncRElement|HTMLDataListElement|Uint16Array|PopStateEvent|HTMLMenuElement|DOMTokenList|SVGPathSegCurvetoCubicAbs|CSSMediaRule|HTMLHeadingElement|Range|defaultstatus|EventSource|SVGHKernElement|CustomEvent|HTMLEmbedElement|SVGImageElement|CompositionEvent|Float32Array|SVGMarkerElement|CSSValue|SVGGlyphElement|SVGLength|HTMLHtmlElement|FileError|Entity|SVGColor|CSSValueList|SVGPointList|localStorage|EntityReference|SVGFEDisplacementMapElement|SVGFEOffsetElement|CharacterData|webkitAudioPannerNode|SVGGElement|event|SVGAElement|SVGRectElement|MouseEvent|HTMLDirectoryElement|WebGLTexture|HTMLCanvasElement|screenLeft|webkitAudioContext|XMLHttpRequestProgressEvent|scrollbars|Notification|HTMLTableColElement|parent|Blob|HTMLBRElement|XPathEvaluator|SVGAltGlyphElement|CSSFontFaceRule|HTMLSpanElement|Int8Array|SVGMaskElement|status|CanvasRenderingContext2D|Plugin|Worker|MessageEvent|CSSStyleSheet|SVGPathSegLinetoVerticalRel|SVGPathSegCurvetoCubicSmoothRel|pageXOffset|Attr|DOMSettableTokenList|HTMLParagraphElement|SharedWorker|File|SVGLineElement|SVGPathElement|HTMLUnknownElement|MediaList|SVGStyleElement|SVGTextElement|length|HTMLFontElement|webkitIDBKeyRange|HTMLFrameElement|NodeFilter|devicePixelRatio|MimeType|XMLHttpRequest|HTMLTableElement|MessagePort|SVGMatrix|crypto|SVGFontFaceUriElement|MediaController|TextEvent|closed|opener|HTMLFieldSetElement|ProgressEvent|HTMLCollection|IceCandidate|HTMLButtonElement|SVGAnimatedLength|SVGPathSegCurvetoQuadraticRel|SVGFEBlendElement|HTMLAppletElement|locationbar|SVGPathSegCurvetoQuadraticSmoothAbs|SVGAltGlyphDefElement|SVGSymbolElement|SVGAnimatedEnumeration|sessionStorage|EventException|StyleSheetList|SVGStringList|PluginArray|SVGPathSeg|NodeList|outerHeight|HTMLImageElement|HTMLOListElement|SVGFEImageElement|SVGPathSegCurvetoQuadraticAbs|SVGPoint|BeforeLoadEvent|HTMLBaseElement|HTMLInputElement|HTMLMapElement|SVGDescElement|HTMLAreaElement|AudioProcessingEvent|SVGAnimateColorElement|DocumentType|styleMedia|Audio|CanvasGradient|SVGException|WebKitCSSFilterValue|HTMLVideoElement|HashChangeEvent|ClientRect|DocumentFragment|DOMStringList|SVGUnitTypes|SVGFontFaceElement|performance|SVGClipPathElement|TouchEvent|SVGPathSegLinetoRel|TimeRanges|webkitIDBIndex|MessageChannel|RGBColor|HTMLAllCollection|SVGRadialGradientElement|SVGPathSegClosePath|name|WebKitBlobBuilder|SVGAnimatedAngle|SVGFEGaussianBlurElement|HTMLKeygenElement|HTMLBodyElement|ProcessingInstruction|Image|HTMLHRElement|SVGAnimatedPreserveAspectRatio|Rect|WebSocket|frameElement|WebKitCSSKeyframeRule|webkitIDBDatabaseException|SVGAltGlyphItemElement|Event|SVGMetadataElement|Node|SVGRenderingIntent|webkitIDBDatabase|DataView|CloseEvent|SVGPaint|Option|HTMLTitleElement|self|NamedNodeMap|SVGZoomEvent|CSSImportRule|webkitIDBRequest|HTMLLegendElement|HTMLMeterElement|screenTop|SVGFEMorphologyElement|Counter|Comment|SVGFEFuncBElement|MutationEvent|SVGStopElement|SVGAnimatedNumber|history|HTMLDListElement|SVGLengthList|MediaError|SVGTitleElement|WebKitPoint|CSSStyleDeclaration|Uint8Array|HTMLModElement|screen|CDATASection|HTMLDivElement|SVGPathSegLinetoHorizontalRel|SVGAnimatedRect|DOMImplementation|SVGCircleElement|SVGElement|SVGSVGElement|SVGFontFaceSrcElement|SVGElementInstanceList|WebKitCSSMatrix|HTMLTableCellElement|HTMLParamElement|HTMLOutputElement|defaultStatus|console|SVGFECompositeElement|OverflowEvent|SVGPathSegList|HTMLObjectElement|HTMLOptionElement|SVGForeignObjectElement|SVGAngle|HTMLSourceElement|CSSPrimitiveValue|SVGFEComponentTransferElement|Window|CSSRuleList|HTMLScriptElement|pageYOffset|DOMException|menubar|SVGPatternElement|SVGPathSegCurvetoQuadraticSmoothRel|XPathException|offscreenBuffering|WebGLRenderbuffer|Storage|HTMLFormElement|SVGFilterElement|SVGFEFloodElement|SVGPathSegMovetoAbs|SVGDefsElement|SVGFETileElement|SessionDescription|SVGTransform|webkitIndexedDB|HTMLMediaElement|webkitIDBCursor|KeyboardEvent|WheelEvent|scrollY|SVGFESpecularLightingElement|SVGPathSegLinetoHorizontalAbs|HTMLSelectElement|HTMLBaseFontElement|SVGFEConvolveMatrixElement|SVGFEDropShadowElement|HTMLMetaElement|XSLTProcessor|TextMetrics|XMLDocument|screenY|ClientRectList|SVGPolylineElement|ArrayBuffer|SVGGradientElement|SVGCursorElement|SVGFETurbulenceElement|SVGPathSegArcRel|MediaStreamEvent|SVGFontFaceFormatElement|SVGDocument|HTMLUListElement|webkitStorageInfo|FileReader|SVGScriptElement|HTMLTableSectionElement|Int16Array|StyleSheet|SVGAnimatedBoolean|DOMParser|SVGUseElement|SVGPreserveAspectRatio|webkitIDBTransaction|HTMLQuoteElement|WebGLBuffer|SVGTextContentElement|Clipboard|SVGFontElement|SVGAnimatedInteger|CSSCharsetRule|CSSPageRule|webkitNotifications|Uint32Array|HTMLHeadElement|SVGViewElement|SVGSwitchElement|frames|CSSRule|WebKitAnimationEvent|SVGFontFaceNameElement|WebGLActiveInfo|SVGTextPathElement|StorageEvent|SVGAnimatedString|SVGFEFuncGElement|Int32Array|SVGFEDiffuseLightingElement|HTMLIFrameElement|HTMLLabelElement|HTMLTableRowElement|SVGSetElement|Text|SVGFEDistantLightElement|Selection|SVGAnimatedLengthList|applicationCache|CSSStyleRule|SVGMPathElement|CanvasPattern|Float64Array|webkitURL|SVGPathSegCurvetoCubicRel|statusbar|MimeTypeArray|HTMLElement|navigator|SVGFESpotLightElement|webkitIDBFactory|ErrorEvent|HTMLDocument|SVGAnimatedTransformList|FileList|SVGComponentTransferFunctionElement|WebGLShader|HTMLPreElement|WebGLRenderingContext|SVGAnimateTransformElement|SpeechInputEvent|SVGFEMergeNodeElement|HTMLMarqueeElement|SVGTextPositioningElement|webkitIDBObjectStore|PageTransitionEvent|onpagehide|onpause|onload|onloadeddata|onwebkitanimationstart|oninvalid|onsubmit|onchange|postMessage|onsearch|onresize|onseeking|onunload|onended|close|onwebkittransitionend|ondragstart|onselect|onloadstart|ondrop|onkeyup|ondblclick|onabort|onoffline|onloadedmetadata|onbeforeunload|onwebkitanimationiteration|onsuspend|onmouseover|ondragleave|ondragover|onkeydown|oncontextmenu|ondrag|ononline|onseeked|oninput|onwaiting|onpageshow|onfocus|webkitPostMessage|ondurationchange|onerror|oncanplay|oncanplaythrough|onprogress|onkeypress|onmousewheel|focus|onreset|onmousedown|onmessage|blur|onstorage|onwebkitanimationend|ontimeupdate|onmouseout|onblur|ondeviceorientation|onpopstate|onratechange|ondragenter|ondragend|onmousemove|onplaying|onstalled|onscroll|onplay|onhashchange|onmouseup|onvolumechange|onemptied|onclick|getSelection|print|stop|open|showModalDialog|alert|confirm|prompt|find|scrollBy|scrollTo|scroll|moveBy|moveTo|resizeBy|resizeTo|matchMedia|setTimeout|clearTimeout|setInterval|clearInterval|webkitRequestAnimationFrame|webkitCancelAnimationFrame|webkitCancelRequestAnimationFrame|atob|btoa|addEventListener|removeEventListener|captureEvents|releaseEvents|getComputedStyle|getMatchedCSSRules|webkitConvertPointFromPageToNode|webkitConvertPointFromNodeToPage|dispatchEvent|webkitRequestFileSystem|webkitResolveLocalFileSystemURL|openDatabase|TEMPORARY|PERSISTENT/g;
for(var i in window){
if(! test_list.test(i)){
df.push(i);
};
};
for(var i in df){
console.log(df[i],':',window[df[i]]);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment