Skip to content

Commit

Permalink
Renamed function
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkelM committed Nov 29, 2023
1 parent da6fbb9 commit d2d7d97
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/content.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Content script that is injected into YouTube pages
import { setDOMTextWithDelay, updateSmallButtonStyle, getPageTypeFromURL, RandomYoutubeVideoError, delay } from "./utils.js";
import { setDOMTextWithDelay, updateSmallButtonStyleForText, getPageTypeFromURL, RandomYoutubeVideoError, delay } from "./utils.js";
import { configSync, setSyncStorageValue } from "./chromeStorage.js";
import { buildShuffleButton, shuffleButton, shuffleButtonTextElement, tryRenameUntitledList } from "./domManipulation.js";
import { chooseRandomVideo } from "./shuffleVideo.js";
Expand Down Expand Up @@ -124,7 +124,7 @@ function resetShuffleButtonText() {
if (shuffleButtonTextElement.id.includes("large-shuffle-button")) {
shuffleButtonTextElement.innerText = "\xa0Shuffle";
} else if (shuffleButtonTextElement.innerText !== "autorenew") {
updateSmallButtonStyle(shuffleButtonTextElement, false);
updateSmallButtonStyleForText(shuffleButtonTextElement, false);
shuffleButtonTextElement.innerText = "shuffle";
}
}
Expand Down Expand Up @@ -178,7 +178,7 @@ async function shuffleVideos() {
return;
}

updateSmallButtonStyle(shuffleButtonTextElementCopy, false);
updateSmallButtonStyleForText(shuffleButtonTextElementCopy, false);
shuffleButtonTextElementCopy.innerText = "autorenew";
let rotation = 0;

Expand All @@ -203,15 +203,15 @@ async function shuffleVideos() {
if (shuffleButtonTextElement.id.includes("large-shuffle-button")) {
shuffleButtonTextElement.innerText = "\xa0Shuffle";
} else {
updateSmallButtonStyle(shuffleButtonTextElementCopy, false);
updateSmallButtonStyleForText(shuffleButtonTextElementCopy, false);
shuffleButtonTextElementCopy.innerText = "shuffle";
}
} catch (error) {
console.error(error);

hasBeenShuffled = true;
if (shuffleButton.id.includes("small-shuffle-button")) {
updateSmallButtonStyle(shuffleButtonTextElementCopy, true);
updateSmallButtonStyleForText(shuffleButtonTextElementCopy, true);
}

let displayText = "";
Expand Down
8 changes: 4 additions & 4 deletions src/shuffleVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getLength,
RandomYoutubeVideoError,
YoutubeAPIError,
updateSmallButtonStyle,
updateSmallButtonStyleForText,
getPageTypeFromURL
} from "./utils.js";
import { configSync, setSyncStorageValue, getUserQuotaRemainingToday } from "./chromeStorage.js";
Expand Down Expand Up @@ -1015,7 +1015,7 @@ async function playVideo(chosenVideos, firedFromPopup) {
if (player && player.classList.contains('playing-mode') && !player.classList.contains('unstarted-mode')) {
player.children[0].click();
}
} else if(pageType === "channel") {
} else if (pageType === "channel") {
// Channel page: Pause the featured video if it exists and is playing
const featuredPlayer = document.querySelector('ytd-player#player')?.children[0]?.children[0];
if (featuredPlayer && featuredPlayer.classList.contains('playing-mode') && !featuredPlayer.classList.contains('unstarted-mode')) {
Expand Down Expand Up @@ -1104,9 +1104,9 @@ function updateProgressTextElement(progressTextElement, largeButtonText, smallBu
} else {
// Make it the icon style if an icon is set, otherwise the text style
if (!["shuffle", "close"].includes(smallButtonText)) {
updateSmallButtonStyle(progressTextElement, true);
updateSmallButtonStyleForText(progressTextElement, true);
} else {
updateSmallButtonStyle(progressTextElement, false);
updateSmallButtonStyleForText(progressTextElement, false);
}
progressTextElement.innerText = smallButtonText;
}
Expand Down
6 changes: 3 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function setDOMTextWithDelay(textElement, newText, delayMS, predicate = (
});
}

export function updateSmallButtonStyle(textElement, isTextStyle) {
export function updateSmallButtonStyleForTextForText(textElement, isTextStyle) {
textElement.style.fontSize = isTextStyle ? "12px" : "";
textElement.style.position = isTextStyle ? "absolute" : "";
textElement.style.top = isTextStyle ? "50%" : "";
Expand All @@ -58,9 +58,9 @@ export function updateSmallButtonStyle(textElement, isTextStyle) {
textElement.style.display = isTextStyle ? "flex" : "";

if (isTextStyle) {
textElement.classList.remove("material-symbols-outlined");
textElement.classList.remove("material-symbols-outlined");
} else {
textElement.classList.add("material-symbols-outlined");
textElement.classList.add("material-symbols-outlined");
}
}

Expand Down

0 comments on commit d2d7d97

Please sign in to comment.