Skip to content

Instantly share code, notes, and snippets.

@yuyoyuppe
Created July 17, 2020 13:04
Show Gist options
  • Save yuyoyuppe/c731ccda109d3234aefb33b032dd3556 to your computer and use it in GitHub Desktop.
Save yuyoyuppe/c731ccda109d3234aefb33b032dd3556 to your computer and use it in GitHub Desktop.
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