Return Youtube Dislikes and Ratio

This commit is contained in:
Jesper Handskemager 2022-01-07 15:34:45 +01:00
parent 326a362eb8
commit 61577b12f7
2 changed files with 22 additions and 1 deletions

View File

@ -7,6 +7,24 @@ String.prototype.supplant = function (o) {
});
}
function set_real_dislike()
{
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://returnyoutubedislikeapi.com/votes?videoId=' + video_data.id);
xhr.onload = function() {
if (xhr.status === 200) {
var data = JSON.parse(xhr.responseText);
document.getElementById("dislikes").innerHTML = "<i class='icon ion-ios-thumbs-down'></i> " + data.dislikes.toLocaleString('en-US');
document.getElementById("rating").innerHTML = "Rating: " + Math.round(data.rating * 10) / 10 + " / 5";
}
else {
document.getElementById("dislikes").innerHTML = "<i class='icon ion-ios-thumbs-down'></i> 0";
}
};
xhr.send();
}
function toggle_parent(target) {
body = target.parentNode.parentNode.children[1];
if (body.style.display === null || body.style.display === '') {
@ -452,6 +470,9 @@ window.addEventListener('load', function (e) {
get_playlist(video_data.plid);
}
// Gets and sets the dislike count from 'returnyoutubedislikeapi.com'
set_real_dislike();
if (video_data.params.comments[0] === 'youtube') {
get_youtube_comments();
} else if (video_data.params.comments[0] === 'reddit') {

View File

@ -209,7 +209,7 @@ before_all do |env|
"style-src 'self' 'unsafe-inline'",
"img-src 'self' data:",
"font-src 'self' data:",
"connect-src 'self'",
"connect-src 'self' returnyoutubedislikeapi.com",
"manifest-src 'self'",
"media-src 'self' blob:" + extra_media_csp,
"child-src 'self' blob:",