Skip to content

Instantly share code, notes, and snippets.

@rubenhorn
Created August 3, 2020 12:50
Show Gist options
  • Save rubenhorn/c87810abb6ab59fb908e221486213de4 to your computer and use it in GitHub Desktop.
Save rubenhorn/c87810abb6ab59fb908e221486213de4 to your computer and use it in GitHub Desktop.
Tampermonkey script to set YouTube playback speed to 2x
// ==UserScript==
// @name 2xYT
// @version 0.1
// @description Automatically sets the playback speed to 2x on YouTube.com
// @match *://www.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const playbackSpeedSettingsKey = 'yt-player-playback-rate';
// Check if already 2x
if(!(playbackSpeedSettingsKey in sessionStorage) || JSON.parse(sessionStorage[playbackSpeedSettingsKey]).data != 2){
const playbackSpeedSettings = { 'data':'2', 'creation': Date.now() };
sessionStorage[playbackSpeedSettingsKey] = JSON.stringify(playbackSpeedSettings);
// Reload to apply changed settings
location.reload();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment