Skip to content

Instantly share code, notes, and snippets.

@luismasuelli
Created July 1, 2019 20:48
Show Gist options
  • Save luismasuelli/9e0fc39c19c54eacd76293fdcac8ad4f to your computer and use it in GitHub Desktop.
Save luismasuelli/9e0fc39c19c54eacd76293fdcac8ad4f to your computer and use it in GitHub Desktop.
Moo
function repeat(what, howMuch) {
var total = "";
for(var k=0; k<howMuch; k++) total += what;
return total;
}
function moo(v) {
return v.replace(/\S+/g, function(captured) {
return "M" + repeat("O", Math.min(captured.length - 1, 2));
});
}
$('*').contents().filter(function() {
return this.nodeType == Node.TEXT_NODE && this.nodeValue.trim() != '';
}).each(function() {
this.nodeValue = moo(this.nodeValue);
});
var cows = ["https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcReb29fmEjdNBmz0NmNFIASFmmEbW5F9goJ6aG-G13ZGXr5NTnf","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR__Ex7np11gmEYntnSHyLQ9gYR6I5ZrVVe_lCMAiBWlvwVehu6","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRA4JJ6C3Lm5CKTw6RirYax9DBJZZvOg98KpYj6xmqTYdq1Mdl_rg","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcToNjuWkKRC6m6MRDiHARpyQOm47sULlNfbCKCbpF5GoaBGySel","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQLzSvu3C6BrBtklvYzD2hAEy5hpnLV3y2G_n8Pc80mk-XJTFrnHw","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQh9uKVMq381V7Xqgm00e3kLUWD-QEikYju8H0JoM6ctW0u7I__","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTyS2N3zZ4v1xpAbXdbEI45XzCFtlC2Z0hRTRj-kYAKdp8Ekm2b","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRDqkwxXB4seY2dd_M3V_cyItWTZFfBe4MNyt_lXhPbR2CZcTy4uw","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSh6qx8TpeWAcV9vOUxOUzY-dcBHMQtnt4MOviac8PU4hxUwzcPzQ","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRXFw6Sl7ST5VvZnY5-HzZHZ8R6aIGrw6klghPSkLjqSOBUDEBF","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRnXvXouQca4GJa0DLUVPOrXK8dld9Wn9-ZP9fQY1avn_Lq-IRkPQ","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQWgBVOKpg0_SdsO6uPIZLwyjE65-Ql4Z3cI6vBw8f0VQmq-JV8","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRspN2GfL07eXO24rCpYNbHGuRDOBTs3_3T_QDsHyxLUBaXkJai","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS_Esg2UJhStgusdQqqfQ69N65m90FfuDOoEfjMW0gh1qnkOPze","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSconDuyyzs07mS6ADoWaxuXluaCXykO4tpMpR28V3KbFtRO_wG1A","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQHj1NgpfANPJxTpXj5GaxTUeiWmX9dPnAA9iI_JTMPEBALWJfIpQ","https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSLasv9lzsafuOscAahYAcvuidg70INOYQpT04_xD3tcm3g7J1SRg"];
$("img").each(function(index, element) {
var $this = $(element);
console.log("Iterating image...")
if ($this.width() < 100 || $this.height() < 100) return;
console.log("Has good size");
$this.attr('src', cows[parseInt(Math.random() * cows.length)]);
$this.css('object-fit', 'cover');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment