diff --git a/Extensions/combined/src/starRating.js b/Extensions/combined/src/starRating.js new file mode 100644 index 0000000..5d98814 --- /dev/null +++ b/Extensions/combined/src/starRating.js @@ -0,0 +1,101 @@ +import { cLog } from "./utils"; + +function createStarRating(rating, isMobile) { + let starRating = document.createElement('label'); + + let starSlider = document.createElement("input"); + starSlider.setAttribute("class", "rating"); + starSlider.setAttribute("max", "5"); + starSlider.setAttribute("readonly", ""); + starSlider.setAttribute("style", `--fill:rgb(255, 215, 0);--value:${rating.toString()};};background-color: transparent;`); + starSlider.setAttribute("type", "range"); + + starRating.appendChild(starSlider); + + let YTLikeButton; + + if (isMobile){ + YTLikeButton = document.querySelector('#app > div.page-container > ytm-watch > ytm-single-column-watch-next-results-renderer > ytm-slim-video-metadata-section-renderer > ytm-slim-video-action-bar-renderer > div > ytm-slim-metadata-toggle-button-renderer:nth-child(1)'); + } else { + YTLikeButton = document.querySelector('#top-level-buttons-computed > ytd-toggle-button-renderer:nth-child(1)'); + } + + YTLikeButton.insertAdjacentElement('afterend', starRating); + + try { + let YTBar = document.querySelector('#ryd-bar-container'); + YTBar.setAttribute("style", "width: 190%; height: 2px;"); + } + catch(err) { + cLog("RateBar Not Present"); + } + + + + let style = ``; + +document.head.insertAdjacentHTML("beforeend", style); + + } + + export { createStarRating }; diff --git a/Extensions/combined/src/state.js b/Extensions/combined/src/state.js index df9d561..7160903 100644 --- a/Extensions/combined/src/state.js +++ b/Extensions/combined/src/state.js @@ -8,6 +8,7 @@ import { getColorFromTheme, } from "./utils"; import { localize } from "./utils"; +import { createStarRating } from "./starRating"; //TODO: Do not duplicate here and in ryd.background.js const apiUrl = "https://returnyoutubedislikeapi.com"; @@ -199,6 +200,7 @@ function processResponse(response, storedData) { getDislikeButton().style.color = getColorFromTheme(false); } } + createStarRating(response.rating, isMobile()); } // Tells the user if the API is down