diff --git a/assets/js/comments.js b/assets/js/comments.js index 848d36fb..73be4bfa 100644 --- a/assets/js/comments.js +++ b/assets/js/comments.js @@ -72,7 +72,28 @@ function get_youtube_comments() { url += '&ucid=' + video_data.ucid } - var onNon200 = function (xhr) { comments.innerHTML = fallback; }; + var onNon200 = function (xhr) { + if (!video_data.comments_enabled) { + comments.innerHTML = ` +
+

${video_data.youtube_comments_disabled_text}

+ +

+ + + ${video_data.youtube_comments_disabled_try_reddit} + + +

+
`; + + document.getElementById("try-reddit-comments-link").onclick = swap_comments + } else { + comments.innerHTML = fallback; + } + + }; + if (video_data.params.comments[1] === 'youtube') onNon200 = function (xhr) {}; diff --git a/assets/js/watch.js b/assets/js/watch.js index 31c09785..8eaf0654 100644 --- a/assets/js/watch.js +++ b/assets/js/watch.js @@ -178,6 +178,10 @@ addEventListener('load', function (e) { if (video_data.plid) get_playlist(video_data.plid); + if (!video_data.comments_enabled && video_data.params.comments.includes("youtube")) { + return; + } + if (video_data.params.comments[0] === 'youtube') { get_youtube_comments(); } else if (video_data.params.comments[0] === 'reddit') { @@ -188,3 +192,5 @@ addEventListener('load', function (e) { get_reddit_comments(); } }); + +document.getElementById("try-reddit-comments-link").onclick = swap_comments \ No newline at end of file diff --git a/locales/en-US.json b/locales/en-US.json index 3f314788..82b1b13c 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -214,6 +214,7 @@ "Hide replies": "Hide replies", "Show replies": "Show replies", "youtube_comments_disabled_text": "Comments are turned off on this video", + "youtube_comments_disabled_try_reddit": "Try reddit comments?", "invidious_comments_disabled_text": "Comments are hidden as per configuration", "Incorrect password": "Incorrect password", "Wrong answer": "Wrong answer", diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index f4eb4203..9d4c70fe 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -42,6 +42,12 @@ we're going to need to do it here in order to allow for translations. content: "<%= translate(locale, "Show less") %>" } + +<% + # Disable the try reddit link if javascript is disabled +%> + + <% end %>