ReturnInvidiousDislike

Displays the dislike count of videos accessed via Invidious.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name               ReturnInvidiousDislike
// @name:de            ReturnInvidiousDislike
// @name:en            ReturnInvidiousDislike
// @namespace          sun/userscripts
// @version            1.2.10
// @description        Displays the dislike count of videos accessed via Invidious.
// @description:de     Zeigt die Dislike-Anzahl von Videos auf Invidious an.
// @description:en     Displays the dislike count of videos accessed via Invidious.
// @compatible         chrome
// @compatible         edge
// @compatible         firefox
// @compatible         opera
// @compatible         safari
// @homepageURL        https://forgejo.sny.sh/sun/userscripts
// @supportURL         https://forgejo.sny.sh/sun/userscripts/issues
// @contributionURL    https://liberapay.com/sun
// @contributionAmount €1.00
// @author             Sunny <[email protected]>
// @include            *://*/watch?v=*
// @match              *://*/watch?v=*
// @connect            returnyoutubedislikeapi.com
// @run-at             document-end
// @inject-into        auto
// @grant              GM.xmlHttpRequest
// @grant              GM_xmlhttpRequest
// @noframes
// @require            https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// @icon               https://forgejo.sny.sh/sun/userscripts/raw/branch/main/icons/ReturnInvidiousDislike.png
// @copyright          2021-present, Sunny (https://sny.sh/)
// @license            Hippocratic License; https://forgejo.sny.sh/sun/userscripts/src/branch/main/LICENSE.md
// ==/UserScript==

(() => {
  const video = new URLSearchParams(window.location.search).get("v");
  const views = document.getElementById("views")?.childNodes[1];
  const likes = document.getElementById("likes")?.childNodes[1];
  const dislikes = document.getElementById("dislikes")?.childNodes[1];
  const rating = document.getElementById("rating");

  if (video && views && likes && rating) {
    GM.xmlHttpRequest({
      url: `https://returnyoutubedislikeapi.com/votes?videoId=${video}`,
      onload: (response) => {
        const data = JSON.parse(response.responseText);

        views.textContent = ` ${data.viewCount.toLocaleString()}`;
        likes.textContent = ` ${data.likes.toLocaleString()}`;
        rating.textContent = `Rating: ${data.rating.toFixed(4)} / 5`;

        if (dislikes) {
          dislikes.textContent = ` ${data.dislikes.toLocaleString()}`;
        } else {
          const clone = likes.parentElement.cloneNode(true);
          const icon = clone.getElementsByClassName("icon")[0];
          const text = clone.childNodes[1];

          icon.classList.replace("ion-ios-thumbs-up", "ion-ios-thumbs-down");
          text.textContent = ` ${data.dislikes.toLocaleString()}`;
          likes.parentElement.insertAdjacentElement("afterend", clone);
        }
      },
    });
  }
})();