// ==UserScript== // @name YouTube Rotate 90° // @namespace http://tampermonkey.net/ // @version 1.2 // @description 把 Youtube 影片旋轉0°、90°,讓你輕鬆觀看影片! // @author zaqwsx2205 // @match https://*.youtube.com/* // @match https://*.youtube.com/watch?v=* // @match https://www.youtube.com/embed/* // @match https://www.youtube-nocookie.com/embed/* // @require https://code.jquery.com/jquery-3.4.1.min.js // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; var width; var height; var heightTest; var bool = false; var safeTest = location.href; function transform90(){ setTimeout(function(){ width = $(".html5-video-container").outerWidth(); height = $(".html5-video-container").outerHeight(); heightTest = width - height; $(".video-test1").html(''); }, 20); } function build(){ $(".video-test, .video-test1, .video-test2, .transform90").remove(); if($(".ytp-embed").length > 0){ $(".html5-video-container").append('
'); $(".video-test2").html(''); $('.ytp-chrome-top-buttons').prepend(''); }else{ $(".ytp-right-controls").prepend(''); } $('.transform90').on("click", function() { bool = !bool; if(bool){ $(".html5-video-container").append('
'); $(".html5-video-container").append('
'); $(".video-test").html(''); transform90(); }else{ $(".video-test, .video-test1").remove(); } }); } function observeTEST() { var composeBox = $('#player-container video')[0]; var composeObserver = new MutationObserver(function(e) { if(safeTest != location.href){ safeTest = location.href; bool = false; build(); } }); if(!composeBox) { window.setTimeout(observeTEST,500); return; } var config = {characterData: true, childList: true, attributes: true}; composeObserver.observe(composeBox,config); } $(document).ready(function(){ build(); observeTEST(); $(window).resize( function () { if(bool){ transform90(); } }); document.addEventListener("fullscreenchange", function( event ) { if(bool){ transform90(); } }); $(".ytp-size-button").click(function(){ if(bool){ transform90(); } }); }); })();