Last active
August 27, 2020 16:55
-
-
Save sgregson/5a136f27f16755646c1b29e1c4084bf3 to your computer and use it in GitHub Desktop.
Buildkite inline video annotations from link URL
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 Inline Video Links in Buildkite | |
// @description Buildkite (really the markdown parser under the hood) doesn't support video annotations, so this will | |
// @namespace https://sgregson.dev | |
// @version 1.0 | |
// @author sgregson | |
// @match https://buildkite.com/* | |
// ==/UserScript== | |
(() => { | |
// Find all links pointing to mp4 files | |
const videoLinks = document.querySelectorAll('a[href$=".mp4"]') | |
videoLinks.forEach(e => { | |
const video = document.createElement("video") | |
const source = document.createElement("source") | |
source.setAttribute("type", "video/mp4"); | |
source.setAttribute("src", e.href); | |
video.setAttribute("width", "100%"); | |
video.setAttribute("controls", "true"); | |
video.appendChild(source) | |
// Inline the video after the link | |
e.parentNode.append(video); | |
}) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this can be improved, should implement a mutation observer for items which are revealed after the document loads