-
-
Notifications
You must be signed in to change notification settings - Fork 109
/
get-browser-globals.js
75 lines (66 loc) · 1.25 KB
/
get-browser-globals.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use strict';
const ignorePatterns = [
/^webkit/i,
'BeforeInstallPromptEvent',
/^Bluetooth/,
'CDATASection',
'captureEvents',
'InputDeviceCapabilities',
'releaseEvents',
'SyncManager',
/^USB/,
// DevTools globals
'chrome',
'$_',
'$0',
'$1',
'$2',
'$3',
'$4',
'$',
'$$',
'$x',
'clear',
'copy',
'debug',
'dir',
'dirxml',
'getEventListeners',
'inspect',
'keys',
'monitor',
'monitorEvents',
'profile',
'profileEnd',
'queryObjects',
'table',
'undebug',
'unmonitor',
'unmonitorEvents',
'values'
];
const globals = Object.getOwnPropertyNames(window)
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
.filter(global => {
for (const pattern of ignorePatterns) {
if (typeof pattern === 'string') {
if (global === pattern) {
return false;
}
} else {
if (pattern.test(global)) {
return false;
}
}
}
return true;
});
const ret = {};
for (const key of globals) {
ret[key] = key.startsWith('on');
}
copy(JSON.stringify(ret, null, '\t'));
/*
Usage:
Open an Incognito window in Chrome Canary and paste the above into the console. You'll now have a new object in your clipboard for the `browser` field in `globals.json`. You still need to manually filter out items from the `builtin` list.
*/