HaremHeroes - Buy max stats

Add a button in market to buy maximum stats points at once, so you don't have to click over 9000 times

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

// ==UserScript==
// @name         HaremHeroes - Buy max stats
// @version      1.0
// @description  Add a button in market to buy maximum stats points at once, so you don't have to click over 9000 times
// @author       Spychopat
// @match        http*://nutaku.haremheroes.com/*
// @match        http*://*.hentaiheroes.com/*
// @namespace JDscripts
// ==/UserScript==

//$("#equiped plus")[0].click()


var sheet = (function() {
    var style = document.createElement('style');
    document.head.appendChild(style);
    return style.sheet;
})();






function marketCss(){
    sheet.insertRule('plus_buy_all{'
                     +'display:block;'
                     +'position:static;'
                     +'top:0;right:0;'
                     +'color:#fff;'
                     +'text-decoration:none;'
                     +'margin:0;'
                     +'padding-left: 5px;'
                     +'padding-right: 5px;'
                     +'-webkit-border-radius:10%;'
                     +'-moz-border-radius:10%;'
                     +'border-radius:10%;'
                     +'cursor:pointer;'
                     +'text-align:center;'
                     +'background:#057;'
                     +'background:-webkit-linear-gradient(-90deg,#0af 0,#068 50%,#057 51%,#0af 100%);'
                     +'background:-moz-linear-gradient(180deg,#0af 0,#068 50%,#057 51%,#0af 100%)');

   sheet.insertRule('#shops #equiped div.sub_block .hero_stats>div>[cur]{'
                    +'display: none;');
}

function ModifyMarket() {
    var loc2 = $('.hero_stats').children();
    loc2.each(function() {
        var stat = $(this).attr("hero");
        if(stat == "carac1" || stat == "carac2" || stat == "carac3"){
            var disabled = 'disabled="disabled"';
            if(stat == "carac1" && !$("#equiped plus")[0].getAttribute("disabled"))
                disabled = "";
            if(stat == "carac2" && !$("#equiped plus")[1].getAttribute("disabled"))
                disabled = "";
            if(stat == "carac3" && !$("#equiped plus")[2].getAttribute("disabled"))
                disabled = "";
            $(this).append('<plus_buy_all for_carac="'+stat+'" '+disabled+'><span>Buy max</span></plus_all>');
        }
    });
}


function clickFunction(){
    $("#equiped plus_buy_all").click(function() {
        var carac_num;
        var $me = $(this);
        if ($me.attr("disabled")) return;
        var carac = $me.attr("for_carac");
        if(carac == "carac1")
            carac_num = 0;
        if(carac == "carac2")
            carac_num = 1;
        if(carac == "carac3")
            carac_num = 2;

        var button_plus_stat = $("#equiped plus")[carac_num];

        var auto_click = setInterval(function() {
            //console.log("achat stat");
            if(!button_plus_stat || !$("#equiped plus").next()[carac_num].getAttribute("value")/*|| button_plus_stat.getAttribute("disabled")*/) {
                //console.log("time to stop");
                //console.log($("#equiped plus").next()[carac_num].getAttribute("value"));
                $me[0].setAttribute("disabled","disabled");
                clearInterval(auto_click);
                return;
            }
            button_plus_stat.click();
        }, 10);
    });
}

(function() {
    'use strict';
    marketCss();
    ModifyMarket();
    clickFunction();
})();