Skip to content

Commit

Permalink
feat: Hide live stream chat #452
Browse files Browse the repository at this point in the history
  • Loading branch information
VampireChicken12 committed Apr 26, 2024
1 parent fb9b6b4 commit e823cb5
Show file tree
Hide file tree
Showing 28 changed files with 168 additions and 17 deletions.
4 changes: 4 additions & 0 deletions public/locales/ca-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Automatic theater mode",
"title": "Automatically enables theater mode when you load a video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Hide scrollbar",
"title": "Hides the pages scrollbar"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/cs-CZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Automatic theater mode",
"title": "Automatically enables theater mode when you load a video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Hide scrollbar",
"title": "Hides the pages scrollbar"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Automatischer Theatermodus",
"title": "Automatisch den Theatermodus aktivieren, wenn ein Video geladen wird"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Scrollbar ausblenden",
"title": "Versteckt die Scrollleiste"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Automatic theatre mode",
"title": "Automatically enables theatre mode when you load a video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Hide scrollbar",
"title": "Hides the pages scrollbar"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Automatic theater mode",
"title": "Automatically enables theater mode when you load a video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Hide scrollbar",
"title": "Hides the pages scrollbar"
Expand Down
1 change: 1 addition & 0 deletions public/locales/en-US.json.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ interface EnUS {
label: "Automatic theater mode";
title: "Automatically enables theater mode when you load a video";
};
hideLiveStreamChat: { label: "Hide live stream chat"; title: "Hides the live stream chat" };
hideScrollbar: { label: "Hide scrollbar"; title: "Hides the pages scrollbar" };
hideShorts: { label: "Hide shorts"; title: "Hides all shorts" };
loopButton: {
Expand Down
4 changes: 4 additions & 0 deletions public/locales/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Modo cine automático",
"title": "Activar automáticamente el modo cine al cargar un vídeo"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Ocultar barra de desplazamiento",
"title": "Oculta la barra de desplazamiento de la página"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/fa-IR.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Automatic theater mode",
"title": "Automatically enables theater mode when you load a video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Hide scrollbar",
"title": "Hides the pages scrollbar"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Mode cinéma automatique",
"title": "Activer automatiquement le mode cinéma lorsque vous chargez une vidéo"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Cacher la barre de défilement",
"title": "Cache la barre de défilement des pages"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/he-IL.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Automatic theater mode",
"title": "Automatically enables theater mode when you load a video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Hide scrollbar",
"title": "Hides the pages scrollbar"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/hi-IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Automatic theater mode",
"title": "Automatically enables theater mode when you load a video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Hide scrollbar",
"title": "Hides the pages scrollbar"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Modalità teatro automatica",
"title": "Attiva automaticamente la modalità teatro quando carichi un video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Nascondi barra scorrimento",
"title": "Nasconde la barra di scorrimento delle pagine"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "自動シアターモード",
"title": "動画の読み込み時に自動的にシアターモードを有効にする"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "スクロールバー隠す機能",
"title": "ページのスクロールバーを隠す"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/pl-PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Automatic theater mode",
"title": "Automatically enables theater mode when you load a video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Hide scrollbar",
"title": "Hides the pages scrollbar"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Modo teatro automático",
"title": "Ativar automaticamente o modo teatro quando você carregar um vídeo"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Ocultar a barra de rolagem",
"title": "Oculta a barra de rolagem da página"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Включить автоматический режим кинотеатра",
"title": "Автоматически включать режим кинотеатра при загрузке видео"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Включить скрытие полосы прокрутки страницы",
"title": "Скрывает полосу прокрутки страницы"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/sv-SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Automatiskt teaterläge",
"title": "Aktiverar automatiskt teaterläge när du startar en video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Dölj rullningslisten",
"title": "Döljer sidornas rullningsfält"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/tr-TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "Otomatik tiyatro modu",
"title": "Video yüklediğinizde tiyatro modunu otomatik olarak etkinleştirir"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "Kaydırma çubuğu gizlemeyi etkinleştir",
"title": "Sayfa kaydırma çubuğunu gizler"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "自动启用剧场模式",
"title": "当视频打开时,自动启用剧场模式"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "启用隐藏滚动条",
"title": "隐藏页面滚动条"
Expand Down
4 changes: 4 additions & 0 deletions public/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"label": "自動啟用劇院模式",
"title": "載入影片時自動啟用劇院模式"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
},
"hideScrollbar": {
"label": "隱藏捲軸",
"title": "隱藏頁面捲軸"
Expand Down
20 changes: 14 additions & 6 deletions src/components/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,14 @@ export default function Settings() {
title={t("settings.sections.miscellaneous.features.hideShorts.title")}
type="checkbox"
/>
<Setting
checked={settings.enable_hide_live_stream_chat?.toString() === "true"}
id="enable_hide_live_stream_chat"
label={t("settings.sections.miscellaneous.features.hideLiveStreamChat.label")}
onChange={setCheckboxOption("enable_hide_live_stream_chat")}
title={t("settings.sections.miscellaneous.features.hideLiveStreamChat.title")}
type="checkbox"
/>
</SettingSection>
<SettingSection>
<SettingTitle title={t("settings.sections.videoHistory.title")} />
Expand Down Expand Up @@ -1087,15 +1095,15 @@ export default function Settings() {
</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 dark:hover:bg-[rgba(24,26,27,0.5)] sm:text-base md:text-lg"
className="danger p-2 text-sm sm:text-base md:text-lg dark:hover:bg-[rgba(24,26,27,0.5)]"
id="clear_data_button"
onClick={clearData}
title={t("settings.sections.bottomButtons.clear.title")}
type="button"
value={t("settings.sections.bottomButtons.clear.value")}
/>
<input
className="accent p-2 text-sm dark:hover:bg-[rgba(24,26,27,0.5)] sm:text-base md:text-lg"
className="accent p-2 text-sm sm:text-base md:text-lg dark:hover:bg-[rgba(24,26,27,0.5)]"
id="import_settings_button"
onClick={importSettings}
title={t("settings.sections.importExportSettings.importButton.title")}
Expand All @@ -1104,7 +1112,7 @@ export default function Settings() {
/>
{isPopup && (
<button
className="accent flex items-center justify-center p-2 text-sm dark:hover:bg-[rgba(24,26,27,0.5)] sm:text-base md:text-lg"
className="accent flex items-center justify-center p-2 text-sm sm:text-base md:text-lg dark:hover:bg-[rgba(24,26,27,0.5)]"
id="openinnewtab_button"
onClick={() => openInNewTab("src/pages/options/index.html")}
title={t("settings.sections.bottomButtons.openTab.title")}
Expand All @@ -1114,7 +1122,7 @@ export default function Settings() {
</button>
)}
<input
className="accent p-2 text-sm dark:hover:bg-[rgba(24,26,27,0.5)] sm:text-base md:text-lg"
className="accent p-2 text-sm sm:text-base md:text-lg dark:hover:bg-[rgba(24,26,27,0.5)]"
id="export_settings_button"
onClick={exportSettings}
title={t("settings.sections.importExportSettings.exportButton.title")}
Expand All @@ -1123,7 +1131,7 @@ export default function Settings() {
/>
{notifications.filter((n) => n.action === "reset_settings").length > 0 ?
<input
className="danger p-2 text-sm dark:hover:bg-[rgba(24,26,27,0.5)] sm:text-base md:text-lg"
className="danger p-2 text-sm sm:text-base md:text-lg dark:hover:bg-[rgba(24,26,27,0.5)]"
id="confirm_button"
onClick={() => {
const notificationToRemove = notifications.find((n) => n.action === "reset_settings");
Expand All @@ -1146,7 +1154,7 @@ export default function Settings() {
value={t("settings.sections.bottomButtons.confirm.value")}
/>
: <input
className="warning p-2 text-sm dark:hover:bg-[rgba(24,26,27,0.5)] sm:text-base md:text-lg"
className="warning p-2 text-sm sm:text-base md:text-lg dark:hover:bg-[rgba(24,26,27,0.5)]"
id="reset_button"
onClick={resetOptions}
title={t("settings.sections.bottomButtons.reset.title")}
Expand Down
3 changes: 3 additions & 0 deletions src/features/hideLiveStreamChat/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.yte-hide-live-stream-chat {
display: none !important;
}
42 changes: 42 additions & 0 deletions src/features/hideLiveStreamChat/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { YouTubePlayerDiv } from "@/src/types";

import { type ElementClassPair, modifyElementsClassList, waitForAllElements, waitForSpecificMessage } from "@/src/utils/utilities";

import "./index.css";
const liveStreamChatElementPairs: ElementClassPair[] = [
{
className: "yte-hide-live-stream-chat",
selector: "div#chat-container"
},
{
className: "yte-hide-live-stream-chat",
selector: "div#chat-container #chat"
},
{
className: "yte-hide-live-stream-chat",
selector: "#full-bleed-container #panels-full-bleed-container"
}
];
export async function enableHideLiveStreamChat() {
const optionsData = await waitForSpecificMessage("options", "request_data", "content");
const {
data: {
options: { enable_hide_live_stream_chat: enableHideLiveStreamChat }
}
} = optionsData;
if (!enableHideLiveStreamChat) return;
await waitForAllElements(["div#player", "div#player-wide-container", "div#video-container", "div#player-container"]);
const player = document.querySelector<YouTubePlayerDiv>("div#movie_player");
if (!player) return;
const playerData = await player.getVideoData();
if (!playerData.isLive) return;
modifyElementsClassList("add", liveStreamChatElementPairs);
}

export async function disableHideLiveStreamChat() {
const player = document.querySelector<YouTubePlayerDiv>("div#movie_player");
if (!player) return;
const playerData = await player.getVideoData();
if (!playerData.isLive) return;
modifyElementsClassList("remove", liveStreamChatElementPairs);
}
18 changes: 9 additions & 9 deletions src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ export const localePercentages: Record<AvailableLocales, number> = {
"en-GB": 2,
"es-ES": 63,
"fa-IR": 0,
"fr-FR": 67,
"fr-FR": 66,
"he-IL": 0,
"hi-IN": 0,
"it-IT": 100,
"ja-JP": 100,
"it-IT": 99,
"ja-JP": 99,
"pl-PL": 0,
"pt-BR": 74,
"ru-RU": 100,
"sv-SE": 98,
"tr-TR": 75,
"zh-CN": 100,
"zh-TW": 95
"pt-BR": 73,
"ru-RU": 99,
"sv-SE": 97,
"tr-TR": 74,
"zh-CN": 99,
"zh-TW": 94
};
export const localeDirection: Record<AvailableLocales, "ltr" | "rtl"> = {
"ca-ES": "ltr",
Expand Down
5 changes: 5 additions & 0 deletions src/pages/content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ const storageChangeHandler = async (changes: StorageChanges, areaName: string) =
playerSpeed: options.player_speed
});
},
enable_hide_live_stream_chat: (__oldValue, newValue) => {
sendExtensionOnlyMessage("hideLiveStreamChatChange", {
hideLiveStreamChatEnabled: newValue
});
},
enable_hide_scrollbar: (__oldValue, newValue) => {
sendExtensionOnlyMessage("hideScrollBarChange", {
hideScrollBarEnabled: newValue
Expand Down
Loading

0 comments on commit e823cb5

Please sign in to comment.