GfyCat Redirect to WebM Video File

Automatically promotes GfyCat gif pages to raw WebM video

  1. // ==UserScript==
  2. // @name GfyCat Redirect to WebM Video File
  3. // @namespace gfycatVideoRedirect_kk
  4. // @description Automatically promotes GfyCat gif pages to raw WebM video
  5. // @version 0.2
  6. // @author Kai Krause <kaikrause95@gmail.com>
  7. // @match http://gfycat.com/*
  8. // @match https://gfycat.com/*
  9. // @grant none
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. // gifycat.com/gifs/detail/id
  14. var videoPlayer = document.getElementsByTagName('video')[0];
  15. if (videoPlayer) {
  16. var children = videoPlayer.childNodes;
  17. for (var i = 0; i < children.length; ++i) {
  18. if (children[i].type == "video/webm") {
  19. var webm = children[i].src;
  20. break;
  21. }
  22. }
  23. } else {
  24. // gifycat.com/id
  25. var webm = document.getElementById('webmSource').src;
  26. var mp4 = document.getElementById('mp4Source').src;
  27. }
  28.  
  29. if (webm) {
  30. location.assign(webm);
  31. } else if (mp4) {
  32. location.assign(mp4);
  33. }