Created
January 14, 2018 14:16
-
-
Save JLChnToZ/4cf6f402990e00490773fe10917a987b to your computer and use it in GitHub Desktop.
A little script for refreshing all gifs on a webpage to make them synchronized.
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
| (function refreshGif(selector, images, srcs) { | |
| var mode = !!srcs, i; | |
| if(mode) { | |
| for(i = 0; i < images.length; i++) | |
| images[i].src = srcs[i]; | |
| return; | |
| } | |
| var dummyGif = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='; | |
| images = document.querySelectorAll((selector || '') + ' img[src$=\'.gif\']'); | |
| srcs = []; | |
| for(i = 0; i < images.length; i++) { | |
| srcs[i] = images[i].src; | |
| images[i].src = dummyGif; | |
| } | |
| setTimeout(refreshGif, 0, selector, images, srcs); | |
| })(); | |
| /* Alternative you may copy this bookmarklet: | |
| javascript:(function()%7B!function%20A(e%2Cr%2Cl)%7Bvar%20t%3Bif(!!l)for(t%3D0%3Bt%3Cr.length%3Bt%2B%2B)r%5Bt%5D.src%3Dl%5Bt%5D%3Belse%7Bfor(r%3Ddocument.querySelectorAll((e%7C%7C%22%22)%2B%22%20img%5Bsrc%24%3D'.gif'%5D%22)%2Cl%3D%5B%5D%2Ct%3D0%3Bt%3Cr.length%3Bt%2B%2B)l%5Bt%5D%3Dr%5Bt%5D.src%2Cr%5Bt%5D.src%3D%22data%3Aimage%2Fgif%3Bbase64%2CR0lGODlhAQABAIAAAP%2F%2F%2FwAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw%3D%3D%22%3BsetTimeout(A%2C0%2Ce%2Cr%2Cl)%7D%7D()%7D)() | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment