Skip to content

Instantly share code, notes, and snippets.

@wayou
Created January 13, 2019 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wayou/bffd0ad08928ae9aae0fb4f83429ebc2 to your computer and use it in GitHub Desktop.
Save wayou/bffd0ad08928ae9aae0fb4f83429ebc2 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name set video playback rate
// @namespace http://tampermonkey.net/
// @version 0.1
// @description change the playback rate of the video
// @author wayou
// @match *://pan.baidu.com/*
// @match *://www.zealer.com/*
// @grant unsafeWindow
// @grant GM_addStyle
// @grant GM_info
// @grant GM_xmlhttpRequest
// @run-at document-end
// ==/UserScript==
(function() {
"use strict";
var wrapper = document.createElement("div");
wrapper.style.cssText = "z-index:999;position:absolute;top:0;";
var hint = document.createElement("span");
hint.innerText = "select video rate:";
wrapper.appendChild(hint);
var rates = [0.1, 0.5, 0.8, 1, 1.3, 1.5, 1.8, 2, 2.5];
var options = rates.map(function(rate) {
return (
'<option value="' +
rate +
'" ' +
(rate == 1 ? 'selected="selected"' : "") +
">" +
rate +
"</option>"
);
});
var select = document.createElement("select");
select.onchange = function(event) {
var video = document.querySelector("video");
if (!video) {
alert("video not found. check your network or reload.");
}
video.playbackRate = event.currentTarget.value;
};
select.innerHTML = options;
wrapper.appendChild(select);
document.body.prepend(wrapper);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment