Created
August 3, 2018 22:15
-
-
Save Spongman/446af67ab242019965cc6499d90d9f56 to your computer and use it in GitHub Desktop.
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
window.fr = function(o) { | |
var m = new Map(); | |
var rg = [{ pn: 'window', v: window, l: 0 }]; | |
function add(pc) { | |
var p = pc.v; | |
var l = pc.l + 1; | |
for (var pn of Object.getOwnPropertyNames(p)) { | |
try { | |
var pd = Object.getOwnPropertyDescriptor(p, pn); | |
//if (pd.get) continue; | |
//console.log(pn, pd); | |
var v = pd.hasOwnProperty('value') ? pd.value : p[pn]; | |
if (v == null) continue; | |
var c = m.get(v); | |
if (!c || pc.l < c.l) { | |
var nc = { p: pc, pn: pn, v: v, l: l }; | |
if (!c) | |
rg.push(nc); | |
m.set(v, nc); | |
if (v === o) { | |
var rg2 = []; | |
for (var pp = nc; pp; pp = pp.p) | |
rg2.push(pp.pn); | |
console.log(rg2.reverse().join('.')); | |
} | |
} | |
} | |
catch { } | |
} | |
} | |
while (rg.length) { | |
add(rg.pop()); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment