Created
January 13, 2019 08:13
-
-
Save wayou/bffd0ad08928ae9aae0fb4f83429ebc2 to your computer and use it in GitHub Desktop.
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 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