It's not really possible to properly embed a video in a Github comment, pull
request or issue like it's possible for
images
for instance. So if you want to put a video in a Github pull request (I do that
quite often), you have to upload it to a video hosting service like Youtube and
then you can put the link in the description. This is not what I would call
embedding a video but at least it's simple and effective.
Lately, I discovered on Stackoverflow a much better
solution
where the simple text link to the video hosting service is replaced by a
thumbnail generated by the video platform. In markdown, for Youtube this gives:
[![Alt text](https://img.youtube.com/vi/VID/0.jpg)](https://www.youtube.com/watch?v=VID)
Of course, VID
should be replaced by the actual Youtube video id. This is
still not embedding a video but that's a bit nicer and a much better incentive
to click to watch the video :-) The only problem is that it's a tad long to
type and to remember. That's why I decided to write a
Greasemonkey script to
simplify that. Actually, at first I wanted to write a super simple
bookmarklet but Firefox has a very
annoying issue where bookmarklets are broken on Content Security Policy enabled
website like on
Github :-(
Anyway, the Greasemonkey script is available on Github in
dpobel/github-add-youtube-video
.
To use it, you first need to install
Greasemonkey and
then just load the
addvideo.user.js
in your browser, it should ask if you want to install that script. After doing
that, the Github markdown
editor should
get a shiny new button that is able to transform any Youtube URL to the previous code
snippet, here is the script in action:
Screencast of github-add-youtube-video Greasemonkey
script
If nothing is selected in the textarea, hitting button will just prompt the
user for a Youtube URL to embed. This script should also work in Greasemonkey clones
for Chrome, though I did not test it.