Created
December 8, 2011 15:15
-
-
Save fredyang/1447252 to your computer and use it in GitHub Desktop.
check how many global variable is used in chrome
This file contains hidden or 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
(function() { | |
var keys = "allKeys,top,window,location,external,chrome,v8Locale,document,SVGPathSegLinetoVerticalRel,SVGFESpotLightElement,HTMLButtonElement,Worker,webkitIDBTransaction,webkitNotifications,EntityReference,NodeList,screenY,SVGAnimatedNumber,SVGTSpanElement,navigator,MimeTypeArray,sessionStorage,SVGPoint,SVGScriptElement,OverflowEvent,HTMLTableColElement,OfflineAudioCompletionEvent,HTMLOptionElement,HTMLInputElement,webkitIDBIndex,SVGFEPointLightElement,SVGPathSegList,SVGImageElement,HTMLLinkElement,defaultStatus,MutationEvent,HTMLMetaElement,XMLHttpRequestProgressEvent,WebKitCSSTransformValue,Clipboard,HTMLTableElement,SharedWorker,SVGAElement,SVGAnimatedRect,webkitIDBDatabaseError,HTMLSpanElement,SVGGElement,toolbar,SVGLinearGradientElement,innerHeight,webkitIndexedDB,SVGForeignObjectElement,SVGAnimateElement,applicationCache,SVGFontElement,webkitAudioContext,pageXOffset,SVGFontFaceElement,ErrorEvent,Element,SVGPathSegCurvetoQuadraticSmoothRel,opener,SVGStopElement,HTMLUnknownElement,StyleSheetList,Float64Array,WebGLShader,Uint32Array,TimeRanges,HTMLHRElement,MediaStreamEvent,WebKitPoint,screenLeft,SVGViewElement,SVGGradientElement,WebGLContextEvent,SVGPathSegMovetoRel,CanvasPattern,WebGLActiveInfo,HTMLProgressElement,HTMLDivElement,HashChangeEvent,KeyboardEvent,SVGHKernElement,HTMLTitleElement,HTMLQuoteElement,webkitIDBDatabaseException,SVGFEImageElement,DOMTokenList,screenX,WebGLProgram,SVGPathSegMovetoAbs,RangeException,SVGTextPathElement,SVGAnimatedTransformList,webkitIDBFactory,HTMLLegendElement,SVGPathSegCurvetoQuadraticAbs,MouseEvent,MediaError,AudioProcessingEvent,CompositionEvent,Uint16Array,HTMLObjectElement,HTMLFontElement,SVGFilterElement,WebKitTransitionEvent,MediaList,SVGVKernElement,SVGPaint,SVGFETileElement,Document,XPathException,innerWidth,TextMetrics,personalbar,HTMLHeadElement,SVGFEComponentTransferElement,ProgressEvent,SVGAnimatedPreserveAspectRatio,Node,SVGRectElement,CSSPageRule,SVGLineElement,CharacterData,length,FileError,MessagePort,SVGDocument,ClientRect,Option,SVGDescElement,Notation,WebGLBuffer,StorageEvent,HTMLFieldSetElement,HTMLVideoElement,locationbar,SVGRenderingIntent,SVGPathSegLinetoRel,WebGLTexture,webkitAudioPannerNode,SVGGlyphRefElement,UIEvent,HTMLTableRowElement,HTMLDListElement,File,SVGEllipseElement,SVGFEFuncRElement,Int32Array,HTMLAllCollection,CSSValue,SVGAnimatedNumberList,HTMLParamElement,SVGElementInstance,HTMLModElement,scrollY,SVGPathSegLinetoHorizontalRel,outerHeight,SVGAltGlyphDefElement,CSSFontFaceRule,SVGPathSeg,CSSStyleDeclaration,WebSocket,TouchEvent,Rect,StyleSheet,SVGPathSegLinetoHorizontalAbs,SVGColor,ArrayBuffer,SVGComponentTransferFunctionElement,SVGStyleElement,Int16Array,HTMLOutputElement,SVGNumberList,DataView,DeviceOrientationEvent,Blob,SVGFEFloodElement,clientInformation,CloseEvent,webkitStorageInfo,HTMLStyleElement,HTMLBaseElement,HTMLBRElement,FileReader,SVGFEBlendElement,HTMLHtmlElement,SVGFEConvolveMatrixElement,SVGFEGaussianBlurElement,HTMLTextAreaElement,HTMLBaseFontElement,scrollbars,webkitIDBCursor,screen,localStorage,defaultstatus,WebGLRenderbuffer,SVGTextElement,SVGFEOffsetElement,RGBColor,SVGGlyphElement,Float32Array,HTMLCanvasElement,ProcessingInstruction,SVGZoomEvent,HTMLFrameElement,SVGElementInstanceList,SVGFEDisplacementMapElement,PopStateEvent,frames,SVGPathSegCurvetoCubicSmoothRel,HTMLElement,HTMLSelectElement,Int8Array,SVGFEDistantLightElement,ImageData,SVGFEFuncBElement,HTMLIsIndexElement,HTMLDocument,SVGCircleElement,HTMLCollection,SVGSetElement,SVGFEMergeElement,HTMLDirectoryElement,CSSMediaRule,MessageEvent,SVGFESpecularLightingElement,DOMException,SVGNumber,SVGFontFaceSrcElement,CSSRule,SVGElement,WebKitCSSMatrix,status,SVGMissingGlyphElement,HTMLScriptElement,CustomEvent,DOMImplementation,SVGLength,HTMLOptGroupElement,SVGPathSegLinetoVerticalAbs,SVGTextPositioningElement,HTMLKeygenElement,styleMedia,SVGFEFuncGElement,HTMLAreaElement,HTMLFrameSetElement,SVGPathSegCurvetoQuadraticRel,name,SVGAnimateMotionElement,self,HTMLIFrameElement,Comment,XMLSerializer,Event,performance,statusbar,Range,HTMLPreElement,DOMStringList,Image,SVGAltGlyphItemElement,SVGPathSegCurvetoQuadraticSmoothAbs,SVGRect,parent,SVGFontFaceFormatElement,closed,crypto,SVGAnimateTransformElement,webkitIDBDatabase,HTMLOListElement,HTMLFormElement,SVGPathSegCurvetoCubicSmoothAbs,DOMParser,SVGPathSegClosePath,console,SVGPathSegArcRel,EventException,SVGAnimatedString,SVGTransformList,webkitIDBRequest,SVGFEMorphologyElement,SVGAnimatedLength,SVGPolygonElement,scrollX,SVGPathSegLinetoAbs,WebKitFlags,HTMLMediaElement,XMLDocument,webkitIDBObjectStore,SVGMaskElement,HTMLHeadingElement,XMLHttpRequest,TextEvent,event,HTMLMeterElement,SVGPathElement,SVGStringList,HTMLAppletElement,devicePixelRatio,FileList,webkitURL,CanvasRenderingContext2D,MessageChannel,SVGFEDropShadowElement,WebGLRenderingContext,webkitIDBKeyRange,HTMLMarqueeElement,WebKitCSSKeyframesRule,XSLTProcessor,CSSImportRule,BeforeLoadEvent,PageTransitionEvent,CSSRuleList,SVGAnimatedLengthList,SVGTransform,HTMLSourceElement,SVGTextContentElement,HTMLTableSectionElement,SVGRadialGradientElement,HTMLTableCellElement,SVGCursorElement,DocumentFragment,SVGPathSegCurvetoCubicAbs,SVGUseElement,FormData,SVGPreserveAspectRatio,HTMLMapElement,XPathResult,HTMLLIElement,SVGSwitchElement,SVGLengthList,Plugin,HTMLParagraphElement,HTMLBlockquoteElement,SVGPathSegArcAbs,SVGAnimatedBoolean,outerWidth,CSSStyleRule,SVGFontFaceUriElement,Text,HTMLUListElement,SpeechInputEvent,WebGLUniformLocation,SVGPointList,CSSPrimitiveValue,HTMLEmbedElement,PluginArray,SVGPathSegCurvetoCubicRel,ClientRectList,SVGMetadataElement,SVGTitleElement,SVGAnimatedAngle,CSSCharsetRule,menubar,SVGAnimateColorElement,SVGMatrix,HTMLBodyElement,SVGSymbolElement,HTMLAudioElement,CDATASection,SVGFEDiffuseLightingElement,SVGFETurbulenceElement,WebKitBlobBuilder,SVGAnimatedEnumeration,WebKitCSSKeyframeRule,Audio,SVGFEMergeNodeElement,history,Entity,SQLException,HTMLTableCaptionElement,DOMStringMap,MimeType,EventSource,SVGException,NamedNodeMap,WebGLFramebuffer,XMLHttpRequestUpload,WebKitAnimationEvent,Uint8Array,SVGAnimatedInteger,HTMLMenuElement,SVGDefsElement,SVGAngle,SVGSVGElement,XPathEvaluator,HTMLImageElement,NodeFilter,SVGAltGlyphElement,SVGClipPathElement,Attr,Counter,SVGPolylineElement,DOMSettableTokenList,SVGPatternElement,SVGFECompositeElement,CSSValueList,XMLHttpRequestException,SVGFEColorMatrixElement,SVGTRefElement,WheelEvent,SVGUnitTypes,HTMLLabelElement,HTMLAnchorElement,SVGFEFuncAElement,CanvasGradient,frameElement,DocumentType,Storage,SVGMPathElement,CSSStyleSheet,SVGMarkerElement,offscreenBuffering,pageYOffset,SVGFontFaceNameElement,screenTop,onseeked,onkeypress,onwebkitanimationend,onmouseup,onemptied,onseeking,onclick,onmousedown,onwebkitanimationiteration,onpopstate,onmessage,onunload,onmouseover,blur,ontimeupdate,onstalled,onvolumechange,ondragenter,ondurationchange,onwaiting,ondragstart,onstorage,ononline,onbeforeunload,onplay,onloadstart,onsuspend,ondrag,onscroll,ondblclick,ondragend,onloadedmetadata,onpagehide,onmousewheel,onreset,onpageshow,onpause,onmouseout,oninvalid,close,onsubmit,oncontextmenu,onoffline,onload,ondragleave,onkeyup,onkeydown,oncanplay,oncanplaythrough,ondrop,ondragover,onratechange,onerror,onloadeddata,onwebkitanimationstart,onabort,onselect,onplaying,ondeviceorientation,focus,onsearch,onhashchange,onended,onmousemove,onwebkittransitionend,postMessage,onchange,onprogress,oninput,onblur,onresize,onfocus,getSelection,print,stop,open,showModalDialog,alert,confirm,prompt,find,scrollBy,scrollTo,scroll,moveBy,moveTo,resizeBy,resizeTo,matchMedia,setTimeout,clearTimeout,setInterval,clearInterval,webkitRequestAnimationFrame,webkitCancelRequestAnimationFrame,atob,btoa,addEventListener,removeEventListener,captureEvents,releaseEvents,getComputedStyle,getMatchedCSSRules,webkitConvertPointFromPageToNode,webkitConvertPointFromNodeToPage,openDatabase,webkitRequestFileSystem,webkitResolveLocalFileSystemURL,dispatchEvent,TEMPORARY,PERSISTENT".split(","); | |
function isUserGloba(k) { | |
for (var i = 0; i < keys.length; i++) { | |
if (keys[i] === k) { | |
return false; | |
} | |
} | |
return true; | |
} | |
console.userGlobal = function() { | |
var rtn = []; | |
for (var k in window) { | |
if (isUserGloba(k)) { | |
rtn.push(k); | |
} | |
} | |
return rtn.join("\n") + "\ntotal count: " + rtn.length; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment