HRPG+

Improved Heroes RPG GUI

Verze ze dne 08. 10. 2015. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        HRPG+
// @namespace   HRPG
// @description Improved Heroes RPG GUI
// @include     http://heroesrpg.com/game.php*
// @include     http://www.heroesrpg.com/game.php*
// @version     1.1.3
// @grant       none
// ==/UserScript==
// multiple skills, gem bonuses from accs/weps, notify update
// change tab title to CAPTCHA
$('#chat1').prepend(`<input type="submit" value="Cancel Autobuy" onclick="javascript:autoDo = false;"></input> Volume: <input id="volume" type="number" min="0" max="100" value="100" width="30" size="3"></input> <input type="checkbox" id="riftAlerts" checked="${window.localStorage.getItem('riftAlerts')||false?'checked':'none'}"></input> Nugget's RiftAlert™`);
//todo: calculate max autos, sell all accessories
$('#riftAlerts').change(function () {localStorage.setItem('riftAlerts',$('#riftAlerts').is(':checked'));});
$('#main').append('<input clicked="javascript:autoDo=false;">Cancel</input>');
$('body').append('<script src="http://cdn.rawgit.com/showdownjs/showdown/master/dist/showdown.js"></script>');
$('body').append('<script>Array.prototype.after = function (o){return this[this.indexOf(o)+1];}\nString.prototype.replaceAt = function(n, t) {return this.substring(0, n) + t + this.substring(n + 1);}</script>');

window.converter = new window.showdown.Converter();

window.autoDo = true;

window.rarityNum = new Object();
window.rarityNum.common = 1;
window.rarityNum.uncommon = 2;
window.rarityNum.rare = 3;
window.rarityNum.epic = 4;
window.rarityNum.legendary = 5;

window.command = new Object();
window.command.c = 'Posts <message> to clan chat.'
window.command.t = 'Posts <message> to trade chat.'
window.command.double = 'Shows length of double and haste remaining.'
window.command.haste = 'Shows length of double and haste remaining.'
window.command.commands = 'Shows a list of commands.'
window.command.command = 'Shows information about <commandname>.'
window.command.profile = 'Shows profile of <username>.'
window.command.who = 'Shows basic information of <username>.'
window.command.misc = 'Shows battles and quests of <username>.'
window.command.crafting = 'Shows crafting levels of <username>.'
window.command.gathering = 'Shows gathering levels of <username>.'
window.command.pick = 'Picks <number> <rarity> chests.'
window.command.pickall = 'Picks all <rarity> chests.'
window.command.boosts = 'Shows your boosts.'
window.command.buyboost = 'Buys <number> <name> boosts.'
window.command.buyauto = 'Buys <number> autos.'

window.boosts = new Object();
window.boosts.battleexp = 1;
window.boosts.gold = 2;
window.boosts.attribute = 3;
window.boosts.battlesp = 4;
window.boosts.gatheringexp = 5;
window.boosts.gatheringsp = 6;

window.onlineHTML = function(name){
  online = false;
  $.ajax({type:'POST', url:'misc.php', data:{mod:'playersonlinelist'}, success:function(data) { 
    if($.map($('td',data.v),function(n){return n.textContent;}).indexOf(name) != -1) {online = true;}
  }, dataType:'json', async: false});
  if(online) {return '[ONLINE]';}
  return '<font color="#FFBBBB">[OFFLINE]</font>';
}

window.maxAutos = function(credits) {
  //return credits = 10*Math.floor(autos/10)*(Math.floor(autos/10)-1) + 10*((autos/10)%1)*(Math.floor(autos/10))- 30
}

window.chatLine = function(msg){
  $('#chat_table1').prepend('<tr id=\"ct1_tr'+(chatid1)+'\"><td>'+msg+'</td></tr>');
  chatid1++;
}

window.send_chat = function(){
  autoDo = true;
  msg = chatInputElem.val();
  if(msg.toLowerCase() == '/commands'){
    chatLine('<font color="BBFFBB">/c &lt;message&gt;, /t &lt;message&gt;, /double, /haste /commands, /command &lt;commandname&gt;, /pick &lt;rarity&gt; &lt;number&gt;, /pickall &lt;rarity&gt;, /boosts, /buyboost &lt;boostname&gt; &lt;amount&gt;, /buyauto &lt;amount&gt;</font>');
    chatInputElem.val('');
    return;
  }
  if(msg.toLowerCase().startsWith('/command ')){
    commandName=msg.slice(9);
    chatInputElem.val('');
    chatLine(`<font color="BBFFBB">/${commandName}: ${command[commandName].replace('<','&lt;').replace('>','&gt')}</font>`);
    return;
  }
  if(msg.toLowerCase() == '/boosts'){
    $.post('upgrade.php', {mod:'boosts'}, function(data){
      for(i = 2; i < 8; i++){chatLine('<font color="BBFFBB">' + $('td',$('tr',data.v)[i])[0].textContent+': '+$('td',$('tr',data.v)[i])[1].textContent + '</font>');}
	  }, 'json');
    return;
  }
  if(msg.toLowerCase().startsWith('/buyboost ')){
    vars = msg.slice(10).split(' ');
    chatInputElem.val('');
    id = boosts[vars[0]];
    amount = Math.min(vars[1],$('#s_credits')[0].textContent/50);
    while (autoDo && amount > 0){
      amount--;
      spendCredits(id,'boost');
    }
    return;
  }
  if(msg.toLowerCase().startsWith('/buyauto ')){
    amount = Math.min(msg.slice(9),$('#s_credits')[0].textContent);
    chatInputElem.val('');
    while (autoDo && amount > 0){
      amount--;
      spendCredits(id,'boost');
    }
    return;
  }
  if(msg.toLowerCase().startsWith('/pick ')){
    vars = msg.slice(6).split(' ');
    rarity = rarityNum[vars[0]];
    chatInputElem.val('');
    if (rarity == undefined) return;
    $('#center_select').val(5);
    centerSelect();
    $('#craft_select')[0].selectedIndex = 4;
    craftSelect();
    console.log(rarity);
    amount = Math.min($('tr','#lockpicking-table')[parseInt(rarity)].childNodes[1].textContent,vars[1]);
    while (autoDo && amount > 9){
      amount -= 10;
      craftPickLock(rarity,2);
    }
    while (autoDo && amount > 0){
      amount--;
      craftPickLock(rarity,1);
    }
    return;
  }
  if(msg.toLowerCase().startsWith('/pickall ')){
    rarity=rarityNum[msg.slice(9)];
    chatInputElem.val('');
    if (rarity == undefined) return;
    $('select#center_select')[0].selectedIndex = 3;
    centerSelect();
    $('select#craft_select')[0].selectedIndex = 4;
    craftSelect();
    while (autoDo && $('tr','#lockpicking-table')[parseInt(rarity)].childNodes[1].textContent > 9) craftPickLock(rarity,2);
    while (autoDo && $('tr','#lockpicking-table')[parseInt(rarity)].childNodes[1].textContent > 0) craftPickLock(rarity,1);
    return;
  }
  if(msg.startsWith('/profile ')){
    viewPlayer(msg.slice(9));
    chatInputElem.val('');
    return;
  }
  if(msg.toLowerCase().startsWith('/who ')){
    $.post('misc.php', {mod:'viewplayer', id:msg.slice(5)}, function(data) {
      array = $.map($('td',$('table',data.v).find('tbody')[0]),function(n){return n.textContent;});
      name = array.after('Name:');
      chatLine(`<font color="BBFFBB"><a href="javascript:m('${name}');">${name}</a> - ${$('a',data.v)[0].outerHTML} - Level ${array.after('Level:')} - ${array.after('Nobility Rank:')} - ${onlineHTML(name)} - <a href="javascript:viewPlayer('${name}')">Profile</a></font>`);
    }, 'json');
    chatInputElem.val('');
    return;
  }
  if(msg.toLowerCase().startsWith('/misc ')){
    $.post('misc.php', {mod:'viewplayer', id:msg.slice(6)}, function(data) {
      array = $.map($('td',$('table',data.v).find('tbody')[0]),function(n){return n.textContent;});
      name = array.after('Name:');
      chatLine(`<font color="BBFFBB"><a href="javascript:m('${name}');">${name}</a> - Battles: ${array.after('Battles:')} - Battle Quests: ${array.after('Battle Quests:')} - TS Quests ${array.after('TS Quests:')}</font>`);
    }, 'json');
    chatInputElem.val('');
    return;
  }
  if(msg.toLowerCase().startsWith('/crafting ')){
    $.post('misc.php', {mod:'viewplayer', id:msg.slice(6)}, function(data) {
      array = $.map($('td',$('table',data.v).find('tbody')[0]),function(n){return n.textContent;});
      name = array.after('Name:');
      chatLine(`<font color="BBFFBB"><a href="javascript:m('${name}');">${name}</a> - Forging: ${array.after('Forging:')} - Leatherworking: ${array.after('Leatherworking:')} - Enchanting: ${array.after('Enchanting:')} - Lockpicking: ${array.after('Lockpicking:')} - Jewelcrafing: ${array.after('Jewelcrafting:')}</font>`);
    }, 'json');
    chatInputElem.val('');
    return;
  }
  if(msg.toLowerCase().startsWith('/gathering ')){
    $.post('misc.php', {mod:'viewplayer', id:msg.slice(6)}, function(data) {
      array = $.map($('td',$('table',data.v).find('tbody')[0]),function(n){return n.textContent;});
      name = array.after('Name:');
      chatLine(`<font color="BBFFBB"><a href="javascript:m('${name}');">${name}</a> - Hunting: ${array.after('Hunting:')} - Mining: ${array.after('Mining:')} - Woodcutting: ${array.after('Woodcutting:')} - Quarrying: ${array.after('Quarrying:')}</font>`);
    }, 'json');
    chatInputElem.val('');
    return;
  }
  if(msg.toLowerCase().startsWith('/g ')){msg.replaceAt(2,'c');}
  $.post('chat.php', {mod:'send', msg:msg}, function(data) {
    if(!data.err) {
      if(data.addignore) {ignored.push(data.addignore);}
      if(data.remignore) {ignored.splice(ignored.indexOf(data.remignore, 1));}
      chatInputElem.val('');
      chatinactivity = 0;
      update_chat(0);
    } else { displayError(data.err); }
  }, 'json');
}

window.bRightSelect = function() {
  mod = $('#bright_select').val();
  $.post('displayr.php', {mod:mod}, function(data) {
    $('#bright_content').html(data.html);
    if($('select#bright_select')[0].options[$('select#bright_select')[0].selectedIndex].text == 'Items') {
      $('#bright_content').html($('#bright_content').html().replace(/\[<a href="javascript:openChest\((\d),1\)">Open<\/a>\]/g, `<a href="javascript:$('select#center_select')[0].selectedIndex = 3; centerSelect(); $('select#craft_select')[0].selectedIndex = 4; craftSelect(); craftPickLock($1,1);">P</a> <a href="javascript:$('select#center_select')[0].selectedIndex = 3; centerSelect(); $('select#craft_select')[0].selectedIndex = 4; craftSelect(); craftPickLock($1,2);">10</a> <a href="javascript:openChest($1,1);">O</a>`));
    }
  }, 'json');
}

window.update_chat = function(initiate) {
  stopActivityTimer();
  startActivityTimer();
  $.post('chatupdate2.php', {initiate:initiate}, function(data) {
    if(data.c) {
      $.each(data.c, function(i, item) {
        if($.inArray(data.c[i].uid, ignored) < 0) {
          chat_table = 1;
          data.c[i].message = converter.makeHtml(data.c[i].message);
          if(data.c[i].type == 1) { msg = '<span class="time">['+data.c[i].time+']</span> '+genrank(data.c[i].nrank, data.c[i].prank)+' '+genStatus(data.c[i].status)+'<a href="javascript:m(\''+data.c[i].cname+'\');">'+data.c[i].cname+'</a>: '+data.c[i].message+'</span>'; }
          else if(data.c[i].type == 0) { msg = '<span class="time">['+data.c[i].time+']</span> <span style="color: #FF8888">'+data.c[i].message+'</span>'; }
          else if(data.c[i].type == 5) { msg = '<span class="time">['+data.c[i].time+']</span> <span style="color: #55AA55">'+data.c[i].message+'</span>'; }
          else if(data.c[i].type == 10) { msg = '<span class="time">['+data.c[i].time+']</span> <span style="color: #88FF88">Global: '+data.c[i].message+'</span>';
            if($('#riftAlerts')[0].checked && data.c[i].message == 'A Rift will open in 5 minutes!') {audio = new Audio('http://cdn.rawgit.com/somebody1234/misc-files/master/rift.mp3');audio.volume=$('#volume')[0].value/100; audio.play();}
          else if(data.c[i].type == 1000) { msg = '<span class="time">['+data.c[i].time+']</span> '+genrank(data.c[i].nrank, data.c[i].prank)+' <span style="color: #FFFF00">[Clan] <a href="javascript:m(\''+data.c[i].cname+'\');">'+data.c[i].cname+'</a>: '+data.c[i].message+'</span>'; }
          else if(data.c[i].type == 1001) { msg = '<span class="time">['+data.c[i].time+']</span> <span style="color: #FFFF00">Clan Global: '+data.c[i].message+'</span>'; }
          else if(data.c[i].type == 20) { msg = '<span class="time">['+data.c[i].time+']</span> '+genrank(data.c[i].nrank, data.c[i].prank)+' <span style="color: #9999FF">[Newbie] <a href="javascript:m(\''+data.c[i].cname+'\');">'+data.c[i].cname+'</a>: '+data.c[i].message+'</span>'; }
          else if(data.c[i].type == 30) { msg = '<span class="time">['+data.c[i].time+']</span> '+genrank(data.c[i].nrank, data.c[i].prank)+' <span style="color: #FF9933">[Staff] <a href="javascript:m(\''+data.c[i].cname+'\');">'+data.c[i].cname+'</a>: '+data.c[i].message+'</span>'; }
          else if(data.c[i].type == 55) { msg = '<span class="time">['+data.c[i].time+']</span> '+genrank(data.c[i].nrank, data.c[i].prank)+' <span style="color: #00BB00">[Trade] <a href="javascript:m(\''+data.c[i].cname+'\');">'+data.c[i].cname+'</a>: '+data.c[i].message+'</span>'; }
          else if(data.c[i].type == 50) { msg = '<span class="time">['+data.c[i].time+']</span> <span style="color: #FF7171">Message Received: <a href="javascript:m(\''+data.c[i].cname+'\');">'+data.c[i].cname+'</a>: '+data.c[i].message+'</span>'; }
          else if(data.c[i].type == 51) { msg = '<span class="time">['+data.c[i].time+']</span> <span style="color: #F59292">Message Sent: <a href="javascript:m(\''+data.c[i].cname+'\');">'+data.c[i].cname+'</a>: '+data.c[i].message+'</span>'; }
          else if(data.c[i].type == 2) { msg = '<span class="time">['+data.c[i].time+']</span> '+genrank(data.c[i].nrank, data.c[i].prank)+' <i>* '+genStatus(data.c[i].status)+'<a href="javascript:m(\''+data.c[i].cname+'\');">'+data.c[i].cname+'</a> '+data.c[i].message+'</span></i>'; }
          else if(data.c[i].type == 99) { msg = '<span class="time">['+data.c[i].time+']</span> '+data.c[i].message; chat_table = 10; }
          else if(data.c[i].type == 101) { msg = '<span class="time">['+data.c[i].time+']</span> '+genrank(data.c[i].nrank, data.c[i].prank)+' '+genStatus(data.c[i].status)+'<a href="javascript:m(\''+data.c[i].cname+'\');">'+data.c[i].cname+'</a>: '+data.c[i].message+'</span>'; chat_table = 50; }
          if(chat_table == 10) {
            $('#chat_table10').prepend('<tr id=\"ct10_tr'+(chatid10)+'\"><td>'+msg+'</td></tr>');
            chatid10++;
            if(chatview != 10) { chatcount10++; $('#chatcount10').html(' ('+chatcount10+')'); }
            if(initiate == 0) { $('#ct10_tr'+(chatid10-chatsize)).remove(); }
          }
          else if(chat_table == 50) {
            $('#chat_table50').prepend('<tr id=\"ct50_tr'+(chatid50)+'\"><td>'+msg+'</td></tr>');
            chatid50++;
            if(initiate == 0) { $('#ct50_tr'+(chatid50-chatsize)).remove(); }
          }
          else {
            chatLine(msg);
            if(chatview != 1) { chatcount1++; $('#chatcount1').html(' ('+chatcount1+')'); }
            if(initiate == 0) { $('#ct1_tr'+(chatid1-chatsize)).remove(); }
          }
        }
        if(data.fl) {window.location = 'http://www.heroesrpg.com';}
      });
    }
    stopActivityTimer();
    clearTimeout(chattimer);
    if(chatinactivity < 20) {
      chatinactivity++;
      chattimer = setTimeout(function() {
        update_chat(0);
      }, 5000);
    } else {
      chattimer = setTimeout(function() {
        update_chat(0);
      }, 9000);
    }
  }, 'json');
}