Real likes

Script by Punsh

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Real likes
// @namespace    http://tampermonkey.net/
// @version      2024-05-26
// @description  Script by Punsh
// @author       You
// @match        https://lolz.live/threads/7112292/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=lolz.live
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    const users = document.querySelectorAll(".userText")

    let html = document.createElement("div")

    users.forEach(user => {
        let link = user.querySelector("span a.username")

        fetch(`https://lolz.live/${link.getAttribute("href")}`).then(resul => resul.text().then(htmlText => {
            let noReaction = 0

            html.innerHTML = htmlText

            let reaction = Number(html.querySelector(".count").textContent.replace(" ", ""))

            fetch(`https://lolz.live/${link.getAttribute("href")}likes?type=gotten&content_type=post&stats=1`).then(resul => {
                resul.text().then(htmlText => {
                    html.innerHTML = htmlText

                    let allReaction = html.querySelectorAll(".node ")

                    allReaction.forEach(el => {
                        if (el.querySelector(".muted").textContent.toLowerCase().indexOf("розыгрыш") !== -1) {
                            noReaction += Number(el.querySelector(".counter").textContent.replace(" ", ""))
                        }
                    })

                    const element = `<i class="userCounterIcon fas fa-heart"></i>${reaction - noReaction}`
                    if (user.querySelector(".userCounters span")) {
                        user.querySelector(".userCounters span").innerHTML = element
                    } else {
                        user.insertAdjacentHTML("beforeend", `<span class="userCounter item muted">${element}</span>`)
                    }
                })
            })
        }))
    })

    const observ = new MutationObserver(obser => {
        const window = `<div style="position: absolute; left: -999999px; top: -999999px; width: 100px; height: 100px; overflow: scroll;"><div style="height: 200px; width: 100%;"></div></div>`

        const reaction = document.querySelectorAll(".memberCardInner")

        if (obser[0].addedNodes[0]) {
            if (obser[0].addedNodes[0].outerHTML == window) {
                let link = reaction[reaction.length - 1].querySelector(".username.NoOverlay").getAttribute("href")
                let noReaction = 0

                fetch(`https://lolz.live/${link}likes?type=gotten&content_type=post&stats=1`).then(resul => {
                    resul.text().then(htmlText => {
                        html.innerHTML = htmlText

                        let allReaction = html.querySelectorAll(".node ")

                        allReaction.forEach(el => {
                            if (el.querySelector(".muted").textContent.toLowerCase().indexOf("розыгрыш") !== -1) {
                                noReaction += Number(el.querySelector(".counter").textContent.replace(" ", ""))
                            }
                        })

                        const element = `<i class="counterIcon likeCounterIcon"></i>${Number(reaction[reaction.length - 1].querySelector("a.counter").textContent.replace(" ", "")) - noReaction}`
                        reaction[reaction.length - 1].querySelector("a.counter").innerHTML = element
                    })
                })
            }
        }
    })

    observ.observe(document.body, {
        childList: true,
        subtree: false
    })
})();