📜 ⬆️ ⬇️

We catch user input on the console in Google Chrome

Hey. I decided to write about a small chrome feature that I accidentally discovered once. How to use it - decide for yourself.

Immediately I will show an example in order not to exaggerate (I tested it on the last Chrome that I had):

var gn = Object.getOwnPropertyNames.bind(Object) var f = function(o) { if(f.caller && f.caller.toString && f.caller.toString().indexOf('object&&ArrayBuffer.isView(o)&&o.length>9999') > 0) { console.log(f.caller) } return gn(o); } Object.getOwnPropertyNames = f 

If you start entering something into the console after running the code above, then when you enter into the console, some function will start to fall out.
')
This one:

 (function getCompletions(type) { var object; if (type === 'string') object = new String(''); else if (type === 'number') object = new Number(0); else if (type === 'boolean') object = new Boolean(false); else object = this; var result = []; try { for (var o = object; o; o = Object.getPrototypeOf(o)) { if ((type === 'array' || type === 'typedarray') && o === object && ArrayBuffer.isView(o) && o.length > 9999) continue; var group = { items: [], __proto__: null }; try { if (typeof o === 'object' && o.constructor && o.constructor.name) group.title = o.constructor.name; } catch (ee) {} result[result.length] = group; var names = Object.getOwnPropertyNames(o); var isArray = Array.isArray(o); for (var i = 0; i < names.length; ++i) { if (isArray && /^[0-9]/.test(names[i])) continue; group.items[group.items.length] = names[i]; } } } catch (e) {} return result; } ) 

Obviously, with its help, Google Hrome gives us sags, which will be shown in the drop-down menu when entering text into the console.

image
Feel free to override the values ​​returned by the Object.getOwnPropertyNames function, and insert any garbage there if you want. You can also just react to user input in the console. (In the example, we simply derive that very function of chromium).

image

Everything :)

image

Repository here

Source: https://habr.com/ru/post/329320/


All Articles