Created
June 29, 2017 06:33
-
-
Save evinism/6cebf26916c57b286434df5466ebc627 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copy paste this script into the JS console on xkcd.com | |
// you can open the js console by pressing cmd-alt-j | |
// or by right clicking, pressing "inspect element", and navigating to the tab that says console. | |
const amt = 2000; | |
$('body').html(''); | |
const getImageUrl = (num) => 'http://generated.inspirobot.me/00' + (Math.floor(num / 10000) + 1) + '/aXm' + (num - Math.floor(num / 10000)*10000 + 1) + 'xjU.jpg'; | |
function shuffle(array) { | |
var currentIndex = array.length, temporaryValue, randomIndex; | |
// While there remain elements to shuffle... | |
while (0 !== currentIndex) { | |
// Pick a remaining element... | |
randomIndex = Math.floor(Math.random() * currentIndex); | |
currentIndex -= 1; | |
// And swap it with the current element. | |
temporaryValue = array[currentIndex]; | |
array[currentIndex] = array[randomIndex]; | |
array[randomIndex] = temporaryValue; | |
} | |
return array; | |
} | |
let items = []; | |
for(let i = 0; i < amt; i++){ | |
items.push('<img src="' + getImageUrl(i) + '" style="width:300px;"></img>'); | |
} | |
items = shuffle(items); | |
items.forEach( (item) => $('body').append(item)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment