Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==UserScript==
// @name Youtube customisation
// @namespace https://darkwood.fr
// @version 0.0.1
// @description Create youtube specific actions
// @author matyo91
// @match https://*.youtube.com/*
// @compatible firefox >=52
// @compatible chrome >=55
// @license MIT
// ==/UserScript==
// fix Youtube shortcut to speed down video for AZERTY keyboard
// detail : https://blog.darkwood.fr/article/raccourci-pour-lire-des-videos-2x
(function() {
'use strict';
var functions = {
upPlaybackSpeed() {
document.querySelector(".html5-video-player video").playbackRate = document.querySelector(".html5-video-player video").playbackRate + 0.1
},
increasePlaybackSpeed: function() {
var player = document.querySelector('#movie_player');
if (player && player.setPlaybackRate && player.getPlaybackRate) {
player.setPlaybackRate(player.getPlaybackRate() + .1);
}
},
decreasePlaybackSpeed: function() {
var player = document.querySelector('#movie_player');
if (player && player.setPlaybackRate && player.getPlaybackRate) {
player.setPlaybackRate(player.getPlaybackRate() - .1);
}
},
resetPlaybackSpeed: function() {
var player = document.querySelector('#movie_player');
if (player && player.setPlaybackRate && player.getPlaybackRate) {
player.setPlaybackRate(1);
}
},
}
document.addEventListener("DOMContentLoaded", function() {
window.addEventListener('keydown', function(event) {
console.log(event.keyCode)
if(event.keyCode === 188) { // '<'
functions.resetPlaybackSpeed();
}
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.