diff --git a/Extensions/combined/ryd.content-script.js b/Extensions/combined/ryd.content-script.js index 02370ede..3bb64656 100644 --- a/Extensions/combined/ryd.content-script.js +++ b/Extensions/combined/ryd.content-script.js @@ -69,3 +69,116 @@ document.addEventListener("yt-navigate-finish", function (event) { }); setTimeout(() => sendVideoIds(), 2500); + +function initializeInfoPanelButton() { + let ytpRightControls = document.querySelector("#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-right-controls"); + let RYDInfoPanelButton = document.createElement("button"); + RYDInfoPanelButton.setAttribute("id", "RYDInfoPanelButton"); + RYDInfoPanelButton.setAttribute("class", "ytp-button"); + RYDInfoPanelButton.innerHTML = ''; + ytpRightControls.firstElementChild.insertAdjacentElement('beforebegin', RYDInfoPanelButton); + document.getElementById("RYDInfoPanelButton").addEventListener('click', showRYDInfoPanel); +} + +function showRYDInfoPanel() { + if (document.getElementById("RYDInfoPanel")) { document.getElementById("RYDInfoPanel").remove(); return; } + console.log("qwerty"); + let YTPageRightSide = document.querySelector("#secondary"); + let RYDInfoPanel = document.createElement("div"); + RYDInfoPanel.setAttribute("id", "RYDInfoPanel"); + RYDInfoPanel.setAttribute("style", "color: white; background-color: rgb(68, 68, 68); border-radius: 2rem; padding: 2rem; box-shadow: 0.5em 1em 2em 0.5rem rgba(0,0,0,0.2);"); + + // expected API response + let response = { + "id": "swLyst02ZK4", + "dateCreated": "2022-04-24T07:14:29.808647Z", + "likes": 105696, + "dislikes": 180, + "rating": 4.993199591975518, + "viewCount": 2016789, + "deleted": false, + "extensionUsersLikeCount": 10569, + "extensionUsersDislikeCount": 18, + "extensionUsersVotes": 10600 + }; + + RYDInfoPanel.innerHTML = ` +
+ + Return YouTube Dislike +
+ +Likes: | +${response.likes} | +
---|---|
Dislikes: | +${response.dislikes} | +
Views: | +${response.viewCount} | +
Rating: | +${response.rating} | +
Entry Created on: | +${response.dateCreated} | +
Likes: | +${response.extensionUsersLikeCount} | +
---|---|
Dislikes: | +${response.extensionUsersDislikeCount} | +
Neutral Votes: | +${response.extensionUsersVotes - response.extensionUsersDislikeCount - response.extensionUsersLikeCount} | +
Rating: | +${response.extensionUsersLikeCount / (response.extensionUsersLikeCount + response.extensionUsersDislikeCount)} | +
Votes: | +${response.extensionUsersVotes} | +
User Percentage: | +${(response.extensionUsersVotes / (response.likes + response.dislikes))*100}% | +