Skip to content

Commit

Permalink
feat: hide end screen cards #373
Browse files Browse the repository at this point in the history
  • Loading branch information
VampireChicken12 committed May 15, 2024
1 parent 96dc516 commit d414119
Show file tree
Hide file tree
Showing 29 changed files with 174 additions and 33 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/locales/ca-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
"label": "Automatic theater mode",
"title": "Automatically enables theater mode when you load a video"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
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 @@ -211,6 +211,10 @@
"label": "Automatic theater mode",
"title": "Automatically enables theater mode when you load a video"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
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 @@ -211,6 +211,10 @@
"label": "Automatischer Theatermodus",
"title": "Automatisch den Theatermodus aktivieren, wenn ein Video geladen wird"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
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 @@ -211,6 +211,10 @@
"label": "Automatic theatre mode",
"title": "Automatically enables theatre mode when you load a video"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
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 @@ -211,6 +211,10 @@
"label": "Automatic theater mode",
"title": "Automatically enables theater mode when you load a video"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
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 @@ -145,6 +145,10 @@ interface EnUS {
label: "Automatic theater mode";
title: "Automatically enables theater mode when you load a video";
};
hideEndScreenCards: {
label: "Hide end screen cards";
title: "Hides the cards at the end of the 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" };
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 @@ -211,6 +211,10 @@
"label": "Modo cine automático",
"title": "Activar automáticamente el modo cine al cargar un vídeo"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
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 @@ -211,6 +211,10 @@
"label": "Automatic theater mode",
"title": "Automatically enables theater mode when you load a video"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
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 @@ -211,6 +211,10 @@
"label": "Mode cinéma automatique",
"title": "Activer automatiquement le mode cinéma lorsque vous chargez une vidéo"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
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 @@ -211,6 +211,10 @@
"label": "Automatic theater mode",
"title": "Automatically enables theater mode when you load a video"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
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 @@ -211,6 +211,10 @@
"label": "Automatic theater mode",
"title": "Automatically enables theater mode when you load a video"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
Expand Down
8 changes: 6 additions & 2 deletions public/locales/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
"label": "Modalità teatro automatica",
"title": "Attiva automaticamente la modalità teatro quando carichi un video"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Nascondi chat live stream",
"title": "Nasconde la chat live stream"
Expand All @@ -224,8 +228,8 @@
"title": "Nasconde tutti i blocchi"
},
"hideTranslateComment": {
"label": "Hide translate comment button",
"title": "Hides 'Translate to Language' button under comments"
"label": "Nascondi pulsante \"Traduci commento\"",
"title": "Nasconde il pulsante 'Traduci in…' sotto i commenti"
},
"loopButton": {
"label": "Pulsante Ripeti",
Expand Down
8 changes: 6 additions & 2 deletions public/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
"label": "自動シアターモード",
"title": "動画の読み込み時に自動的にシアターモードを有効にする"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "配信チャットを隠す",
"title": "配信チャットを隠する"
Expand All @@ -224,8 +228,8 @@
"title": "全ショートを隠す"
},
"hideTranslateComment": {
"label": "Hide translate comment button",
"title": "Hides 'Translate to Language' button under comments"
"label": "コメント翻訳ボタンを隠す",
"title": "コメントの下で「言語に翻訳する」ボタンを隠する"
},
"loopButton": {
"label": "動画ループボタン",
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 @@ -211,6 +211,10 @@
"label": "Automatic theater mode",
"title": "Automatically enables theater mode when you load a video"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
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 @@ -211,6 +211,10 @@
"label": "Modo teatro automático",
"title": "Ativar automaticamente o modo teatro quando você carregar um vídeo"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
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 @@ -211,6 +211,10 @@
"label": "Включить автоматический режим кинотеатра",
"title": "Автоматически включать режим кинотеатра при загрузке видео"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
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 @@ -211,6 +211,10 @@
"label": "Automatiskt teaterläge",
"title": "Aktiverar automatiskt teaterläge när du startar en video"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Hide live stream chat",
"title": "Hides the live stream chat"
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 @@ -211,6 +211,10 @@
"label": "Otomatik tiyatro modu",
"title": "Video yüklediğinizde tiyatro modunu otomatik olarak etkinleştirir"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "Canlı yayın sohbetini gizle",
"title": "Canlı yayın sohbetini gizler"
Expand Down
8 changes: 6 additions & 2 deletions public/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
"label": "自动启用剧场模式",
"title": "当视频打开时,自动启用剧场模式"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "隐藏直播聊天",
"title": "隐藏直播聊天"
Expand All @@ -224,8 +228,8 @@
"title": "隐藏所有短视频"
},
"hideTranslateComment": {
"label": "Hide translate comment button",
"title": "Hides 'Translate to Language' button under comments"
"label": "隐藏翻译评论按钮",
"title": "隐藏评论下方的“翻译至当前语言”按钮"
},
"loopButton": {
"label": "循环按钮",
Expand Down
8 changes: 6 additions & 2 deletions public/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
"label": "自動啟用劇院模式",
"title": "載入影片時自動啟用劇院模式"
},
"hideEndScreenCards": {
"label": "Hide end screen cards",
"title": "Hides the cards at the end of the video"
},
"hideLiveStreamChat": {
"label": "隱藏直播聊天室",
"title": "隱藏直播的聊天室"
Expand All @@ -224,8 +228,8 @@
"title": "隱藏全部 Shorts"
},
"hideTranslateComment": {
"label": "Hide translate comment button",
"title": "Hides 'Translate to Language' button under comments"
"label": "隱藏翻譯留言按鈕",
"title": "隱藏留言下的翻譯按鈕"
},
"loopButton": {
"label": "循環按鈕",
Expand Down
8 changes: 8 additions & 0 deletions src/components/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,14 @@ export default function Settings() {
title={t("settings.sections.miscellaneous.features.hideTranslateComment.title")}
type="checkbox"
/>
<Setting
checked={settings.enable_hide_end_screen_cards?.toString() === "true"}
id="enable_hide_end_screen_cards"
label={t("settings.sections.miscellaneous.features.hideEndScreenCards.label")}
onChange={setCheckboxOption("enable_hide_end_screen_cards")}
title={t("settings.sections.miscellaneous.features.hideEndScreenCards.title")}
type="checkbox"
/>
</SettingSection>
<SettingSection>
<SettingTitle title={t("settings.sections.videoHistory.title")} />
Expand Down
3 changes: 3 additions & 0 deletions src/features/hideEndScreenCards/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.yte-hide-end-screen-cards {
display: none !important;
}
31 changes: 31 additions & 0 deletions src/features/hideEndScreenCards/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { modifyElementsClassList, waitForAllElements, waitForSpecificMessage } from "@/src/utils/utilities";

import "./index.css";
export async function enableHideEndScreenCards() {
const {
data: {
options: { enable_hide_end_screen_cards: enableHideEndScreenCards }
}
} = await waitForSpecificMessage("options", "request_data", "content");
if (!enableHideEndScreenCards) return;

await waitForAllElements(["div#player", "div#player-wide-container", "div#video-container", "div#player-container"]);
modifyElementsClassList(
"add",
Array.from(document.querySelectorAll(".ytp-ce-element")).map((element) => ({
className: "yte-hide-end-screen-cards",
element
}))
);
}

export async function disableHideEndScreenCards() {
await waitForAllElements(["div#player", "div#player-wide-container", "div#video-container", "div#player-container"]);
modifyElementsClassList(
"remove",
Array.from(document.querySelectorAll(".ytp-ce-element")).map((element) => ({
className: "yte-hide-end-screen-cards",
element
}))
);
}
48 changes: 24 additions & 24 deletions src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@ import { type Resource, createInstance } from "i18next";

import { waitForSpecificMessage } from "../utils/utilities";
export const availableLocales = [
"ca-ES",
"cs-CZ",
"de-DE",
"en-GB",
"en-US",
"es-ES",
"fa-IR",
"fr-FR",
"he-IL",
"hi-IN",
"it-IT",
"ja-JP",
"pl-PL",
"pt-BR",
"ru-RU",
"sv-SE",
"tr-TR",
"zh-CN",
"zh-TW"
"ca-ES",
"cs-CZ",
"de-DE",
"en-GB",
"en-US",
"es-ES",
"fa-IR",
"fr-FR",
"he-IL",
"hi-IN",
"it-IT",
"ja-JP",
"pl-PL",
"pt-BR",
"ru-RU",
"sv-SE",
"tr-TR",
"zh-CN",
"zh-TW"
] as const;
export const localePercentages: Record<AvailableLocales, number> = {
"ca-ES": 0,
"cs-CZ": 0,
"de-DE": 35,
"de-DE": 34,
"en-GB": 2,
"en-US": 100,
"es-ES": 61,
"fa-IR": 0,
"fr-FR": 65,
"fr-FR": 64,
"he-IL": 0,
"hi-IN": 0,
"it-IT": 98,
"ja-JP": 98,
"pl-PL": 0,
"pt-BR": 71,
"ru-RU": 97,
"sv-SE": 95,
"tr-TR": 73,
"ru-RU": 96,
"sv-SE": 94,
"tr-TR": 72,
"zh-CN": 98,
"zh-TW": 94
};
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_end_screen_cards: (__oldValue, newValue) => {
sendExtensionOnlyMessage("hideEndScreenCardsChange", {
hideEndScreenCardsEnabled: newValue
});
},
enable_hide_live_stream_chat: (__oldValue, newValue) => {
sendExtensionOnlyMessage("hideLiveStreamChatChange", {
hideLiveStreamChatEnabled: newValue
Expand Down
Loading

0 comments on commit d414119

Please sign in to comment.