m.YouTube.com auto fullscreen on rotate

Switches the video to full-screen mode when you rotate your smart device

当前为 2023-10-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name m.YouTube.com auto fullscreen on rotate
  3. // @namespace m-youtube-com-auto-fullcreen-on-rotate
  4. // @version 1.0
  5. // @description Switches the video to full-screen mode when you rotate your smart device
  6. // @author hlorand.hu
  7. // @match https://m.youtube.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
  9. // @grant none
  10. // @license https://creativecommons.org/licenses/by-nc-sa/4.0/
  11. // ==/UserScript==
  12.  
  13. // Screenshot: https://ibb.co/chtmD9F
  14.  
  15. (function() {
  16. //'use strict';
  17.  
  18. window.addEventListener("orientationchange", (event) => {
  19. let player = document.getElementById("player-container-id");
  20. let angle = event.target.screen.orientation.angle;
  21.  
  22. // enter fullscreen
  23. if( angle > 60 && angle < 120 || angle > 240 && angle < 300 ){
  24. player.requestFullscreen();
  25. }
  26.  
  27. // exit fullscreen
  28. if( angle > 330 || angle < 30 || angle > 150 && angle < 210 ){
  29. document.exitFullscreen();
  30. }
  31. });
  32.  
  33. })();