Skip to content

Commit 6886985

Browse files
committed
[devtools-snippet] add logGlobals.js
1 parent 77e8bc8 commit 6886985

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

devtools-snippets/logGlobals.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
log-globals
3+
by Sindre Sorhus
4+
https://github.com/sindresorhus/log-globals
5+
MIT License
6+
*/
7+
(function () {
8+
'use strict';
9+
10+
function getIframe() {
11+
var el = document.createElement('iframe');
12+
el.style.display = 'none';
13+
document.body.appendChild(el);
14+
var win = el.contentWindow;
15+
document.body.removeChild(el);
16+
return win;
17+
}
18+
19+
function detectGlobals() {
20+
var iframe = getIframe();
21+
var ret = Object.create(null);
22+
23+
for (var prop in window) {
24+
if (!(prop in iframe)) {
25+
ret[prop] = window[prop];
26+
}
27+
}
28+
29+
return Object.keys(ret);
30+
}
31+
32+
console.log(detectGlobals());
33+
})();

0 commit comments

Comments
 (0)