Last active
January 26, 2018 18:21
-
-
Save Fuzzyma/8e320b494803a4b511d0acc4c501afcd to your computer and use it in GitHub Desktop.
Tribalwars: Fügt einen Button hinzu, der das Nachschicken von Supporttruppen ermöglicht, die gestorben sind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Truppen Nachsenden | |
// @namespace tribalswars | |
// @description Fügt einen Button hinzu, der das Nachschicken von Supporttruppen ermöglicht, die gestorben sind | |
// @include https://*.die-staemme.de/game.php*screen=report* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
;(function(){ | |
var $report_ReportSupportAttackMerged = $('.report_ReportSupportAttackMerged') | |
if(!$report_ReportSupportAttackMerged.length) return | |
var villages = $('.report_ReportSupportAttackMerged .village_anchor') | |
var units = $report_ReportSupportAttackMerged.find('table.vis .unit_link').map(function() { return $(this).data('unit') }).get() | |
var losses = $report_ReportSupportAttackMerged.find('table.vis tr:nth-child(3) td.unit-item').map(function() { return $(this).text() }).get() | |
var buttons = $report_ReportSupportAttackMerged.closest('table').next().find('tbody tr:first') | |
var villageToSupport = villages.eq(0).data('id') | |
villages.each(function(index, el) { | |
if(index == 0) return | |
var url = [ | |
'game.php?village=', | |
villages.eq(index).data('id'), | |
'&screen=place&target=', | |
villageToSupport | |
].join('') | |
for(var i = (index-1) * 12; i < (index) * 12; ++i) { | |
url += '&' + units[i] + '=' + losses[i] | |
} | |
$(this).closest('table').next().append($('<tfoot><tr><td colspan="100" align="right"><a href="'+ url +'" target="_blank">Nachschicken</a></td></tr></tfoot>')) | |
}) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment