Skip to content

Instantly share code, notes, and snippets.

@osuushi
Created May 15, 2021 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osuushi/6a8b6c015ee5d6ceabc0977230fbfaee to your computer and use it in GitHub Desktop.
Save osuushi/6a8b6c015ee5d6ceabc0977230fbfaee to your computer and use it in GitHub Desktop.
Rotate YouTube videos Tampermonkey script
// ==UserScript==
// @name Rotate YouTube
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Key bindings to rotate youtube videos
// @author osuushi
// @match https://www.youtube.com/watch?*
// @icon https://www.google.com/s2/favicons?domain=youtube.com
// @grant GM_addStyle
// @require https://cdnjs.cloudflare.com/ajax/libs/mousetrap/1.6.5/mousetrap.min.js
// ==/UserScript==
(function() {
'use strict';
let oldStyle = null
let angle = 0
const updateStyle = () => {
if (oldStyle) oldStyle.remove()
let scale = 1
if (angle % 180 != 0) {
scale = 10/16
}
oldStyle = GM_addStyle(`
video {
transition: transform 400ms;
transform: rotate(${angle}deg) scale(${scale});
}
`)
}
Mousetrap.bind("alt+,", () => {
angle -= 90
updateStyle()
})
Mousetrap.bind("alt+.", () => {
angle += 90
updateStyle()
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment