mirror of
https://github.com/iv-org/invidious.git
synced 2026-09-07 17:42:46 -05:00
Add error message when comments are disabled
This commit is contained in:
parent
986471320d
commit
1cf31f9309
@ -418,7 +418,7 @@ p.channel-name { margin: 0; overflow-wrap: anywhere;}
|
|||||||
p.video-data { margin: 0; font-weight: bold; font-size: 80%; }
|
p.video-data { margin: 0; font-weight: bold; font-size: 80%; }
|
||||||
|
|
||||||
.channel-profile > .channel-name,
|
.channel-profile > .channel-name,
|
||||||
.channel-profile > .channel-name-pronouns > .channel-name
|
.channel-profile > .channel-name-pronouns > .channel-name
|
||||||
{
|
{
|
||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
@ -909,4 +909,8 @@ h1, h2, h3, h4, h5, p,
|
|||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#comments-turned-off-on-video-message > p, #comments-disabled-message > p {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|||||||
@ -53,6 +53,10 @@ function show_youtube_replies(event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_youtube_comments() {
|
function get_youtube_comments() {
|
||||||
|
if (!video_data.comments_enabled) {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
var comments = document.getElementById('comments');
|
var comments = document.getElementById('comments');
|
||||||
|
|
||||||
var fallback = comments.innerHTML;
|
var fallback = comments.innerHTML;
|
||||||
|
|||||||
@ -190,8 +190,5 @@ addEventListener('load', function (e) {
|
|||||||
get_youtube_comments();
|
get_youtube_comments();
|
||||||
} else if (video_data.params.comments[1] === 'reddit') {
|
} else if (video_data.params.comments[1] === 'reddit') {
|
||||||
get_reddit_comments();
|
get_reddit_comments();
|
||||||
} else {
|
}
|
||||||
var comments = document.getElementById('comments');
|
|
||||||
comments.innerHTML = '';
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -222,6 +222,8 @@
|
|||||||
"View Reddit comments": "View Reddit comments",
|
"View Reddit comments": "View Reddit comments",
|
||||||
"Hide replies": "Hide replies",
|
"Hide replies": "Hide replies",
|
||||||
"Show replies": "Show replies",
|
"Show replies": "Show replies",
|
||||||
|
"youtube_comments_disabled_text": "Comments are turned off on this video",
|
||||||
|
"invidious_comments_disabled_text": "Comments are hidden as per configuration",
|
||||||
"Incorrect password": "Incorrect password",
|
"Incorrect password": "Incorrect password",
|
||||||
"Wrong answer": "Wrong answer",
|
"Wrong answer": "Wrong answer",
|
||||||
"Erroneous CAPTCHA": "Erroneous CAPTCHA",
|
"Erroneous CAPTCHA": "Erroneous CAPTCHA",
|
||||||
|
|||||||
@ -193,6 +193,11 @@ struct Video
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns true if comments are enabled on the video
|
||||||
|
def comments?
|
||||||
|
return info["commentsEnabled"].as_bool
|
||||||
|
end
|
||||||
|
|
||||||
# Macros defining getters/setters for various types of data
|
# Macros defining getters/setters for various types of data
|
||||||
|
|
||||||
private macro getset_string(name)
|
private macro getset_string(name)
|
||||||
|
|||||||
@ -295,6 +295,20 @@ module Invidious::Videos::Parser
|
|||||||
"likeButton", "toggleButtonRenderer"
|
"likeButton", "toggleButtonRenderer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Comments enabled?
|
||||||
|
comments_enabled = true
|
||||||
|
|
||||||
|
# When comments are enabled the primary results should contain either the comments-entry-point
|
||||||
|
# or comment-item-section section
|
||||||
|
if primary_results
|
||||||
|
section = primary_results.as_a.find { |s| s.dig?("itemSectionRenderer", "sectionIdentifier") == "comment-item-section" }
|
||||||
|
|
||||||
|
# messageRenderer should say "Comments are turned off."
|
||||||
|
if section && section.dig?("itemSectionRenderer", "contents", 0, "messageRenderer")
|
||||||
|
comments_enabled = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if likes_button
|
if likes_button
|
||||||
likes_txt = likes_button.dig?("accessibilityText")
|
likes_txt = likes_button.dig?("accessibilityText")
|
||||||
# Note: The like count from `toggledText` is off by one, as it would
|
# Note: The like count from `toggledText` is off by one, as it would
|
||||||
@ -441,6 +455,7 @@ module Invidious::Videos::Parser
|
|||||||
"authorThumbnail" => JSON::Any.new(author_thumbnail.try &.as_s || ""),
|
"authorThumbnail" => JSON::Any.new(author_thumbnail.try &.as_s || ""),
|
||||||
"authorVerified" => JSON::Any.new(author_verified || false),
|
"authorVerified" => JSON::Any.new(author_verified || false),
|
||||||
"subCountText" => JSON::Any.new(subs_text || "-"),
|
"subCountText" => JSON::Any.new(subs_text || "-"),
|
||||||
|
"commentsEnabled" => JSON::Any.new(comments_enabled),
|
||||||
}
|
}
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|||||||
@ -63,6 +63,7 @@ we're going to need to do it here in order to allow for translations.
|
|||||||
"preferences" => preferences,
|
"preferences" => preferences,
|
||||||
"premiere_timestamp" => video.premiere_timestamp.try &.to_unix,
|
"premiere_timestamp" => video.premiere_timestamp.try &.to_unix,
|
||||||
"vr" => video.vr?,
|
"vr" => video.vr?,
|
||||||
|
"comments_enabled" => video.comments?,
|
||||||
"projection_type" => video.projection_type,
|
"projection_type" => video.projection_type,
|
||||||
"local_disabled" => CONFIG.disabled?("local"),
|
"local_disabled" => CONFIG.disabled?("local"),
|
||||||
"support_reddit" => true,
|
"support_reddit" => true,
|
||||||
@ -289,14 +290,26 @@ we're going to need to do it here in order to allow for translations.
|
|||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<div id="comments" class="comments">
|
<div id="comments" class="comments">
|
||||||
<% if nojs %>
|
<% if (params.comments <=> ["", ""]) == 0 %>
|
||||||
<%= comment_html %>
|
<div id="comments-disabled-message" class="h-box v-box">
|
||||||
|
<p><b><%= I18n.translate(locale, "invidious_comments_disabled_text") %></b></p>
|
||||||
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<noscript>
|
<% if video.comments? %>
|
||||||
<a href="/watch?<%= env.params.query %>&nojs=1">
|
<% if nojs %>
|
||||||
<%= I18n.translate(locale, "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.") %>
|
<%= comment_html %>
|
||||||
</a>
|
<% else %>
|
||||||
</noscript>
|
<noscript>
|
||||||
|
<a href="/watch?<%= env.params.query %>&nojs=1">
|
||||||
|
<%= I18n.translate(locale, "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.") %>
|
||||||
|
</a>
|
||||||
|
</noscript>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<div id="comments-turned-off-on-video-message" class="h-box v-box">
|
||||||
|
<p><b><%= I18n.translate(locale, "youtube_comments_disabled_text") %></b></p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user