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
56caf1bffa
commit
a83bc8196d
@ -3,6 +3,24 @@ var video_data = JSON.parse(document.getElementById('video_data').textContent);
|
|||||||
var spinnerHTML = '<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
var spinnerHTML = '<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
||||||
var spinnerHTMLwithHR = spinnerHTML + '<hr>';
|
var spinnerHTMLwithHR = spinnerHTML + '<hr>';
|
||||||
|
|
||||||
|
// Moved channel emoji helper to top for safe access
|
||||||
|
helpers.replaceChannelEmojis = function(html) {
|
||||||
|
if (!video_data.channelEmojis) return html;
|
||||||
|
// Use DOM parser to replace only in text nodes
|
||||||
|
const parser = new DOMParser();
|
||||||
|
const doc = parser.parseFromString(html, 'text/html');
|
||||||
|
const textNodes = doc.createTreeWalker(doc.body, NodeFilter.SHOW_TEXT);
|
||||||
|
|
||||||
|
let node;
|
||||||
|
while ((node = textNodes.nextNode())) {
|
||||||
|
node.textContent = node.textContent.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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return doc.body.innerHTML;
|
||||||
|
};
|
||||||
|
|
||||||
String.prototype.supplant = function (o) {
|
String.prototype.supplant = function (o) {
|
||||||
return this.replace(/{([^{}]*)}/g, function (a, b) {
|
return this.replace(/{([^{}]*)}/g, function (a, b) {
|
||||||
var r = o[b];
|
var r = o[b];
|
||||||
@ -10,15 +28,6 @@ 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) {
|
function toggle_comments(event) {
|
||||||
// ... existing code ...
|
// ... existing code ...
|
||||||
}
|
}
|
||||||
@ -30,31 +39,19 @@ function get_youtube_comments() {
|
|||||||
|
|
||||||
helpers.xhr('GET', url, {retries: 5, entity_name: 'comments'}, {
|
helpers.xhr('GET', url, {retries: 5, entity_name: 'comments'}, {
|
||||||
on200: function (response) {
|
on200: function (response) {
|
||||||
var commentInnerHtml = ' \
|
var commentInnerHtml = `
|
||||||
<div> \
|
<div>
|
||||||
<h3> \
|
<h3>
|
||||||
<a href="javascript:void(0)">[ − ]</a> \
|
<a href="javascript:void(0)" class="comment-toggle">${video_data.comments_text}</a>
|
||||||
{commentsText} \
|
${video_data.support_reddit ? ` <a href="javascript:void(0)" class="comment-toggle" data-comments="reddit">${video_data.reddit_comments_text}</a>` : ''}
|
||||||
</h3> \
|
</h3>
|
||||||
<b> \
|
<div>${helpers.replaceChannelEmojis(response.contentHtml)}</div>
|
||||||
'
|
<hr>
|
||||||
if (video_data.support_reddit) {
|
</div>`;
|
||||||
commentInnerHtml += ' <a href="javascript:void(0)" data-comments="reddit"> \
|
|
||||||
{redditComments} \
|
|
||||||
</a> \
|
|
||||||
'
|
|
||||||
}
|
|
||||||
commentInnerHtml += ' </b> \
|
|
||||||
</div> \
|
|
||||||
<div>{contentHtml}</div> \
|
|
||||||
<hr>'
|
|
||||||
|
|
||||||
// Apply channel emoji conversion
|
// Rebind handlers after DOM update
|
||||||
var processedContentHtml = helpers.replaceChannelEmojis(response.contentHtml);
|
document.querySelectorAll('.comment-toggle').forEach(el => {
|
||||||
commentInnerHtml = commentInnerHtml.supplant({
|
el.addEventListener('click', toggle_comments);
|
||||||
contentHtml: processedContentHtml,
|
|
||||||
commentsText: video_data.comments_text,
|
|
||||||
redditComments: video_data.reddit_comments_text
|
|
||||||
});
|
});
|
||||||
comments.innerHTML = commentInnerHtml;
|
comments.innerHTML = commentInnerHtml;
|
||||||
},
|
},
|
||||||
|
|||||||
@ -9,8 +9,9 @@ function hide_youtube_replies(event) {
|
|||||||
var body = target.parentNode.parentNode.children[1];
|
var body = target.parentNode.parentNode.children[1];
|
||||||
body.style.display = 'none';
|
body.style.display = 'none';
|
||||||
|
|
||||||
target.innerHTML = sub_text;
|
target.innerHTML = sub_text; // Show "show replies" label
|
||||||
target.onclick = show_youtube_replies;
|
target.onclick = show_youtube_replies;
|
||||||
|
// Swap data attributes for next toggle
|
||||||
target.setAttribute('data-inner-text', inner_text);
|
target.setAttribute('data-inner-text', inner_text);
|
||||||
target.setAttribute('data-sub-text', sub_text);
|
target.setAttribute('data-sub-text', sub_text);
|
||||||
}
|
}
|
||||||
@ -23,12 +24,17 @@ function show_youtube_replies(event) {
|
|||||||
var body = target.parentNode.parentNode.children[1];
|
var body = target.parentNode.parentNode.children[1];
|
||||||
body.style.display = '';
|
body.style.display = '';
|
||||||
|
|
||||||
target.innerHTML = inner_text; // Show "hide replies" label
|
target.innerHTML = inner_text; // Show "hide replies" label
|
||||||
target.onclick = hide_youtube_replies;
|
target.onclick = hide_youtube_replies;
|
||||||
|
// Swap data attributes for next toggle
|
||||||
target.setAttribute('data-inner-text', sub_text);
|
target.setAttribute('data-inner-text', sub_text);
|
||||||
target.setAttribute('data-sub-text', inner_text);
|
target.setAttribute('data-sub-text', inner_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_youtube_replies(target, load_more) {
|
// Ensure community.js is included in watch pages
|
||||||
// ... existing code ...
|
if (typeof get_youtube_replies === 'undefined' && window.location.pathname.includes('/watch')) {
|
||||||
|
// Implement watch-page specific reply loader or include community.js
|
||||||
|
console.error('Community functions not initialized for watch page');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ... rest of existing code ...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user