var video_data = JSON.parse(document.getElementById('video_data').textContent);
var spinnerHTML = '
';
var spinnerHTMLwithHR = spinnerHTML + '
';
String.prototype.supplant = function (o) {
return this.replace(/{([^{}]*)}/g, function (a, b) {
var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
});
};
// 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 ? `
` : match;
});
};
function toggle_comments(event) {
// ... existing code ...
}
// ... existing functions ...
function get_youtube_comments() {
// ... existing code ...
helpers.xhr('GET', url, {retries: 5, entity_name: 'comments'}, {
on200: function (response) {
var commentInnerHtml = ' \
\
\
[ − ] \
{commentsText} \
\
\
'
if (video_data.support_reddit) {
commentInnerHtml += ' \
{redditComments} \
\
'
}
commentInnerHtml += ' \
\
{contentHtml}
\
'
// Apply channel emoji conversion
var processedContentHtml = helpers.replaceChannelEmojis(response.contentHtml);
commentInnerHtml = commentInnerHtml.supplant({
contentHtml: processedContentHtml,
commentsText: video_data.comments_text,
redditComments: video_data.reddit_comments_text
});
comments.innerHTML = commentInnerHtml;
},
// ... existing handlers ...
});
}