Created
          September 22, 2017 14:40 
        
      - 
      
- 
        Save damc-dev/393f617b5648efb292dafcb7cc135144 to your computer and use it in GitHub Desktop. 
    Giphy Download Links to All Gifs
  
        
  
    
      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
    
  
  
    
  | javascript: (function() { | |
| /* | |
| Adds download links to gifs on Giphy for easier mass download | |
| jQuery if not already loaded. | |
| */ | |
| if ('undefined'==typeof jQuery) { | |
| script = document.createElement( 'script' ); | |
| script.src = 'https://code.jquery.com/jquery-3.1.1.min.js'; | |
| script.onload=getServers; | |
| document.body.appendChild(script); | |
| } | |
| else { | |
| getGifs(); | |
| } | |
| function getGifs() { | |
| $images= $('a > img') | |
| $images.parents('a').each(function() { | |
| var $a = $(this)[0]; | |
| var $parent =$(this).parent(); | |
| console.log($a); | |
| console.log($parent); | |
| link=$a.href; | |
| urlSplit = link.split("/") | |
| lastUrlParam = urlSplit[urlSplit.length -1]; | |
| parts=lastUrlParam.split("-"); | |
| id=parts[parts.length -1]; | |
| console.log(id); | |
| downloadUrl = "https://media.giphy.com/media/" + id + "/giphy.gif"; | |
| console.log(downloadUrl); | |
| var link = "<a href=\"" + downloadUrl + "\" download>DOWNLOAD</a>" | |
| window.open(downloadUrl); | |
| $parent.after(link); | |
| }); | |
| } | |
| })(); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment