Skip to content

Instantly share code, notes, and snippets.

@Eklei
Last active September 13, 2017 02:23
Show Gist options
  • Save Eklei/0abe97d08f597e5cf2152d217c70b826 to your computer and use it in GitHub Desktop.
Save Eklei/0abe97d08f597e5cf2152d217c70b826 to your computer and use it in GitHub Desktop.
Adds playback speed options to vid.me in the the quality menu (gear icon).
// ==UserScript==
// @name vid.me Playback Speed
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Adds playback speed options to vid.me in the quality menu (gear icon).
// @author Eklei
// @match https://vid.me/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var userscriptWaitForVideo = setInterval(function(){
//console.log('Userscript waiting...');
var testElement = document.getElementById('video_player_html5_api');
if (!testElement || !testElement.playbackRate || !testElement.currentTime)
return;
clearInterval(userscriptWaitForVideo);
userscriptInit();
}, 200);
function userscriptInit() {
function createMenuItem(text, speed) {
var r = document.createElement('li');
r.setAttribute('class', 'vjs-menu-item');
r.setAttribute('tabindex', '-1');
r.setAttribute('role', 'menuitem');
r.setAttribute('aria-live', 'polite');
r.setAttribute("onclick", "document.getElementById('video_player_html5_api').playbackRate = " + speed);
r.textContent = text;
return r;
}
var menuContent = document.querySelector('.vjs-menu-button[title="Quality"] .vjs-menu-content');
menuContent.style = 'max-height: none;';
menuContent.appendChild(createMenuItem('25%', 0.25));
menuContent.appendChild(createMenuItem('50%', 0.50));
menuContent.appendChild(createMenuItem('75%', 0.75));
menuContent.appendChild(createMenuItem('100%', 1.00));
menuContent.appendChild(createMenuItem('125%', 1.25));
menuContent.appendChild(createMenuItem('150%', 1.50));
menuContent.appendChild(createMenuItem('200%', 2.00));
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment