Skip to content

Instantly share code, notes, and snippets.

@cameronism
Forked from 140bytes/LICENSE.txt
Created December 18, 2012 20:19
Show Gist options
  • Save cameronism/4331574 to your computer and use it in GitHub Desktop.
Save cameronism/4331574 to your computer and use it in GitHub Desktop.
Clearly the internet does not have enough kittens

Kittens

Replace page images with kittens from http://placekitten.com

See test.html for a ready to install bookmarklet; you can fix the internet one page at a time.

!function (images) {
for (var ix = images.length, img; img = images[--ix]; ) {
// ignore small images, 64x64 is the smallest square allowed
if (img.width * img.height > 4e3) {
// let there be kittens
img.src = "http://placekitten.com/" + img.width + "/" + img.height;
}
}
}(document.images);
!function(a){for(var c,b=a.length;c=a[--b];)c.width*c.height>4e3&&(c.src="http://placekitten.com/"+c.width+"/"+c.height)}(document.images);
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "kittens",
"description": "Replace all images with pictures of kittens",
"keywords": [
"kitten",
"image",
"fun"
]
}
<!DOCTYPE html>
<title>Kittens</title>
<body>
<a
style="font-size: 300%; display: block;"
href="javascript:!function(a){for(var c,b=a.length;c=a[--b];)c.width*c.height>4e3&&(c.src='http://placekitten.com/'+c.width+'/'+c.height)}(document.images);"
>kittens!</a>
<div>&uarr; bookmarklet ready &uarr;</div>
<script>
// grab random images from loreempixel - this gets pretty close to 140 on its own
(Math.E * Date.now()).toString(9).split(0).map(function (num, ix, img) {
ix = num.length || 9;
img = new Image();
img.src = "http://lorempixel.com/" + ix * 9 + "/" + -ix * ~num[0];
document.body.appendChild(img);
});
</script>
</body>
@atk
Copy link

atk commented Dec 23, 2012

Lose the "http:" in the URL - placekittens supports https and you save 5 bytes. You can shave off another byte by temporarily saving width and height:

!function(a){for(var c,b=a.length,w,h;c=a[--b];)(w=c.width)*(h=c.height)>4e3&&(c.src="//placekitten.com/"+w+"/"+h)}(document.images)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment