Skip to content

Commit

Permalink
fix #1768 fixing playlist repeat & shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
ImprovedTube committed Sep 29, 2023
1 parent 74ba70b commit dee477b
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions js&css/web-accessible/www.youtube.com/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,34 @@ ImprovedTube.playlistRepeat = function () {
if ( ImprovedTube.storage.playlist_repeat === true ) {
setTimeout(function (){
var option = ImprovedTube.storage.playlist_repeat,
button = document.querySelector("ytd-playlist-loop-button-renderer button"),
button = document.querySelector("#button.ytd-playlist-loop-button-renderer") || document.querySelector("ytd-playlist-loop-button-renderer button") || document.querySelector("ytd-playlist-loop-button-renderer");
svg = button.querySelector("path").attributes.d.textContent.split(" ")[0];
if (button && ((option === true && svg !== 'M20,14h2v5L5.84,19.02l1.77,1.77l-1.41,1.41L1.99,18l4.21-4.21l1.41,1.41l-1.82,1.82L20,17V14z')
// || (option === false && svg !== 'M21,13h1v5L3.93,18.03l2.62,2.62l-0.71,0.71L1.99,17.5l3.85-3.85l0.71,0.71l-2.67,2.67L21,17V13z')
)) { button.click(); }
if (button && (option === true && svg.startsWith('M21')
) && button.querySelector("#tooltip")?.textContent !== 'Loop video'
&& button.firstElementChild?.firstElementChild?.attributes[2]?.textContent !== 'Loop video'
&& button.querySelector("#tooltip")?.textContent !== 'Turn off loop'
&& button.firstElementChild?.firstElementChild?.attributes[2]?.textContent !== 'Turn off loop'
)
{ button.click(); }
}, 5000);
}
};

/* https://github.com/code-charity/youtube/issues/1768#issuecomment-1720423923 */

/*------------------------------------------------------------------------------
4.5.4 SHUFFLE
------------------------------------------------------------------------------*/
ImprovedTube.playlistShuffle = function () {
var button = ImprovedTube.elements.playlist.shuffle_button,
if ( ImprovedTube.storage.playlist_shuffle === true ) {
setTimeout(function (){
var button = ImprovedTube.elements.playlist.shuffle_button,
option = ImprovedTube.storage.playlist_shuffle;
try{
if (button && ((option === true && button.firstElementChild.firstElementChild.attributes[2].textContent !== 'Loop video') || (option === 'disabled' && button.firstElementChild.firstElementChild.attributes[2].textContent === 'Loop playlist'))) {
button.click();
}
}catch{}
button = document.querySelector('#playlist-actions #playlist-action-menu ytd-toggle-button-renderer');
svg = button.querySelector("path").attributes.d.textContent.split(" ")[0];
if (button && (option === true && svg.startsWith('M18.1')
) )
{ button.click(); }
}, 5000);
}
};

0 comments on commit dee477b

Please sign in to comment.