File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ // logAllNonDefaultPropertiesOfWindow.js
2
+ // https://github.com/0xdevalias/userscripts/tree/main/devtools-snippets
3
+ // Attempts to enumerate all non default properties of the global 'window' object.
4
+
5
+ ( function ( ) {
6
+ // Ref: https://developer.chrome.com/docs/devtools/console/utilities/
7
+ const chromeDevtoolsUtilityMethods = [
8
+ '$_' ,
9
+ '$0' ,
10
+ '$1' ,
11
+ '$2' ,
12
+ '$3' ,
13
+ '$4' ,
14
+ '$' ,
15
+ '$$' ,
16
+ '$x' ,
17
+ 'clear' ,
18
+ 'copy' ,
19
+ 'debug' ,
20
+ 'dir' ,
21
+ 'dirxml' ,
22
+ 'inspect' ,
23
+ 'getEventListeners' ,
24
+ 'keys' ,
25
+ 'monitor' ,
26
+ 'monitorEvents' ,
27
+ 'profile' ,
28
+ 'profileEnd' ,
29
+ 'queryObjects' ,
30
+ 'table' ,
31
+ 'undebug' ,
32
+ 'unmonitor' ,
33
+ 'unmonitorEvents' ,
34
+ 'values'
35
+ ] ;
36
+
37
+ // create an iframe and append to body to load a clean window object, then extract it's properties
38
+ const iframe = document . createElement ( 'iframe' ) ;
39
+ iframe . style . display = 'none' ;
40
+ document . body . appendChild ( iframe ) ;
41
+ const iframePristineWindowProperties = Object . getOwnPropertyNames ( iframe . contentWindow ) ;
42
+ document . body . removeChild ( iframe ) ;
43
+
44
+ const currentWindowProperties = Object . getOwnPropertyNames ( window ) ;
45
+
46
+ // filter the list against the properties that exist in the clean window
47
+ const windowPropertiesWithoutDefaults = currentWindowProperties . filter ( ( prop ) => ! iframePristineWindowProperties . includes ( prop ) ) ;
48
+ const windowPropertiesWithoutDefaultsOrDevToolsUtilities = windowPropertiesWithoutDefaults . filter ( ( prop ) => ! chromeDevtoolsUtilityMethods . includes ( prop ) ) ;
49
+
50
+ console . log ( windowPropertiesWithoutDefaults ) ;
51
+ console . log ( windowPropertiesWithoutDefaultsOrDevToolsUtilities ) ;
52
+
53
+ window . __chromeDevtoolsUtilityMethods = chromeDevtoolsUtilityMethods ;
54
+ window . __iframePristineWindowProperties = iframePristineWindowProperties ;
55
+ window . __currentWindowProperties = currentWindowProperties ;
56
+ window . __windowPropertiesWithoutDefaults = windowPropertiesWithoutDefaults ;
57
+ window . __windowPropertiesWithoutDefaultsOrDevToolsUtilities = windowPropertiesWithoutDefaultsOrDevToolsUtilities ;
58
+ } ( ) ) ;
You can’t perform that action at this time.
0 commit comments