Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions js&css/web-accessible/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ ImprovedTube.videoPageUpdate = function () {
ImprovedTube.playerCinemaModeButton();
ImprovedTube.playerHamburgerButton();
ImprovedTube.playerControls();
ImprovedTube.autoPauseOtherVideos();

}
};

Expand Down
33 changes: 25 additions & 8 deletions js&css/web-accessible/www.youtube.com/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ImprovedTube.forcedPlayVideoFromTheBeginning = function () {
video = this.elements.video,
paused = video?.paused;

if (player && video && this.storage.forced_play_video_from_the_beginning && location.pathname == '/watch') {
if (player && video && this.storage.forced_play_video_from_the_beginning && location.pathname === '/watch') {
player.seekTo(0);
// restore previous paused state
if (paused) { player.pauseVideo(); }
Expand Down Expand Up @@ -153,7 +153,7 @@ ImprovedTube.playerPlaybackSpeed = function () { if (this.storage.player_forced_
return;}
if (DATA.keywords && !keywords) { keywords = DATA.keywords.join(', ') || ''; }
if (keywords === 'video, sharing, camera phone, video phone, free, upload') { keywords = ''; }
var musicIdentifiers = /(official|music|lyrics?)[ -]video|(cover|studio|radio|album|alternate)[- ]version|soundtrack|unplugged|\bmedley\b|\blo-fi\b|\blofi\b|a(lla)? cappella|feat\.|(piano|guitar|jazz|ukulele|violin|reggae)[- ](version|cover)|karaok|backing[- ]track|instrumental|(sing|play)[- ]?along|卡拉OK|卡拉OK|الكاريوكي|караоке|カラオケ|노래방|bootleg|mashup|Radio edit|Guest (vocals|musician)|(title|opening|closing|bonus|hidden)[ -]track|live acoustic|interlude|featuring|recorded (at|live)/i;
var musicIdentifiers = /(official|music|lyrics?)[ -]video|(cover|studio|radio|album|alternate)[- ]version|soundtrack|unplugged|\bmedley\b|\blo-fi\b|\blofi\b|a(lla)? cappella|feat\.|(piano|guitar|jazz|ukulele|violin|reggae)[- ](version|cover)|karaok|backing[- ]track|instrumental|(sing|play)[- ]?along|卡拉OK|الكاريوكي|караоке|カラオケ|노래방|bootleg|mashup|Radio edit|Guest (vocals|musician)|(title|opening|closing|bonus|hidden)[ -]track|live acoustic|interlude|featuring|recorded (at|live)/i;
var musicIdentifiersTitleOnly = /lyrics|theme song|\bremix|\bAMV ?[^a-z0-9]|[^a-z0-9] ?AMV\b|\bfull song\b|\bsong:|\bsong[\!$]|^song\b|( - .*\bSong\b|\bSong\b.* - )|cover ?[^a-z0-9]|[^a-z0-9] ?cover|\bconcert\b/i;
var musicIdentifiersTitle = new RegExp(musicIdentifiersTitleOnly.source + '|' + musicIdentifiers.source, "i");
var musicRegexMatch = musicIdentifiersTitle.test(DATA.title);
Expand Down Expand Up @@ -236,7 +236,7 @@ if (title && title !== 'YouTube') {
}
amountOfSongs = (htmlContent.slice(-80000).match(/},"subtitle":{"simpleText":"(\d*)\s/) || [])[1] || false;
if (keywords) { ImprovedTube.speedException(); }
} catch (error) { console.error('Error: fetching from https://Youtube.com/watch?v=${DATA.videoID}', error); keywords = ''; }
} catch (error) { console.error(`Error: fetching from https://Youtube.com/watch?v=${DATA.videoID}`, error); keywords = ''; }
})();
}
}
Expand Down Expand Up @@ -1746,6 +1746,23 @@ ImprovedTube.pauseWhileTypingOnYoutube = function () {
}
};

// AUTO PAUSE OTHER VIDEOS

ImprovedTube.autoPauseOtherVideos = function(){
const currentplayer = ImprovedTube.elements.player;
if(!currentplayer) return ;
currentplayer.addEventListener('play', ()=> {
const allVideos=document.querySelectorAll('video');

allVideos.forEach(video=>{

if(video!==currentplayer && !video.paused){
video.pause();
}
});
});
};

/*------------------------------------------------------------------------------
HIDE PROGRESS BAR PREVIEW
------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -2195,8 +2212,8 @@ SHORTS AUTO SCROLL
------------------------------------------------------------------------------*/
ImprovedTube.shortsAutoScroll = function () {
if (this.storage.shorts_auto_scroll) {
if (!ImprovedTube.shortsAutoScrollInterval) {
ImprovedTube.shortsAutoScrollInterval = setInterval(() => {
if (!ImprovedTube.shortsAutoScroll) {
ImprovedTube.shortsAutoScroll = setInterval(() => {
if (!location.pathname.startsWith('/shorts/')) return;

const activeRenderer = document.querySelector('ytd-reel-video-renderer[is-active]');
Expand Down Expand Up @@ -2224,9 +2241,9 @@ ImprovedTube.shortsAutoScroll = function () {
}, 1000);
}
} else {
if (ImprovedTube.shortsAutoScrollInterval) {
clearInterval(ImprovedTube.shortsAutoScrollInterval);
ImprovedTube.shortsAutoScrollInterval = null;
if (ImprovedTube.shortsAutoScroll) {
clearInterval(ImprovedTube.shortsAutoScroll);
ImprovedTube.shortsAutoScroll = null;
}
}
};