From a19174c7b367bfcc956f5502b7fb4c35042ed301 Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 23 Sep 2023 14:07:05 -0400 Subject: [PATCH] Allow display of channel watermarks to be optional --- assets/js/player.js | 2 +- config/config.example.yml | 9 +++++++++ locales/en-US.json | 1 + src/invidious/config.cr | 1 + src/invidious/routes/preferences.cr | 5 +++++ src/invidious/user/preferences.cr | 1 + src/invidious/views/user/preferences.ecr | 7 ++++++- 7 files changed, 24 insertions(+), 2 deletions(-) diff --git a/assets/js/player.js b/assets/js/player.js index bfb9decb..76ff2bd0 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -765,7 +765,7 @@ if (location.pathname.startsWith('/embed/')) { } // Channel watermark -if (video_data.watermark) { +if (video_data.watermark && video_data.preferences.show_channel_watermark) { const watermark_html = ``; player.overlay({ diff --git a/config/config.example.yml b/config/config.example.yml index b44fcc0e..4c10b3a7 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -823,6 +823,15 @@ default_user_preferences: ## #save_player_pos: false + ## + ## Show the channel's watermark on the bottom-rght corner of videos + ## + ## Accepted values: true, false + ## Default: false + ## + #show_channel_watermark: true + + # ----------------------------- # Subscription feed # ----------------------------- diff --git a/locales/en-US.json b/locales/en-US.json index a9f78165..243a3d26 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -472,6 +472,7 @@ "user_saved_playlists": "`x` saved playlists", "Video unavailable": "Video unavailable", "preferences_save_player_pos_label": "Save playback position: ", + "preferences_show_channel_watermark_label": "Show channel watermark: ", "crash_page_you_found_a_bug": "It looks like you found a bug in Invidious!", "crash_page_before_reporting": "Before reporting a bug, make sure that you have:", "crash_page_refresh": "tried to refresh the page", diff --git a/src/invidious/config.cr b/src/invidious/config.cr index 429d9246..9f70e268 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -44,6 +44,7 @@ struct ConfigPreferences property vr_mode : Bool = true property show_nick : Bool = true property save_player_pos : Bool = false + property show_channel_watermark : Bool = true def to_tuple {% begin %} diff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.cr index 112535bd..6f25213b 100644 --- a/src/invidious/routes/preferences.cr +++ b/src/invidious/routes/preferences.cr @@ -78,6 +78,10 @@ module Invidious::Routes::PreferencesRoute save_player_pos ||= "off" save_player_pos = save_player_pos == "on" + show_channel_watermark = env.params.body["show_channel_watermark"]?.try &.as(String) + show_channel_watermark ||= "off" + show_channel_watermark = show_channel_watermark == "on" + show_nick = env.params.body["show_nick"]?.try &.as(String) show_nick ||= "off" show_nick = show_nick == "on" @@ -175,6 +179,7 @@ module Invidious::Routes::PreferencesRoute vr_mode: vr_mode, show_nick: show_nick, save_player_pos: save_player_pos, + show_channel_watermark: show_channel_watermark, }.to_json) if user = env.get? "user" diff --git a/src/invidious/user/preferences.cr b/src/invidious/user/preferences.cr index b3059403..3f4e08aa 100644 --- a/src/invidious/user/preferences.cr +++ b/src/invidious/user/preferences.cr @@ -55,6 +55,7 @@ struct Preferences property extend_desc : Bool = CONFIG.default_user_preferences.extend_desc property volume : Int32 = CONFIG.default_user_preferences.volume property save_player_pos : Bool = CONFIG.default_user_preferences.save_player_pos + property show_channel_watermark : Bool = CONFIG.default_user_preferences.show_channel_watermark module BoolToString def self.to_json(value : String, json : JSON::Builder) diff --git a/src/invidious/views/user/preferences.ecr b/src/invidious/views/user/preferences.ecr index 55349c5a..717827f7 100644 --- a/src/invidious/views/user/preferences.ecr +++ b/src/invidious/views/user/preferences.ecr @@ -117,10 +117,15 @@
- + checked<% end %>>
+
+ + checked<% end %>> +
+ <%= translate(locale, "preferences_category_visual") %>