Created
July 17, 2020 13:04
-
-
Save yuyoyuppe/c731ccda109d3234aefb33b032dd3556 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
var objs = new Set(); // we'll store the object references in this array | |
function walkTheObject(obj) { | |
var requiredClass = "MediaStreamTrack"; | |
var keys = {}; | |
try { | |
keys = Object.keys(obj); // get all own property names of the object | |
} catch {} | |
keys.forEach(function (key) { | |
try { | |
var value = obj[key]; // get property value | |
// if the property value is an object... | |
if (value && typeof value === "object") { | |
// if we don't have this reference... | |
if (!objs.has(value)) { | |
objs.add(value); // store the reference | |
if(value.__proto__ && | |
value.__proto__.constructor && | |
value.__proto__.constructor.name && | |
value.__proto__.constructor.name === requiredClass) | |
{ | |
console.log("Found!"); | |
} | |
walkTheObject(value); // traverse all its own properties | |
} | |
} | |
} catch {} | |
}); | |
} | |
new Promise(_ => { | |
walkTheObject(this); | |
console.log("Done!"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment