Самый грубый вариант:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script type="text/javascript">
(function() {
function $(selector) {
return new $.prototype.init(selector);
}
$.prototype = {
constructor: $,
length: 0,
init: function(selector) {
var elem, elems = document.querySelectorAll(selector);
for(var i = 0; i < elems.length; i++) {
this[i] = elems[i];
}
this.length = elems.length;
return this;
},
text: function(text) {
for(var i = 0; i < this.length; i++) {
this[i].innerHTML = text;
}
return this;
}
}
$.prototype.init.prototype = $.prototype;
window.$ = $;
}());
</script>
</head>
<body>
<div class="a">A</div>
<div class="a">B</div>
<script>
$('.a').text('X');
</script>
</body>
</html>