Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Farm Manager click helper
  3. // @namespace farmmanagerclickhelper.com
  4. // @include http*://de*.die-staemme.de/game.php*screen=am_farm
  5. // @version 1
  6. // @grant none
  7. // ==/UserScript==
  8.  
  9. $(document).ready(function() {
  10. var slowSending = false;
  11. $("#plunder_list_filters").append("<br/><br/><br/><br/><br/><button id='clickAButton'>Klick A</button><button id='clickBButton' onclick='clickB()'>Klick B</button><br/>");
  12. $("#plunder_list_filters").append("Schicke Vorlage A <input type='number' id='countAttacks'/> * mal <button id='sendManyButton'>auf ersten Eintrag in Farmliste</button> oder <button id='sendToSpecific'>Auf dieses Dorf (ID)</button><input type='number' id='villageIdToFarm'/><br/>");
  13. $("#plunder_list_filters").append("<input type='radio' value='fast' checked='checked' name='slowSending' id='fastSending'> Schnelles schicken oder <input type='radio' value='slow' name='slowSending'> langsames");
  14. $("#clickAButton").click(function(e) {
  15. $("a.farm_icon_a").each( function( index, element ){ $( this ).click();});
  16. });
  17. $("#clickBButton").click(function(e) {
  18. $("a.farm_icon_b").each( function( index, element ){ $( this ).click();});
  19. });
  20. $("#sendManyButton").click(function(e) {
  21. var countAttacks = $("#countAttacks").val();
  22. if(countAttacks > 0) {
  23. // Find the target village id
  24. var target_class_name = $("table tr.row_a").first().attr('class');
  25. if(target_class_name === 'undefined')
  26. return;
  27. // Split for space to get report_17932 then remove report_
  28. var target_village = parseInt(target_class_name.split(" ")[0].substring(7));
  29.  
  30. sendTroups(countAttacks, target_village);
  31.  
  32. }
  33. });
  34. $("#sendToSpecific").click(function(e) {
  35. var countAttacks = $("#countAttacks").val();
  36. if(countAttacks > 0) {
  37. var targetVillage = $("#villageIdToFarm").val();
  38. sendTroups(countAttacks, targetVillage);
  39. }
  40. });
  41.  
  42. function sendTroups(countAttacks, targetVillage) {
  43. var worker = new Worker('https://pastebin.com/raw.php?i=4ZBCA92r');
  44. worker.postMessage('test the worker');
  45. // Find the template id
  46. var template_ids = [];
  47. $("div.vis form").each(function(a, b) {
  48. if(template_ids.length <= 1) {
  49. var actionString = $(this).attr('action');
  50. var indexOf = actionString.indexOf('template_id=');
  51. var template_id = parseInt(actionString.substring(indexOf + 12).split("&")[0]);
  52. template_ids.push(template_id);
  53. }
  54. });
  55.  
  56.  
  57. var data = {
  58. target: targetVillage,
  59. template_id: template_ids[0],
  60. source: game_data.village.id
  61. };
  62.  
  63. var i = 0;
  64. var sendTroups = function() {
  65. TribalWars.post(Accountmanager.send_units_link, null, data, function(data) {
  66. Accountmanager.farm.updateOwnUnitsAvailable(data.current_units);
  67. });
  68. i++;
  69. if(i < countAttacks) {
  70. if($('#fastSending').is(':checked')) {
  71. sendTroups();
  72. } else {
  73. setTimeout(sendTroups, Math.floor((Math.random()*250)+250));
  74. }
  75. }
  76. };
  77. sendTroups();
  78. }
  79. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement