Faster Media

Set Youtube & Overcast PlaybackRate to 1.6 by default

02.01.2018 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Faster Media
// @namespace    http://tampermonkey.net/
// @version      0.2.10.3
// @description  Set Youtube & Overcast PlaybackRate to 1.6 by default
// @author       Decradish
// @match        *www.youtube.com/watch?v=*
// @match        *overcast.fm/+*
// @match        *v.youku.com/v_show/id_*
// @grant        none
// ==/UserScript==

(function() {
	'use strict';

	var iPlaybackRate = 1.6, //rate
		tmVideo = document.getElementsByTagName("video")[0],
		tmAudio = document.getElementsByTagName("audio")[0],
		tmMedia = false,
		youkuDom = document.getElementById('module_basic_player'); //优酷

	if(youkuDom){
		var youkuInterval = setInterval(function(){
			var ykPlayer = document.getElementById('#ykPlayer');
			if(ykPlayer && ykPlayer.length > 0){
				console.log('------')
				clearInterval(youkuInterval);
				var videos = document.getElementsByTagName('video');
				for(var i=0;i<videos.length;i++){
					videos[i].playbackRate = iPlaybackRate;
					videos[i].oncanplay = function(){
						this.playbackRate = iPlaybackRate;
					}
				}
			}
		}, 10);
		
		return false;
	}

	if(!!tmVideo){
		tmMedia = tmVideo;

		var youTubePlayBtn = document.getElementsByClassName('ytp-play-button')

		if(youTubePlayBtn.length > 0){
			document.getElementsByClassName('ytp-play-button')[0].focus()
		}
	}

	if(!!tmAudio){
		tmMedia = tmAudio;

		document.onkeydown = function(e) {
			var keyCode = e.keyCode || e.which || e.charCode;

			if(keyCode == 32) {
				tmMedia.paused ? tmMedia.play() : tmMedia.pause();
				e.preventDefault();
				return false;
			}
		}
	}

	if(!tmMedia){
		return false;
	}

	tmMedia.playbackRate = iPlaybackRate;

	tmMedia.onplay = function(){
		tmMedia.playbackRate = iPlaybackRate;
	};

	tmMedia.oncanplay = function(){
		tmMedia.playbackRate = iPlaybackRate;
	};
})();