Skip to content

Instantly share code, notes, and snippets.

@eduzappa18
Last active April 4, 2018 00:11
Show Gist options
  • Save eduzappa18/1390474096b960322def052376595ae9 to your computer and use it in GitHub Desktop.
Save eduzappa18/1390474096b960322def052376595ae9 to your computer and use it in GitHub Desktop.
rotate youtube videos
javascript:(function() {
let vid = document.querySelector('video');
let scale, style;
if (vid) {
if (vid.toggle === undefined) {
vid.toggle = true;
}
if (vid.toggle) {
scale = vid.videoHeight/vid.videoWidth;
}
else {
scale = 1;
}
vid.toggle = !vid.toggle;
if (!vid.dg) {
vid.dg = 90;
}
else {
vid.dg += 90;
}
style = 'transform:rotate(' + vid.dg + 'deg) scale(' + scale + ');transition-duration:0.25s;position:absolute;width:100%;height:100%;';
vid.parentNode.style = style;
vid.addEventListener('ended', function (e) {
vid.parentNode.style = '';
}, false);
} else {
alert('no video element found.');
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment