HH Unlock Images

This script unlocks images of both recruited girls and non-recruited girls.

29.10.2021 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         HH Unlock Images
// @namespace    hhUnlock
// @version      2.00
// @description  This script unlocks images of both recruited girls and non-recruited girls.
// @author       YanDee
// @match        *://nutaku.haremheroes.com/harem*
// @match        *://*.hentaiheroes.com/harem*
// @match        *://*.gayharem.com/harem*
// @match        *://*.comixharem.com/harem*
// @grant        unsafeWindow
// ==/UserScript==

(function(uW, $, girlsDataList, number_format_lang, number_reduce, GT) {
    if (document.visibilityState == 'hidden'){
        return;
    }
    function YD_addStyle(rules_obj){
        if (!Array.from(document.styleSheets).some(v => v.title == "YD_HH")){
            let style = document.createElement("style");
            style.title = "YD_HH";
            document.getElementsByTagName("head")[0].appendChild(style);
        }

        let sheet = Array.from(document.styleSheets).find(v => v.title == "YD_HH");

        Object.entries(rules_obj).map(v => {
            sheet.insertRule(v[0] + "{" + Object.entries(v[1]).map(
                s => s[0] + ":" + s[1] + ";"
            ).join("") + "}");
        });
    }

    let totalIncome = Math.round(Object.values(girlsDataList).reduce((t,v) => v.own? t + v.salary_per_hour : t, 0));
    $("div.girls_levels > *").addClass("orig_node");
    $("div.girls_levels").append(
        $("<span>", {class: "hudSC_mix_icn"}),
        $("<p>").append($("<span>", {class: "pompous_text", text: GT.design.haremdex_income})),
        $("<p>").append(
            $("<p>", {
                class: "focus_text",
                hh_title: number_format_lang(totalIncome) + " / " + GT.time.h,
                "tooltip-id": "tooltip_1",
                text: (totalIncome >= 1e6? number_reduce(totalIncome) : number_format_lang(totalIncome)) + " / " + GT.time.h
            }),
            $("<p>", {
                class: "focus_text",
                hh_title: number_format_lang(24 * totalIncome) + " / " + GT.time.d,
                "tooltip-id": "tooltip_1",
                text: (24 * totalIncome >= 1e6? number_reduce(24 * totalIncome) : number_format_lang(24 * totalIncome)) + " / " + GT.time.d
            })
        )
    );
    if (sessionStorage.haremLevDispMode != "default"){
        sessionStorage.haremLevDispMode = "income";
        $("div.girls_levels").addClass("show_income");
    }
    let styles = {
        "div.girls_levels": {"cursor": "pointer"},
        "#harem_left div.girls_levels.show_income>.orig_node": {"display": "none"},
        "#harem_left div.girls_levels:not(.show_income)>:not(.orig_node)": {"display": "none"},
        "#harem_left div.girls_levels p:not(.orig_node)": {"margin": "0"},
        "#harem_whole #harem_right img.avatar": {"filter": "none"},
        "#harem_whole #harem_right div.middle_part.missing_girl": {"margin-top": "0"},
        "#harem_right .diamond-bar .showing": {
            "box-shadow": "0 0 3px 5px rgba(20,255,0,0.75)",
            "opacity": "1"
        },
        "#harem_right .diamond-bar :not(.showing)": {"cursor": "pointer"}
    };
    YD_addStyle(styles);
    $("div.girls_levels").click(function(){
        this.classList.toggle("show_income");
        sessionStorage.haremLevDispMode = $(this).hasClass("show_income")? "income" : "default";
    });

    function getDiamondBar(grade){
        let body = $("<div>", {class: "diamond-bar"});
        for (let i = 0; i < grade; i++) {
            $("<div>", {class: "diamond locked" + (i? "" : " showing"), grade: i}).appendTo(body);
        };
        return body;
    }

    function getHeader(g_id){
        let g_info = uW.all_possible_girls[g_id] || {}, g_name = g_info.ref?.full_name || g_info.Name || "Unknown";
        let icn = $(".opened[girl] .icon > span").clone().removeClass("element_harem_icn").addClass("element_harem_details_icn");
        return [
            $("<h3>", {text: g_name}).append(icn, $("<span>", {carac: "class" + g_info.class})),
            $("<p>", {class: "girl-rarity " + g_info.rarity, text: GT.design["girls_rarity_" + g_info.rarity]})
        ];
    }

    function changeSkin(num){
        $("#harem_right img.avatar").attr("src", (i, src) => src.replace(/av(a|b)\d/g, "ava" + num));
    }

    function perform(){
        let girl_id = $("#harem_left .girls_list .opened").attr("girl");
        if ((girlsDataList[girl_id] || {}).own){
            $(".diamond-bar .diamond.selected").addClass("showing");
        }
        else {
            let grade = (girlsDataList[girl_id].Graded2.match(/<g[^>]*>[^<>]*<[^>]*\/g>/gi) || []).length + 1;
            $('#harem_right img.avatar').before(getHeader(girl_id)).after(getDiamondBar(grade));
            changeSkin(0);
        }
        $(".diamond-bar").on("click", ".diamond:not(.showing)", function(){
            $(".diamond-bar .diamond").removeClass("showing");
            $(this).addClass("showing");
            changeSkin($(this).attr("grade"));
        });
    }

    uW.Girl.prototype.showInRightOrig = uW.Girl.prototype.showInRight;
    uW.Girl.prototype.showInRight = function(){
        this.showInRightOrig.apply(this);
        perform();
    };
    perform();
})(unsafeWindow, unsafeWindow.jQuery, unsafeWindow.girlsDataList, unsafeWindow.number_format_lang, unsafeWindow.number_reduce, unsafeWindow.GT);