Skip to content

Commit

Permalink
Merge pull request #2382 from raszpl/patch-8
Browse files Browse the repository at this point in the history
playerControls() multiple problems
  • Loading branch information
ImprovedTube authored Jun 15, 2024
2 parents 2bbf665 + 5dc87e6 commit ae021ae
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
7 changes: 4 additions & 3 deletions js&css/web-accessible/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,6 @@ document.addEventListener('it-message-from-extension', function () {
localStorage.removeItem('it-player30fps');
}
}
if (ImprovedTube.storage[message.key]==="when_paused") {
ImprovedTube.whenPaused();
};

switch(camelized_key) {
case 'blocklistActivate':
Expand Down Expand Up @@ -370,6 +367,10 @@ document.addEventListener('it-message-from-extension', function () {
case 'subtitlesBackgroundOpacity':
ImprovedTube.subtitlesUserSettings();
break

case 'playerHideControls':
ImprovedTube.playerControls();
break
}

if (ImprovedTube[camelized_key]) {
Expand Down
63 changes: 35 additions & 28 deletions js&css/web-accessible/www.youtube.com/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -982,36 +982,43 @@ ImprovedTube.playerSDR = function () {
/*------------------------------------------------------------------------------
Hide controls
------------------------------------------------------------------------------*/
ImprovedTube.playerControls = function (pause=false) {
var player = this.elements.player; if (player) {
let hide = this.storage.player_hide_controls;
if (hide === 'always') {
ImprovedTube.playerControls = function () {
const player = this.elements.player,
hide = this.storage.player_hide_controls;

if (player && player.hideControls && player.showControls) {

if (hide === 'when_paused' && this.elements.video.paused) {
player.hideControls();

player.onmouseenter = player.showControls;
player.onmouseleave = player.hideControls;
player.onmousemove = (function() {
let thread,
onmousestop = function() {
if (document.querySelector(".ytp-progress-bar:hover")) {
thread = setTimeout(onmousestop, 1000);
} else {
player.hideControls();
}
};

return function() {
player.showControls();
clearTimeout(thread);
thread = setTimeout(onmousestop, 1000);
};
})();
return;
} else if (hide === 'always') {
player.hideControls();
} else if(hide === 'off') {
} else {
player.showControls();
} else if(hide === 'when_paused') {
if(this.elements.video.paused){
player.hideControls( );

ImprovedTube.elements.player.parentNode.addEventListener('mouseenter', function () {
player.showControls();});
ImprovedTube.elements.player.parentNode.addEventListener('mouseleave', function () {
player.hideControls( );});


ImprovedTube.elements.player.parentNode.onmousemove = (function() {
let onmousestop = function() {
player.hideControls( );
}, thread;

return function() {
player.showControls();
clearTimeout(thread);
thread = setTimeout(onmousestop, 1000);
};
})();
}} else { player.showControls(); }
}
}
player.onmouseenter = null;
player.onmouseleave = null;
player.onmousemove = null;
}
};
/*# HIDE VIDEO TITLE IN FULLSCREEN */ // Easier with CSS only (see player.css)
//ImprovedTube.hideVideoTitleFullScreen = function (){ if (ImprovedTube.storage.hide_video_title_fullScreen === true) {
Expand Down

0 comments on commit ae021ae

Please sign in to comment.