Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Farm Manager click helper
- // @namespace farmmanagerclickhelper.com
- // @include http*://de*.die-staemme.de/game.php*screen=am_farm
- // @version 1
- // @grant none
- // ==/UserScript==
- $(document).ready(function() {
- var slowSending = false;
- $("#plunder_list_filters").append("<br/><br/><br/><br/><br/><button id='clickAButton'>Klick A</button><button id='clickBButton' onclick='clickB()'>Klick B</button><br/>");
- $("#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/>");
- $("#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");
- $("#clickAButton").click(function(e) {
- $("a.farm_icon_a").each( function( index, element ){ $( this ).click();});
- });
- $("#clickBButton").click(function(e) {
- $("a.farm_icon_b").each( function( index, element ){ $( this ).click();});
- });
- $("#sendManyButton").click(function(e) {
- var countAttacks = $("#countAttacks").val();
- if(countAttacks > 0) {
- // Find the target village id
- var target_class_name = $("table tr.row_a").first().attr('class');
- if(target_class_name === 'undefined')
- return;
- // Split for space to get report_17932 then remove report_
- var target_village = parseInt(target_class_name.split(" ")[0].substring(7));
- sendTroups(countAttacks, target_village);
- }
- });
- $("#sendToSpecific").click(function(e) {
- var countAttacks = $("#countAttacks").val();
- if(countAttacks > 0) {
- var targetVillage = $("#villageIdToFarm").val();
- sendTroups(countAttacks, targetVillage);
- }
- });
- function sendTroups(countAttacks, targetVillage) {
- var worker = new Worker('https://pastebin.com/raw.php?i=4ZBCA92r');
- worker.postMessage('test the worker');
- // Find the template id
- var template_ids = [];
- $("div.vis form").each(function(a, b) {
- if(template_ids.length <= 1) {
- var actionString = $(this).attr('action');
- var indexOf = actionString.indexOf('template_id=');
- var template_id = parseInt(actionString.substring(indexOf + 12).split("&")[0]);
- template_ids.push(template_id);
- }
- });
- var data = {
- target: targetVillage,
- template_id: template_ids[0],
- source: game_data.village.id
- };
- var i = 0;
- var sendTroups = function() {
- TribalWars.post(Accountmanager.send_units_link, null, data, function(data) {
- Accountmanager.farm.updateOwnUnitsAvailable(data.current_units);
- });
- i++;
- if(i < countAttacks) {
- if($('#fastSending').is(':checked')) {
- sendTroups();
- } else {
- setTimeout(sendTroups, Math.floor((Math.random()*250)+250));
- }
- }
- };
- sendTroups();
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement