Created
March 23, 2015 18:32
-
-
Save 1oh1/d16f71c928490c37fd6b to your computer and use it in GitHub Desktop.
Block GIFs from auto looping on Imgur. Press B to toggle.
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
// ==UserScript== | |
// @id imgur.com@scriptish | |
// @name prevent-gif-looping | |
// @version 1.1 | |
// @namespace imgur.com | |
// @author Vinayak | |
// @description Block GIFs from looping on Imgur | |
// @include http*://imgur.com/* | |
// @run-at document-end | |
// ==/UserScript== | |
function stopLooping(){ | |
document.getElementsByTagName("video")[0].removeAttribute("loop"); | |
loop=false; | |
} | |
function startLooping(){ | |
document.getElementsByTagName("video")[0].setAttribute("loop", "loop"); | |
document.getElementsByTagName("video")[0].load(); | |
loop=true; | |
} | |
function doc_keyUp(e) { | |
// B = key code 66. Press B to toggle looping | |
if (e.keyCode == 66) { | |
if(loop) { stopLooping(); } else { startLooping(); } | |
} | |
} | |
document.addEventListener('keyup', doc_keyUp, false); | |
document.getElementsByTagName("video")[0].removeAttribute("loop"); | |
var loop=false; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment