Skip to content

Instantly share code, notes, and snippets.

@nmanumr
Last active May 20, 2021 20:32
Show Gist options
  • Select an option

  • Save nmanumr/cf94810df13b5ff7d5bc6136a20ca3a5 to your computer and use it in GitHub Desktop.

Select an option

Save nmanumr/cf94810df13b5ff7d5bc6136a20ca3a5 to your computer and use it in GitHub Desktop.

Revisions

  1. nmanumr revised this gist May 20, 2021. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion rotate.js
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,7 @@ function rotate(){

    let $ = document.querySelector.bind(document);
    let stylesheet = document.createElement("style");
    sheet.innerHTML=`
    stylesheet.innerHTML=`
    [theater].rotate #player-theater-container.ytd-watch-flexy{ height:calc((16 / 9) * 100vw); }
    [theater].transform .html5-main-video { transform: scaleX(${conf.flipX ? -1 : 1}) scaleY(${conf.flipY ? -1 : 1}) rotate(${conf.angle || 0 }deg); }`;

    2 changes: 1 addition & 1 deletion rotate.min.js
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,2 @@
    let conf = { flipX: false, flipY: true, angle: 180 };
    function rotate(){let e=$(".ytp-size-button.ytp-button");if(e.title.includes("Theater"))return setTimeout(rotate,200),e.click();let t=$("ytd-watch-flexy[theater]"),n=$(".html5-main-video"),{width:l,height:a}=n.style;if(0!==conf.angle&&180!==Math.abs(conf.angle)){l=+l.slice(0,-2),a=+a.slice(0,-2);let e=window.innerHeight-169;l>e&&(l=e,a=e/16*9,n.style.width=l+"px",n.style.height=a+"px"),n.style.top=(l-a)/2+"px",t.classList.add("rotate")}t.classList.add("transform")}let $=document.querySelector.bind(document),stylesheet=document.createElement("style");sheet.innerHTML=`\n[theater].rotate #player-theater-container.ytd-watch-flexy{ height:calc((16 / 9) * 100vw); }\n[theater].transform .html5-main-video { transform: scaleX(${conf.flipX?-1:1}) scaleY(${conf.flipY?-1:1}) rotate(${conf.angle||0}deg); }`,document.body.appendChild(stylesheet),window.addEventListener("resize",()=>setTimeout(rotate,200)),rotate();
    function rotate(){let e=$(".ytp-size-button.ytp-button");if(e.title.includes("Theater"))return setTimeout(rotate,200),e.click();let t=$("ytd-watch-flexy[theater]"),n=$(".html5-main-video"),{width:l,height:a}=n.style;if(0!==conf.angle&&180!==Math.abs(conf.angle)){l=+l.slice(0,-2),a=+a.slice(0,-2);let e=window.innerHeight-169;l>e&&(l=e,a=e/16*9,n.style.width=l+"px",n.style.height=a+"px"),n.style.top=(l-a)/2+"px",t.classList.add("rotate")}t.classList.add("transform")}let $=document.querySelector.bind(document),stylesheet=document.createElement("style");stylesheet.innerHTML=`\n[theater].rotate #player-theater-container.ytd-watch-flexy{ height:calc((16 / 9) * 100vw); }\n[theater].transform .html5-main-video { transform: scaleX(${conf.flipX?-1:1}) scaleY(${conf.flipY?-1:1}) rotate(${conf.angle||0}deg); }`,document.body.appendChild(stylesheet),window.addEventListener("resize",()=>setTimeout(rotate,200)),rotate();
  2. nmanumr revised this gist May 20, 2021. No changes.
  3. nmanumr revised this gist May 20, 2021. 1 changed file with 44 additions and 0 deletions.
    44 changes: 44 additions & 0 deletions rotate.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    let conf = {
    flipX: false,
    flipY: true,
    angle: 180,
    };

    function rotate(){
    let theaterButton = $('.ytp-size-button.ytp-button');
    if (theaterButton.title.includes("Theater")) {
    setTimeout(rotate, 200);
    return theaterButton.click();
    }

    let container = $("ytd-watch-flexy[theater]");
    let video = $(".html5-main-video");
    let {width,height} = video.style;

    if (conf.angle !== 0 && Math.abs(conf.angle) !== 180) {
    width = +width.slice(0, -2);
    height = +height.slice(0, -2);
    let maxWidth = window.innerHeight-169;

    if (width > maxWidth) {
    width = maxWidth;
    height = maxWidth / 16 * 9;
    video.style.width = width + 'px';
    video.style.height = height + 'px'
    }

    video.style.top= (width - height) / 2 + 'px';
    container.classList.add("rotate");
    }

    container.classList.add("transform");
    }

    let $ = document.querySelector.bind(document);
    let stylesheet = document.createElement("style");
    sheet.innerHTML=`
    [theater].rotate #player-theater-container.ytd-watch-flexy{ height:calc((16 / 9) * 100vw); }
    [theater].transform .html5-main-video { transform: scaleX(${conf.flipX ? -1 : 1}) scaleY(${conf.flipY ? -1 : 1}) rotate(${conf.angle || 0 }deg); }`;

    document.body.appendChild(stylesheet);
    window.addEventListener("resize", () => setTimeout(rotate, 200)), rotate();
  4. nmanumr revised this gist May 20, 2021. 1 changed file with 0 additions and 44 deletions.
    44 changes: 0 additions & 44 deletions rotate.js
    Original file line number Diff line number Diff line change
    @@ -1,44 +0,0 @@
    let conf = {
    flipX: false,
    flipY: true,
    angle: 180,
    };

    function rotate(){
    let theaterButton = $('.ytp-size-button.ytp-button');
    if (theaterButton.title.includes("Theater")) {
    setTimeout(rotate, 200);
    return theaterButton.click();
    }

    let container = $("ytd-watch-flexy[theater]");
    let video = $(".html5-main-video");
    let {width,height} = video.style;

    if (conf.angle !== 0 && Math.abs(conf.angle) !== 180) {
    width = +width.slice(0, -2);
    height = +height.slice(0, -2);
    let maxWidth = window.innerHeight-169;

    if (width > maxWidth) {
    width = maxWidth;
    height = maxWidth / 16 * 9;
    video.style.width = width + 'px';
    video.style.height = height + 'px'
    }

    video.style.top= (width - height) / 2 + 'px';
    container.classList.add("rotate");
    }

    container.classList.add("transform");
    }

    let $ = document.querySelector.bind(document);
    let stylesheet = document.createElement("style");
    sheet.innerHTML=`
    [theater].rotate #player-theater-container.ytd-watch-flexy{ height:calc((16 / 9) * 100vw); }
    [theater].transform .html5-main-video { transform: scaleX(${conf.flipX ? -1 : 1}) scaleY(${conf.flipY ? -1 : 1}) rotate(${conf.angle || 0 }deg); }`;

    document.body.appendChild(stylesheet);
    window.addEventListener("resize", () => setTimeout(rotate, 200)), rotate();
  5. nmanumr revised this gist May 20, 2021. No changes.
  6. nmanumr created this gist May 20, 2021.
    44 changes: 44 additions & 0 deletions rotate.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    let conf = {
    flipX: false,
    flipY: true,
    angle: 180,
    };

    function rotate(){
    let theaterButton = $('.ytp-size-button.ytp-button');
    if (theaterButton.title.includes("Theater")) {
    setTimeout(rotate, 200);
    return theaterButton.click();
    }

    let container = $("ytd-watch-flexy[theater]");
    let video = $(".html5-main-video");
    let {width,height} = video.style;

    if (conf.angle !== 0 && Math.abs(conf.angle) !== 180) {
    width = +width.slice(0, -2);
    height = +height.slice(0, -2);
    let maxWidth = window.innerHeight-169;

    if (width > maxWidth) {
    width = maxWidth;
    height = maxWidth / 16 * 9;
    video.style.width = width + 'px';
    video.style.height = height + 'px'
    }

    video.style.top= (width - height) / 2 + 'px';
    container.classList.add("rotate");
    }

    container.classList.add("transform");
    }

    let $ = document.querySelector.bind(document);
    let stylesheet = document.createElement("style");
    sheet.innerHTML=`
    [theater].rotate #player-theater-container.ytd-watch-flexy{ height:calc((16 / 9) * 100vw); }
    [theater].transform .html5-main-video { transform: scaleX(${conf.flipX ? -1 : 1}) scaleY(${conf.flipY ? -1 : 1}) rotate(${conf.angle || 0 }deg); }`;

    document.body.appendChild(stylesheet);
    window.addEventListener("resize", () => setTimeout(rotate, 200)), rotate();
    2 changes: 2 additions & 0 deletions rotate.min.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    let conf = { flipX: false, flipY: true, angle: 180 };
    function rotate(){let e=$(".ytp-size-button.ytp-button");if(e.title.includes("Theater"))return setTimeout(rotate,200),e.click();let t=$("ytd-watch-flexy[theater]"),n=$(".html5-main-video"),{width:l,height:a}=n.style;if(0!==conf.angle&&180!==Math.abs(conf.angle)){l=+l.slice(0,-2),a=+a.slice(0,-2);let e=window.innerHeight-169;l>e&&(l=e,a=e/16*9,n.style.width=l+"px",n.style.height=a+"px"),n.style.top=(l-a)/2+"px",t.classList.add("rotate")}t.classList.add("transform")}let $=document.querySelector.bind(document),stylesheet=document.createElement("style");sheet.innerHTML=`\n[theater].rotate #player-theater-container.ytd-watch-flexy{ height:calc((16 / 9) * 100vw); }\n[theater].transform .html5-main-video { transform: scaleX(${conf.flipX?-1:1}) scaleY(${conf.flipY?-1:1}) rotate(${conf.angle||0}deg); }`,document.body.appendChild(stylesheet),window.addEventListener("resize",()=>setTimeout(rotate,200)),rotate();