Skip to content

Instantly share code, notes, and snippets.

@1oh1
Created March 23, 2015 18:32
Show Gist options
  • Save 1oh1/d16f71c928490c37fd6b to your computer and use it in GitHub Desktop.
Save 1oh1/d16f71c928490c37fd6b to your computer and use it in GitHub Desktop.
Block GIFs from auto looping on Imgur. Press B to toggle.
// ==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