$ is a local variable injected in your console from the __commandLineAPI object, via a with statement wrapping your code (that’s why it’s not a global variable). If you inspect it more closely (using e.g. debugger; $('*');), you’ll also see that it is basically a function bound to the current window with the following source:
$: function (selector, opt_startNode) {
if (this._canQuerySelectorOnNode(opt_startNode))
return opt_startNode.querySelector(selector);
return inspectedWindow.document.querySelector(selector);
}
(defined on CommandLineAPIImpl.prototype)