From 579628dde1d6cfc9ad031d1a5a27bbddff596fb1 Mon Sep 17 00:00:00 2001 From: ImprovedTube Date: Wed, 3 Apr 2024 04:49:27 +0200 Subject: [PATCH] #2149 --- js&css/web-accessible/functions.js | 3 +- .../web-accessible/www.youtube.com/player.js | 36 ++++++++++--------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/js&css/web-accessible/functions.js b/js&css/web-accessible/functions.js index 96873f454..efd7d6881 100644 --- a/js&css/web-accessible/functions.js +++ b/js&css/web-accessible/functions.js @@ -555,7 +555,8 @@ ImprovedTube.createPlayerButton = function (options) { tooltip.style.top = rect.top - 8 + 'px'; tooltip.textContent = this.dataset.title; - tooltip.style.zIndex = 10001; // needed for cinema mode +if (this.storage.player_cinema_mode_button || this.storage.player_auto_hide_cinema_mode_when_paused || this.storage.player_auto_cinema_mode){ +tooltip.style.zIndex = 10001;} // needed for cinema mode function mouseleave() { tooltip.remove(); diff --git a/js&css/web-accessible/www.youtube.com/player.js b/js&css/web-accessible/www.youtube.com/player.js index 1c7f49307..bed321991 100644 --- a/js&css/web-accessible/www.youtube.com/player.js +++ b/js&css/web-accessible/www.youtube.com/player.js @@ -829,6 +829,7 @@ ImprovedTube.playerFitToWinButton = function () { /*------------------------------------------------------------------------------ CINEMA MODE BUTTON ------------------------------------------------------------------------------*/ + var xpath = function(xpathToExecute){ var result = []; var nodesSnapshot = document.evaluate(xpathToExecute, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); @@ -853,7 +854,7 @@ function createOverlay() { } ImprovedTube.playerCinemaModeButton = function () { - if (this.storage.player_cinema_mode_button === true && (/watch\?/.test(location.href))) { + if (this.storage.player_cinema_mode_button && (/watch\?/.test(location.href))) { var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'), path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); @@ -870,7 +871,7 @@ ImprovedTube.playerCinemaModeButton = function () { opacity: 0.64, onclick: function () { var player = xpath('//*[@id="movie_player"]/div[1]/video')[0].parentNode.parentNode - console.log(player) + // console.log(player) if (player.style.zIndex == 10000){ player.style.zIndex = 1; svg.parentNode.style.opacity = 0.64; @@ -888,7 +889,7 @@ ImprovedTube.playerCinemaModeButton = function () { } else { overlay.style.display = overlay.style.display === 'none' || overlay.style.display === '' ? 'block' : 'none'; } - console.log(overlay) + //console.log(overlay) }, title: 'Cinema Mode' }); @@ -896,39 +897,42 @@ ImprovedTube.playerCinemaModeButton = function () { } ImprovedTube.playerCinemaModeDisable = function () { - var overlay = document.getElementById('overlay_cinema'); - if (overlay && this.storage.player_auto_hide_cinema_mode_when_paused === true) { - overlay.style.display = 'none' - var player = xpath('//*[@id="movie_player"]/div[1]/video')[0].parentNode.parentNode - player.style.zIndex = 1; - var cinemaModeButton = xpath('//*[@id="it-cinema-mode-button"]')[0] - cinemaModeButton.style.opacity = 0.64 - + if (this.storage.player_auto_hide_cinema_mode_when_paused) { + var overlay = document.getElementById('overlay_cinema'); + if (overlay) { + overlay.style.display = 'none' + var player = xpath('//*[@id="movie_player"]/div[1]/video')[0].parentNode.parentNode + player.style.zIndex = 1; + var cinemaModeButton = xpath('//*[@id="it-cinema-mode-button"]')[0] + cinemaModeButton.style.opacity = 0.64 + } } } ImprovedTube.playerCinemaModeEnable = function () { + if (this.storage.player_auto_cinema_mode || this.storage.player_auto_hide_cinema_mode_when_paused) { + if ((/watch\?/.test(location.href))) { var overlay = document.getElementById('overlay_cinema'); + if (this.storage.player_auto_cinema_mode === true && !overlay) { createOverlay(); overlay = document.getElementById('overlay_cinema'); } - console.log(overlay && this.storage.player_auto_hide_cinema_mode_when_paused === true || this.storage.player_auto_cinema_mode === true && overlay) - if (overlay && this.storage.player_auto_hide_cinema_mode_when_paused === true || this.storage.player_auto_cinema_mode === true && overlay) { +// console.log(overlay && this.storage.player_auto_hide_cinema_mode_when_paused === true || this.storage.player_auto_cinema_mode === true && overlay) + if (overlay) { overlay.style.display = 'block' var player = xpath('//*[@id="movie_player"]/div[1]/video')[0].parentNode.parentNode player.style.zIndex = 10000; - console.log(player) + // console.log(player) var cinemaModeButton = xpath('//*[@id="it-cinema-mode-button"]')[0] cinemaModeButton.style.opacity = 1 } } - + } } - /*------------------------------------------------------------------------------ HAMBURGER MENU ------------------------------------------------------------------------------*/