Hentai Heroes Helper (auto collect and button press)

Add in the Hentai Heroes game.

As of 2021-12-04. See the latest version.

// ==UserScript==
// @name			Hentai Heroes Helper (auto collect and button press)
// @description		Add in the Hentai Heroes game.
// @version			1.1.2
// @match			https://www.hentaiheroes.com/*
// @match			https://nutaku.haremheroes.com/*
// @match			https://eroges.hentaiheroes.com/*
// @match			https://thrix.hentaiheroes.com/*
// @match			https://www.gayharem.com/*
// @match			https://nutaku.gayharem.com/*
// @match			https://www.comixharem.com/*
// @match			https://nutaku.comixharem.com/*
// @match			https://*.hornyheroes.com/*
// @run-at			document-end
// @grant			none
// @license         MIT
// @author			Morry98
// @namespace https://greasyfork.org/users/807892
// ==/UserScript==

var press = true;
setInterval(function() {
    $btns = $('#new-battle-skip-btn, .skip-button, .not-supported-browser .blue_button_L, .popup_buttons .blue_button_L,' +
        'button[rel="pop_auto_assign"]:not(:disabled), button[rel="pop_action"]:not(:disabled),' +
        'button[rel="pop_claim"]:not(:disabled)');
    if ($btns.length && press) {
        press = false;
        setTimeout(function() {
            $btns.trigger('click');
            press = true;
        }, 1500);
    }

    // fix se finiti
    $btnPantheon = $('.pantheon-pre-battle-btn');
    if ($btnPantheon.length)
        location.href = $btnPantheon.attr('href');
}, 300);

is_numeric = function(c) {
    return /^\d+$/.test(c);
}
replace_stats = function($el) {
    var str = $el.text().replace(/^\D+/g, ''),
        new_str = '';
    for (i = 0; i < str.length; i++) {
        var char = str.charAt(i)
        if (is_numeric(char))
            new_str += char;
    }
    return +new_str;
}
$(function() {
    var page = $('body').attr('page');

    if (page == 'harem') {
        var girls = null,
            interval_collect = false;

        collect = function() {
            console.log('reset');
            clearInterval(interval_collect);
            interval_collect = setInterval(collect, 20000);
            girls = $("div.girls_list>div[id_girl]>div[girl]:not(.not_owned)");
            collect_girl(0);
        }
        collect_girl = function(i) {
            if (i >= girls.length) return;

            var $girl = $(girls[i]),
                after = 0;
            if (!$girl.find('.salary.loads').length) {
                $girl.trigger("click");
                after = 100;
            }

            var total_salary = replace_stats($('#collect_all span[rel="next_salary"]'));
            if (i === girls.length - 1 && total_salary > 0) {
                $(".girls_list").scrollTop($girl.position().top);
                if (!$girl.parent().next().find('div[girl]').hasClass('not_owned'))
                    collect();
                else $girl.trigger("click");
            } else setTimeout(function() {
                collect_girl(i + 1);
            }, after);
        }
        is_cheat_click = function(e) { return false; }

        collect();
    } else if (page == 'season_arena') {
        var css_hero = '#season-arena .battle_hero .hero_stats_row',
            hero_power = replace_stats($(css_hero + ':first-child>div:first-child')),
            hero_crown = replace_stats($(css_hero + ':nth-child(2)>div:first-child')),
            opponent_index = 0;
        $('.opponents_arena .season_arena_opponent_container').each(function() {
            var $opponent_power = $(this).find('.hero_stats_row:first-child>div:first-child'),
                opponent_power = replace_stats($opponent_power),
                $opponent_crown = $(this).find('.hero_stats_row:nth-child(2)>div:first-child'),
                opponent_crown = replace_stats($opponent_crown),
                result_power = (hero_power >= opponent_power),
                result_crown = (hero_crown >= opponent_crown);
            $opponent_power.css('color', result_power ? '#53af00' : 'red');
            $opponent_crown.css('color', result_crown ? 'green' : 'red');
            if (!result_power || !result_crown)
                $('.opponents_arena .opponent_perform_button_container').eq(opponent_index).find('button').css({
                    'background': '#6a6a6a',
                    'box-shadow': '0 3px 0 rgb(23 33 7 / 60%), inset 0 3px 0 #3c3c3c',
                    '-webkit-box-shadow': '0 3px 0 rgb(23 33 7 / 60%), inset 0 3px 0 #3c3c3c',
                });
            opponent_index++;
        });
    }
});