Skip to content

Instantly share code, notes, and snippets.

@latompa
Last active August 29, 2015 13:55
Show Gist options
  • Save latompa/8740658 to your computer and use it in GitHub Desktop.
Save latompa/8740658 to your computer and use it in GitHub Desktop.
bookmarklet
javascript:(function() {
var puppyBasket = {
square: [
"http://fc04.deviantart.net/fs48/i/2012/019/e/b/husky_puppy_2151_by_sooper_husky-d28f7yz.jpg",
"http://www.rollingmeadowspuppies.com/images/Rose_poochon_male_Rm2_3_2.JPG",
"http://us.123rf.com/400wm/400/400/isselee/isselee0803/isselee080300569/2776137-yorkshire-terrier-puppies-1-month-in-front-of-a-white-background.jpg",
"http://media.bureauoftrade.com/p/2013/09/29/apollo-labrador-retriever-puppy-400c.jpg",
"http://helenwoodwardanimalcenter.files.wordpress.com/2012/04/snowcone-headshot.jpg%3Fw%3D400",
"http://imagecache6.allposters.com/LRG/61/6167/9LTG100Z.jpg",
"http://thumbs.dreamstime.com/x/german-shepherd-puppies-448837.jpg",
"http://r.ddmcdn.com/w_622/u_0/gif/french-mastiff.jpg",
"http://us.123rf.com/400wm/400/400/isselee/isselee1105/isselee110500780/9564151-close-up-of-border-collie-7-months-old-in-front-of-grey-background.jpg",
"http://thumbs.dreamstime.com/x/berner-sennenhund-10770568.jpg",
"http://cutearoo.com/wp-content/uploads/2011/03/Puppy4.jpg",
"http://adopt-a-dog.org/img/news/news-beagles.jpg",
"http://www.puppybandana.co.uk/_images/_gallery/blooming-bold-blooms-dog-bandana.jpg",
"http://www.puppybandana.co.uk/_images/_gallery/camo-dog-bandana-uk.jpg"
],
landscape: ["http://www.cutehomepets.com/wp-content/uploads/2010/10/shy-puppy.jpg",
"http://farm8.staticflickr.com/7024/6520841251_a9dd498efc.jpg",
"http://1.bp.blogspot.com/_YLNhdJ54NGY/TABdnIy6IhI/AAAAAAAABqI/cPlwN39ljpY/s1600/puppy.jpg",
"http://imgc.classistatic.com/cps/poc/131030/948r1/4028k9e_27.jpeg",
"http://img.ehowcdn.com/default/ehow/images/a05/ge/b3/information-teddy-bear-puppies-800x800.jpg",
"http://1.bp.blogspot.com/-M2RBafNJf9w/Tm5M5jI-JUI/AAAAAAAACNk/1b0X28rc5ns/s1600/duffy.jpg",
"http://imgc.classistatic.com/cps/poc/131204/793r1/1439ecg_27.jpeg",
"http://www.bassethoundtown.com/blog/wp-content/uploads/2011/07/Dottie-Mae2.jpg",
"http://cutearoo.com/wp-content/uploads/2011/03/Cozy-Puppy.jpg",
"http://25.media.tumblr.com/7e979e1066615eb5f91490674ef841ee/tumblr_mevoilFVZd1rjvhbwo1_500.jpg",
"http://images2.fanpop.com/images/photos/3900000/Gemma-border-collie-pup-border-collie-3988568-500-375.jpg",
"http://thebestgamesiteever.com/wp/wp-content/uploads/2012/06/Puppy-2-533x400.jpg",
"http://fc01.deviantart.net/fs40/f/2009/024/8/1/Sleepy_by_DoucheTheBag.jpg",
"http://4.bp.blogspot.com/-Ry2HotpJP-I/Uku-4wI2agI/AAAAAAAAXXw/Mxs2M6PDFQs/s640/puppy_dogs_1.jpg",
"http://74211.com/wallpaper/picture_thumb/Norwich-Terrier-Dogs-Sleeping-Puppy-Lying-on-Blue-Blanket-Hard-to-Wake-Up-.jpg"
],
portrait: ["http://www.purebredpups.com/uploads/dogs/puppies%20for%20sale%20iowa%20breeder%20cavachon%20259.JPG",
"http://keetsa.com/blog/wp-content/uploads/2008/11/puppy.jpg",
"http://www.dogbreedinfo.com/images25/QueenElizabethPocketBeagleDogPuppyChloe4Months3.jpg",
"http://animalsleaning.com/wp-content/uploads/2014/01/BdyUKp3IAAA9J-g.jpg-large-375x500.jpg",
"http://www.puppypoopy.com/bermese19.jpg",
"http://goldendoodles.com/photocontest2010/213777f40.jpg",
"http://media-cache-ak0.pinimg.com/736x/db/5b/e8/db5be87bf71d1b9a00b5d3dbf30d6d43.jpg",
"http://1.bp.blogspot.com/-iUOdCvHh6zw/TlvdJmgrEYI/AAAAAAAAAQo/nRWuzzZ3UeE/s1600/1198066713bull_terrier.jpg",
"http://photos.petfinder.com/photos/US/TN/TN628/23458009/TN628.23458009-1-x.jpg",
"http://www.palmbeachpuppies.com/media/catalog/product/cache/1/small_image/9df78eab33525d08d6e5fb8d27136e95/a/_/a_2.jpg",
"https://media.m-penny.com/files/instance-02/main_photo/2013/11/17/10/27/92125c84f1ac2f0207dd0fdc437563df.jpg",
"http://4.bp.blogspot.com/-wV8_KaQvXkc/T8zeuLTEDvI/AAAAAAAAAVc/coM5O87GCDE/s1600/russia.jpg",
"http://2.bp.blogspot.com/-GufmiltAwEU/UDG6BSWJrFI/AAAAAAAABb8/W0Pzap4I-iQ/s1600/puppy5.jpg",
"http://cdn.buzznet.com/assets/users16/amypiehoneybunch/default/37-heart-stoppingly-cute-puppies--large-msg-133252621591.jpg",
"http://www.pupnet.nl/gfx/photo/148.fokker.Border_Collie.puppy.0468158001197033448.400.jpg"
]
};
var randomPuppy = function(aspect){
return puppyBasket[aspect].sort(function() {
return .5 - Math.random();
})[0]
};
var getAspect = function(h,w) {
var a = h / w;
if(a >= 1.25 && a < 2) {
return "portrait"
} else if(a >= 0.83 && a < 1.25) {
return "square"
} else if(a >= 0.5 && a < 0.83){
return "landscape"
} else {
return null;
}
};
var images = document.getElementsByTagName("img");
for(i in images) {
var h = images[i].height;
var w = images[i].width;
var aspect = getAspect(h,w);
if(aspect == null) continue;
images[i].src=randomPuppy(aspect);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment