Kittens in the Web

Posted in this blog on April 22nd, 2011 by blambi
ב”ה

During a lecture related to javascript, well more specific jQuery.

Our lecturer showed us that a large Swedish newspaper uses jQuery and well we did some exercises (trough *firebug*) there and well for the fun of it I decided to write a wee snippet that replaces all images on with cute kitten images from Place Kitten:

  $('img').each( function() { this.src = "http://placekitten.com/" + this.width + "/" + this.height }

So after having written the above but not posting it (yea silly me), I wanted to show a way to write a simple greasemonkey script doing the same but for pages even lacking jQuery:

  var imgz = document.getElementsByTagName( 'IMG' );

  for( var x = 0; x < imgz.length; x++ )
    imgz[x].src = "http://placekitten.com/" + imgz[x].width + "/" + imgz[x].height

Try that against wikipedia and get a quite wikikitten or
something :D (or with charlie sheen places holders…)

WikiKittens!

Tags: ,