Created
July 8, 2016 00:05
-
-
Save tsamb/8c17ffc34cbe3e4e2715b7b94489f913 to your computer and use it in GitHub Desktop.
Some code to paste into the console of webpages to change all of their images. (The website must have jQuery installed!)
This file contains hidden or 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
// How do you create an prompt on the page then get an input of a search term | |
// Then replace all of the images with images based on that search term? | |
jQuery.getJSON( | |
"https://api.giphy.com/v1/gifs/search", | |
{q: "Ryan Gosling", api_key: "dc6zaTOxFJmzC"} | |
).done(function(response) { | |
var images = response.data.map(function(imgObj) { | |
return imgObj.images.original.url; | |
}); | |
jQuery("img").each(function(i, img) { | |
img.src = images[Math.floor(Math.random() * images.length)]; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment