Created
May 15, 2021 20:13
-
-
Save osuushi/6a8b6c015ee5d6ceabc0977230fbfaee to your computer and use it in GitHub Desktop.
Rotate YouTube videos Tampermonkey script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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