Skip to content

Commit 3f4dcc9

Browse files
committed
Updated style for channel shuffle button
1 parent 73d6a60 commit 3f4dcc9

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/content.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ document.addEventListener("yt-navigate-finish", startDOMObserver);
2828
async function startDOMObserver(event) {
2929
// Sometimes, YouTube changes contents of the event or the page structure. Whenever we encounter an identifying change, we update this variable to track it through the process
3030
let eventVersion = "default";
31-
console.log("yt-navigate-finish event fired");
3231
resetShuffleButtonText();
33-
console.log("Reset shuffle button text");
3432

3533
let pageType = getPageTypeFromURL(window.location.href);
36-
console.log(event)
37-
console.log(pageType)
34+
// console.log(event)
35+
// console.log(pageType)
3836

3937
// Get the channel id from the event data
4038
let channelId;
@@ -56,8 +54,9 @@ async function startDOMObserver(event) {
5654
channelName = event?.detail?.response?.response?.header?.pageHeaderRenderer?.pageTitle;
5755
}
5856
}
59-
console.log(channelId)
60-
console.log(channelName)
57+
// console.log(channelId)
58+
// console.log(channelName)
59+
console.log(eventVersion);
6160

6261
if (!channelId?.startsWith("UC")) {
6362
// If no valid channelId was provided in the event, we won't be able to add the button
@@ -82,8 +81,6 @@ async function startDOMObserver(event) {
8281
shortsPageRequiredElementLoadComplete = true;
8382
}
8483

85-
console.log(channelPageRequiredElementLoadComplete)
86-
8784
// If the required element has loaded, add the shuffle button
8885
if (pageType === "video" && videoPageRequiredElementLoadComplete) {
8986
me.disconnect(); // Stop observing

src/domManipulation.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,23 @@ export function buildShuffleButton(pageType, channelId, eventVersion, clickHandl
1515
switch (pageType) {
1616
case "channel":
1717
buttonDivID = "youtube-random-video-large-shuffle-button-channel";
18-
buttonDivExtraStyle = "margin-left: 14px;";
1918
switch (eventVersion) {
2019
case "default":
2120
buttonDivOwner = [document.getElementById("channel-header").querySelector("#inner-header-container").children.namedItem("buttons")];
21+
buttonDivExtraStyle = "margin-left: 8px;";
2222
break;
2323
case "newYTFinishEvent20240521":
2424
buttonDivOwner = [document.getElementById("page-header").querySelector(".page-header-view-model-wiz__page-header-headline-info").getElementsByTagName("yt-flexible-actions-view-model")[0]];
2525
break;
2626
}
2727
break;
28+
// TODO: Fix video shuffle button
2829
case "video":
2930
buttonDivID = "youtube-random-video-large-shuffle-button-video";
3031
buttonDivExtraStyle = "margin-left: 8px;";
3132
buttonDivOwner = [document.getElementById("above-the-fold").children.namedItem("top-row").children.namedItem("owner")];
3233
break;
34+
// TODO: Shorts seem fine, but the button has a different background color from the others
3335
case "short":
3436
isLargeButton = false;
3537
buttonDivID = "youtube-random-video-small-shuffle-button-short";
@@ -43,6 +45,7 @@ export function buildShuffleButton(pageType, channelId, eventVersion, clickHandl
4345

4446
console.log(buttonDivOwner);
4547

48+
// TODO: How does this work with the new layout?
4649
// If we are on a video page, modify the "min-width" of the two divs holding the buttons to make room for the 'Shuffle' button
4750
// This doesn't fix them overlapping in all cases, but most times it does
4851
if (pageType == "video") {
@@ -95,6 +98,7 @@ export function buildShuffleButton(pageType, channelId, eventVersion, clickHandl
9598

9699
// Create the button div & renderer
97100
let buttonDiv;
101+
// TODO: Check if the new styling for video page buttons is the same as for channel page buttons
98102
if (pageType === "channel" || pageType === "video") {
99103
buttonDiv = `
100104
<div id="${buttonDivID}" class="style-scope ytd-c4-tabbed-header-renderer" style="align-items: center; display: flex; flex-direction: row; ${buttonDivExtraStyle}">

0 commit comments

Comments
 (0)