Set Youtube & Overcast PlaybackRate to 1.6 by default
当前为
// ==UserScript==
// @name Faster Media
// @namespace http://tampermonkey.net/
// @version 0.2.3
// @description Set Youtube & Overcast PlaybackRate to 1.6 by default
// @author Decradish
// @match *www.youtube.com/watch?v=*
// @match *overcast.fm/+*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var iPlaybackRate = 1.6, //rate
videoFocusd = false,
tmVideo = document.getElementsByTagName("video")[0],
tmAudio = document.getElementsByTagName("audio")[0],
tmMedia = false;
if(!!tmVideo){
tmMedia = tmVideo;
tmVideo
.onfocus = function(){
videoFocusd = true
}
.onblur = function(){
videoFocusd = false
}
}
if(!!tmAudio){
tmMedia = tmAudio;
}
if(!tmMedia){
return false;
}
tmMedia.oncanplay = function(){
tmMedia.playbackRate = iPlaybackRate;
};
document.onkeydown = function(e) {
var keyCode = e.keyCode || e.which || e.charCode;
//if video focused, ignore this function
if(!!tmVideo && videoFocusd){
return
}
if(keyCode == 32) {
tmMedia.paused ? tmMedia.play() : tmMedia.pause();
e.preventDefault();
return false;
}
}
})();