Youtube Get Dislike

Get Dislike Amount.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Youtube Get Dislike
// @version      0.3
// @description  Get Dislike Amount.
// @license      MIT
// @homepageURL  https://github.com/willy67k/tampermonkey-userscripts
// @homepage     https://github.com/willy67k/tampermonkey-userscripts
// @source       https://github.com/willy67k/tampermonkey-userscripts/raw/master/src/youtube-get-dislike.js
// @namespace    https://github.com/willy67k/tampermonkey-userscripts/raw/master/src/youtube-get-dislike.js
// @author       Lilp
// @match        https://www.youtube.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// ==/UserScript==

(function () {
    "use strict";
    let url = "";

    setInterval(() => {
        if (url === window.window.location.href) {
            return;
        }
        url = window.window.location.href;

        const urlParams = new URLSearchParams(window.location.search).get("v");

        if (!urlParams) return;

        const inter = setInterval(() => {
            const disBtn = document.querySelector("dislike-button-view-model button");
            if (disBtn) {
                clearInterval(inter);
                fetch(`https://returnyoutubedislikeapi.com/Votes?videoId=${urlParams}`)
                    .then((res) => res.json())
                    .then((data) => {
                        if (disBtn && !disBtn.querySelector(".dislike")) {
                            disBtn.setAttribute("style", "width:auto !important");
                            disBtn.insertAdjacentHTML("beforeend", `<span class="dislike">${data.dislikes}</span>`);
                        }
                    });
            }
        }, 1000);
    }, 1000);

    // Your code here...
})();