Skip to content

Commit

Permalink
Merge branch 'dev' into all-contributors/add-HelloIamarandomperson
Browse files Browse the repository at this point in the history
  • Loading branch information
VampireChicken12 authored Dec 24, 2024
2 parents e5f9136 + a8904af commit e002d75
Show file tree
Hide file tree
Showing 30 changed files with 888 additions and 1,050 deletions.
1,726 changes: 706 additions & 1,020 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"typescript-eslint": "^8.8.1",
"vite": "^5.4.8",
"zod": "^3.22.4",
"zod-error": "^1.5.0"
"zod-error": "^1.5.0",
"npm": "^10.9.2"
}
}
}
6 changes: 5 additions & 1 deletion public/locales/ca-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
},
"playlistRemover": {
"label": "Enable the removal of playlists from homepage",
"title": "Get rid of playlists"
}
},
"title": "Miscellaneous settings"
},
Expand Down
6 changes: 5 additions & 1 deletion public/locales/cs-CZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
},
"playlistRemover": {
"label": "Enable the removal of playlists from homepage",
"title": "Get rid of playlists"
}
},
"title": "Miscellaneous settings"
},
Expand Down
6 changes: 5 additions & 1 deletion public/locales/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
},
"playlistRemover": {
"label": "Enable the removal of playlists from homepage",
"title": "Get rid of playlists"
}
},
"title": "Weitere Einstellungen"
},
Expand Down
6 changes: 5 additions & 1 deletion public/locales/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
},
"playlistRemover": {
"label": "Enable the removal of playlists from homepage",
"title": "Get rid of playlists"
}
},
"title": "Miscellaneous settings"
},
Expand Down
6 changes: 5 additions & 1 deletion public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,11 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
},
"playlistRemover": {
"label": "Enable the removal of playlists from homepage",
"title": "Get rid of playlists"
}
},
"title": "Miscellaneous settings"
},
Expand Down
4 changes: 4 additions & 0 deletions public/locales/en-US.json.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ interface EnUS {
label: 'Skip "Video is paused. Continue watching?"';
title: "Skips the idle dialog that pauses video playback";
};
"playlistRemover": {
"label": "Enable the removal of playlists from homepage",
"title": "Get rid of playlists"
}
};
title: "Miscellaneous settings";
};
Expand Down
2 changes: 1 addition & 1 deletion public/locales/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
}
},
"title": "Ajustes varios"
},
Expand Down
2 changes: 1 addition & 1 deletion public/locales/fa-IR.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
}
},
"title": "Miscellaneous settings"
},
Expand Down
6 changes: 5 additions & 1 deletion public/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
},
"playlistRemover": {
"label": "Enable the removal of playlists from homepage",
"title": "Get rid of playlists"
}
},
"title": "Autre paramètres"
},
Expand Down
2 changes: 1 addition & 1 deletion public/locales/he-IL.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
}
},
"title": "Miscellaneous settings"
},
Expand Down
2 changes: 1 addition & 1 deletion public/locales/hi-IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
}
},
"title": "Miscellaneous settings"
},
Expand Down
2 changes: 1 addition & 1 deletion public/locales/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"skipContinueWatching": {
"label": "Salta \"Video in pausa. Continuare a guardare?\"",
"title": "Salta la finestra che mette in pausa la riproduzione video"
}
}
},
"title": "Impostazioni varie"
},
Expand Down
2 changes: 1 addition & 1 deletion public/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"skipContinueWatching": {
"label": "「動画が一時停止されました。続きを視聴しますか?」を抜かする",
"title": "動画一時休止する休眠メッセージを抜かされます"
}
}
},
"title": "他の設定"
},
Expand Down
2 changes: 1 addition & 1 deletion public/locales/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"skipContinueWatching": {
"label": "'동영상이 일시중지되었습니다. 이어서 시청하시겠어요?' 팝업 스킵",
"title": "'동영상이 일시중지되었습니다. 이어서 시청하시겠어요?' 팝업을 자동으로 스킵하여 끊김 없는 재생을 유지합니다."
}
}
},
"title": "기타 설정"
},
Expand Down
2 changes: 1 addition & 1 deletion public/locales/pl-PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
}
},
"title": "Miscellaneous settings"
},
Expand Down
2 changes: 1 addition & 1 deletion public/locales/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
}
},
"title": "Configurações diversas"
},
Expand Down
6 changes: 5 additions & 1 deletion public/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@
"skipContinueWatching": {
"label": "Пропускать \"Воспроизведение приостановлено. Продолжить?\"",
"title": "Автоматически пропускает диалог простоя, который приостанавливает воспроизведение"
}
},
"playlistRemover": {
"label": "Enable the removal of playlists from homepage",
"title": "Get rid of playlists"
}
},
"title": "Прочие параметры"
},
Expand Down
2 changes: 1 addition & 1 deletion public/locales/sv-SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"skipContinueWatching": {
"label": "Hoppa över \"Videon är pausad. Fortsätt titta?\"",
"title": "Hoppa över dialogrutan som pausar videouppspelningen"
}
}
},
"title": "Övriga inställningar"
},
Expand Down
2 changes: 1 addition & 1 deletion public/locales/tr-TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
}
},
"title": "Çeşitli ayarlar"
},
Expand Down
2 changes: 1 addition & 1 deletion public/locales/uk-UA.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
}
},
"title": "Miscellaneous settings"
},
Expand Down
2 changes: 1 addition & 1 deletion public/locales/vi-VN.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"skipContinueWatching": {
"label": "Skip \"Video is paused. Continue watching?\"",
"title": "Skips the idle dialog that pauses video playback"
}
}
},
"title": "Miscellaneous settings"
},
Expand Down
2 changes: 1 addition & 1 deletion public/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"skipContinueWatching": {
"label": "跳過「影片已暫停,繼續觀看?」",
"title": "跳過暫停影片播放的閒置對話框"
}
}
},
"title": "其他設定"
},
Expand Down
11 changes: 9 additions & 2 deletions src/components/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,15 @@ export default function Settings() {
label={t("settings.sections.miscellaneous.features.automaticallyDisableClosedCaptions.label")}
onChange={setCheckboxOption("enable_automatically_disable_closed_captions")}
title={t("settings.sections.miscellaneous.features.automaticallyDisableClosedCaptions.title")}
type="checkbox"
type="checkbox"
/>
<Setting
checked={settings.enable_hide_playlist_recommendations_from_home_page?.toString() === "true"}
id="enable_hide_playlist_recommendations_from_home_page"
label={t("settings.sections.miscellaneous.features.playlistRemover.label")}
onChange={setCheckboxOption("enable_hide_playlist_recommendations_from_home_page")}
title={t("settings.sections.miscellaneous.features.playlistRemover.title")}
type="checkbox"
/>
<Setting
checked={settings.enable_automatically_disable_ambient_mode?.toString() === "true"}
Expand Down Expand Up @@ -1284,7 +1292,6 @@ export default function Settings() {
value={settings.custom_css_code}
/>
</SettingSection>

<div className="sticky bottom-0 left-0 z-10 flex justify-between gap-1 bg-[#f5f5f5] p-2 dark:bg-[#181a1b]">
<input
className="danger p-2 text-sm sm:text-base md:text-lg dark:hover:bg-[rgba(24,26,27,0.5)]"
Expand Down
85 changes: 85 additions & 0 deletions src/features/hidePlaylist/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import type { Nullable } from "@/src/types";
import { waitForSpecificMessage } from "@/src/utils/utilities";

let recommendationsObserver: Nullable<MutationObserver> = null;
let observerDisabled = false;

export async function enableHidePlaylistRecommendationsFromHomePage() {
const {
data: {
options: { enable_hide_playlist_recommendations_from_home_page },
},
} = await waitForSpecificMessage("options", "request_data", "content");

if (!enable_hide_playlist_recommendations_from_home_page) return;

hideRecommendations();
observeHomePageRecommendations();
}

export function disableHidePlaylistRecommendationsFromHomePage() {
showRecommendations();

if (recommendationsObserver) {
recommendationsObserver.disconnect();
recommendationsObserver = null;
}
}

function observeHomePageRecommendations() {
const homePageObserver = new MutationObserver((mutations) => {
if (observerDisabled) return;

mutations.forEach((mutation) => {
if (mutation.addedNodes.length) {
Array.from(mutation.addedNodes).forEach((node) => {
if (node instanceof HTMLElement && node.tagName === "YTD-RICH-ITEM-RENDERER") {
hideMixRecommendation(node);
} else if (node instanceof HTMLElement) {
node.querySelectorAll<HTMLElement>("ytd-rich-item-renderer").forEach(hideMixRecommendation);
}
});
}
});

if (hasRecommendationsOnHomePage()) {
hideRecommendations();
}
});

homePageObserver.observe(document.body, { childList: true, subtree: true });
recommendationsObserver = homePageObserver;
}

function hideMixRecommendation(element: HTMLElement) {
if (element.querySelector("yt-collection-thumbnail-view-model")) {
element.style.display = "none";
}
}

function toggleRecommendationsVisibility(recommendationsVisible: boolean) {
// Use requestAnimationFrame to ensure synchronization
requestAnimationFrame(() => {
observerDisabled = !recommendationsVisible;

const richItemRenderers = document.querySelectorAll<HTMLElement>("ytd-rich-item-renderer");
richItemRenderers.forEach((item) => {
const mixThumbnail = item.querySelector("yt-collection-thumbnail-view-model");
if (mixThumbnail) {
item.style.display = recommendationsVisible ? "" : "none";
}
});
});
}

function hideRecommendations() {
toggleRecommendationsVisibility(false);
}

function showRecommendations() {
toggleRecommendationsVisibility(true);
}

function hasRecommendationsOnHomePage(): boolean {
return document.querySelector("ytd-rich-grid-renderer #contents ytd-rich-item-renderer") !== null;
}
8 changes: 6 additions & 2 deletions src/pages/content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from "@/src/types";
import { defaultConfiguration } from "@/src/utils/constants";
import { parseStoredValue, sendExtensionMessage, sendExtensionOnlyMessage } from "@/src/utils/utilities";

/**
* Adds a script element to the document's root element, which loads a JavaScript file from the extension's runtime URL.
* Also creates a hidden div element with a specific ID to receive messages from the extension.
Expand Down Expand Up @@ -483,7 +482,12 @@ const storageChangeHandler = async (changes: StorageChanges, areaName: string) =
volumeBoostEnabled: options.enable_volume_boost,
volumeBoostMode: newValue
});
}
},
enable_hide_playlist_recommendations_from_home_page: (__oldValue, newValue) => {
sendExtensionOnlyMessage("hidePlaylistRecommendationsFromHomePageChange", {
hidePlaylistRecommendationsFromHomePageEnabled: newValue,
})
}
};
Object.entries(castedChanges).forEach(([key, change]) => {
if (isValidChange(change)) {
Expand Down
Loading

0 comments on commit e002d75

Please sign in to comment.