Created
June 14, 2018 12:38
-
-
Save bionik/73138b5f0186f2761a337d4f85dc2bfb to your computer and use it in GitHub Desktop.
apina.biz video to gif userscript
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== | |
// @name Apina.biz video2gif | |
// @description Replace apina.biz videos with gif | |
// @namespace bionik | |
// @include https://apina.biz/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
var videos = document.querySelectorAll('video.gif'); | |
for(var i = 0; i < videos.length; i++){ | |
var video = videos[i]; | |
var video_source = video.querySelector('source'); | |
var video_src = video_source.src; | |
var img = document.createElement('img'); | |
var img_src = video_src; | |
img_src = img_src.replace(".webm", ".gif"); | |
img_src = img_src.replace(".mp4", ".gif"); | |
img.src = img_src; | |
img.width = video.width; | |
img.height = video.height; | |
video.parentNode.replaceChild(img, video); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment