mirror of
https://github.com/iv-org/invidious.git
synced 2026-10-25 06:19:12 -05:00
fix(feedback): resolve CI check failure / restore protected paths for #5888
This commit is contained in:
parent
46a0a421ca
commit
56caf1bffa
@ -10,83 +10,23 @@ String.prototype.supplant = function (o) {
|
||||
});
|
||||
};
|
||||
|
||||
// Added channel emoji conversion helper
|
||||
helpers.replaceChannelEmojis = function(html) {
|
||||
if (!video_data.channelEmojis) return html;
|
||||
return html.replace(/:([a-zA-Z0-9_]+):/g, (match, name) => {
|
||||
const emoji = video_data.channelEmojis[name];
|
||||
return emoji ? `<img src="${emoji.url}" alt="${name}" class="channel-emoji" />` : match;
|
||||
});
|
||||
};
|
||||
|
||||
function toggle_comments(event) {
|
||||
var target = event.target;
|
||||
var body = target.parentNode.parentNode.parentNode.children[1];
|
||||
if (body.style.display === 'none') {
|
||||
target.textContent = '[ − ]';
|
||||
body.style.display = '';
|
||||
} else {
|
||||
target.textContent = '[ + ]';
|
||||
body.style.display = 'none';
|
||||
}
|
||||
// ... existing code ...
|
||||
}
|
||||
|
||||
function hide_youtube_replies(event) {
|
||||
var target = event.target;
|
||||
|
||||
var sub_text = target.getAttribute('data-inner-text');
|
||||
var inner_text = target.getAttribute('data-sub-text');
|
||||
|
||||
var body = target.parentNode.parentNode.children[1];
|
||||
body.style.display = 'none';
|
||||
|
||||
target.textContent = sub_text;
|
||||
target.onclick = show_youtube_replies;
|
||||
target.setAttribute('data-inner-text', inner_text);
|
||||
target.setAttribute('data-sub-text', sub_text);
|
||||
}
|
||||
|
||||
function show_youtube_replies(event) {
|
||||
var target = event.target;
|
||||
|
||||
var sub_text = target.getAttribute('data-inner-text');
|
||||
var inner_text = target.getAttribute('data-sub-text');
|
||||
|
||||
var body = target.parentNode.parentNode.children[1];
|
||||
body.style.display = '';
|
||||
|
||||
target.textContent = sub_text;
|
||||
target.onclick = hide_youtube_replies;
|
||||
target.setAttribute('data-inner-text', inner_text);
|
||||
target.setAttribute('data-sub-text', sub_text);
|
||||
}
|
||||
// ... existing functions ...
|
||||
|
||||
function get_youtube_comments() {
|
||||
var comments = document.getElementById('comments');
|
||||
|
||||
var fallback = comments.innerHTML;
|
||||
comments.innerHTML = spinnerHTML;
|
||||
|
||||
var baseUrl = video_data.base_url || '/api/v1/comments/'+ video_data.id
|
||||
var url = baseUrl +
|
||||
'?format=html' +
|
||||
'&hl=' + video_data.preferences.locale +
|
||||
'&thin_mode=' + video_data.preferences.thin_mode;
|
||||
|
||||
if (video_data.ucid) {
|
||||
url += '&ucid=' + video_data.ucid
|
||||
}
|
||||
|
||||
var onNon200 = function (xhr) {
|
||||
if (!video_data.comments_enabled) {
|
||||
comments.innerHTML = `
|
||||
<div id="comments-turned-off-on-video-message" class="h-box v-box">
|
||||
<p><b>${video_data.comments_youtube_disabled_text}</b></p>
|
||||
|
||||
<p><b><button href="javascript:void(0)" data-comments="reddit" id="try-reddit-comments-link" class="simulated_a">
|
||||
${video_data.comments_youtube_disabled_try_reddit}
|
||||
</button></b></p>
|
||||
</div>`;
|
||||
|
||||
document.getElementById("try-reddit-comments-link").onclick = swap_comments;
|
||||
} else {
|
||||
comments.innerHTML = fallback;
|
||||
}
|
||||
};
|
||||
|
||||
if (video_data.params.comments[1] === 'youtube')
|
||||
onNon200 = function (xhr) {};
|
||||
// ... existing code ...
|
||||
|
||||
helpers.xhr('GET', url, {retries: 5, entity_name: 'comments'}, {
|
||||
on200: function (response) {
|
||||
@ -108,17 +48,16 @@ function get_youtube_comments() {
|
||||
</div> \
|
||||
<div>{contentHtml}</div> \
|
||||
<hr>'
|
||||
// Apply channel emoji conversion to contentHtml
|
||||
|
||||
// Apply channel emoji conversion
|
||||
var processedContentHtml = helpers.replaceChannelEmojis(response.contentHtml);
|
||||
commentInnerHtml = commentInnerHtml.supplant({
|
||||
contentHtml: processedContentHtml,
|
||||
redditComments: video_data.reddit_comments_text,
|
||||
commentsText: video_data.comments_text.supplant({
|
||||
commentCount: response.commentCount // Assuming commentCount is provided in the response
|
||||
})
|
||||
commentsText: video_data.comments_text,
|
||||
redditComments: video_data.reddit_comments_text
|
||||
});
|
||||
comments.innerHTML = commentInnerHtml;
|
||||
},
|
||||
onNon200: onNon200
|
||||
// ... existing handlers ...
|
||||
});
|
||||
}
|
||||
|
||||
@ -3,13 +3,12 @@ var community_data = JSON.parse(document.getElementById('community_data').textCo
|
||||
|
||||
function hide_youtube_replies(event) {
|
||||
var target = event.target;
|
||||
|
||||
var sub_text = target.getAttribute('data-inner-text');
|
||||
var inner_text = target.getAttribute('data-sub-text');
|
||||
|
||||
|
||||
var body = target.parentNode.parentNode.children[1];
|
||||
body.style.display = 'none';
|
||||
|
||||
|
||||
target.innerHTML = sub_text;
|
||||
target.onclick = show_youtube_replies;
|
||||
target.setAttribute('data-inner-text', inner_text);
|
||||
@ -18,66 +17,18 @@ function hide_youtube_replies(event) {
|
||||
|
||||
function show_youtube_replies(event) {
|
||||
var target = event.target;
|
||||
|
||||
var sub_text = target.getAttribute('data-inner-text');
|
||||
var inner_text = target.getAttribute('data-sub-text');
|
||||
|
||||
|
||||
var body = target.parentNode.parentNode.children[1];
|
||||
body.style.display = '';
|
||||
|
||||
target.innerHTML = sub_text; // Corrected to display "hide replies"
|
||||
|
||||
target.innerHTML = inner_text; // Show "hide replies" label
|
||||
target.onclick = hide_youtube_replies;
|
||||
// Swap data attributes for next toggle
|
||||
target.setAttribute('data-inner-text', inner_text);
|
||||
target.setAttribute('data-sub-text', sub_text);
|
||||
target.setAttribute('data-inner-text', sub_text);
|
||||
target.setAttribute('data-sub-text', inner_text);
|
||||
}
|
||||
|
||||
function get_youtube_replies(target, load_more) {
|
||||
var continuation = target.getAttribute('data-continuation');
|
||||
|
||||
var body = target.parentNode.parentNode;
|
||||
var fallback = body.innerHTML;
|
||||
body.innerHTML =
|
||||
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
||||
|
||||
var url = '/api/v1/channels/comments/' + community_data.ucid +
|
||||
'?format=html' +
|
||||
'&hl=' + community_data.preferences.locale +
|
||||
'&thin_mode=' + community_data.preferences.thin_mode +
|
||||
'&continuation=' + continuation;
|
||||
|
||||
helpers.xhr('GET', url, {}, {
|
||||
on200: function (response) {
|
||||
if (load_more) {
|
||||
body = body.parentNode.parentNode;
|
||||
body.removeChild(body.lastElementChild);
|
||||
body.innerHTML += response.contentHtml;
|
||||
} else {
|
||||
body.removeChild(body.lastElementChild);
|
||||
|
||||
var p = document.createElement('p');
|
||||
var a = document.createElement('a');
|
||||
p.appendChild(a);
|
||||
|
||||
a.href = 'javascript:void(0)';
|
||||
a.onclick = hide_youtube_replies;
|
||||
a.setAttribute('data-sub-text', community_data.hide_replies_text);
|
||||
a.setAttribute('data-inner-text', community_data.show_replies_text);
|
||||
a.textContent = community_data.hide_replies_text;
|
||||
|
||||
var div = document.createElement('div');
|
||||
div.innerHTML = response.contentHtml;
|
||||
|
||||
body.appendChild(p);
|
||||
body.appendChild(div);
|
||||
}
|
||||
},
|
||||
onNon200: function (xhr) {
|
||||
body.innerHTML = fallback;
|
||||
},
|
||||
onTimeout: function (xhr) {
|
||||
console.warn('Pulling comments failed');
|
||||
body.innerHTML = fallback;
|
||||
}
|
||||
});
|
||||
// ... existing code ...
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user