如何通过javascript在Chrome开发者控制台中获取自动完成数据?

时间:2015-10-15 03:25:13

标签: javascript google-chrome google-chrome-devtools

enter image description here

您好。

我希望通过javascript获取上面图片中的所有自动完成数据。

例如,

console.log(data) // data is auto-completion data  

["a[0]", "__defineGetter__", "__defineSetter__", ...] // result of above command

获取自动填充数据的任何想法?

谢谢。

1 个答案:

答案 0 :(得分:0)

您需要对象的所有属性(甚至是非枚举属性)以及原型链中出现的任何属性(例如,使用__proto__)。例如。 :

a = new Array(10); 
a[0] = 1;
console.log(Object.getOwnPropertyNames(a).concat(Object.getOwnPropertyNames(a.__proto__)).concat(Object.getOwnPropertyNames(a.__proto__.__proto__)));

将打印:

["0", "length", "length", "constructor", "toString", "toLocaleString", "join", "pop", "push", "concat", "reverse", "shift", "unshift", "slice", "splice", "sort", "filter", "forEach", "some", "every", "map", "indexOf", "lastIndexOf", "reduce", "reduceRight", "entries", "keys", "copyWithin", "find", "findIndex", "fill", "constructor", "toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "__defineGetter__", "__lookupGetter__", "__defineSetter__", "__lookupSetter__", "__proto__"]