Skip to content

Instantly share code, notes, and snippets.

@lyoshenka
Forked from jacopotarantino/twerkify.js
Last active October 22, 2015 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyoshenka/96e6dec389051b5ae8ea to your computer and use it in GitHub Desktop.
Save lyoshenka/96e6dec389051b5ae8ea to your computer and use it in GitHub Desktop.
Twerkify - Make your website twerk.
javascript:!function(){"use strict";function e(){var e,t,a;e=JSON.parse(this.responseText),t=document.querySelectorAll("img"),a=Array.prototype.slice.call(t),a.forEach(function(t){var a=e.data[Math.floor(Math.random()*e.data.length)];t.src=a.images.fixed_height.url})}console.log("Thank you for twerking");var t;t=new window.XMLHttpRequest,t.addEventListener("load",e),t.open("GET","https://api.giphy.com/v1/gifs/search?q=twerking&api_key=dc6zaTOxFJmzC"),t.send()}();
(function () {
'use strict'
/**
* @module Twerkify
* @description Thank you for twerking. Use at your own risk.
*/
console.log('Thank you for twerking')
var json_request
json_request = new window.XMLHttpRequest()
json_request.addEventListener('load', parse_json)
json_request.open('GET', 'https://api.giphy.com/v1/gifs/search?q=twerking&api_key=dc6zaTOxFJmzC')
json_request.send()
function parse_json () {
var gifs, dom_images, node_array
gifs = JSON.parse(this.responseText)
dom_images = document.querySelectorAll('img')
node_array = Array.prototype.slice.call(dom_images)
node_array.forEach(function (node, index, array) {
var gif = gifs.data[ Math.floor(Math.random() * gifs.data.length) ]
node.src = gif.images.fixed_height.url
})
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment