Guest User

Untitled

a guest
May 1st, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. // ==UserScript==
  2. // @name AM Assistent
  3. // @author Tjeerdo (skype: tjeerdov, AF-naam: .Arrogant)
  4. // @version 1.0
  5. // @namespace www.tribalwars.nl
  6. // @description Met dit script worden verschillende handelingen bij de AM makkelijker gemaakt
  7. // @include https://*.tribalwars.nl/game.php*
  8. // ==/UserScript==
  9.  
  10. $( document ).ready( function() {
  11. // AM import / export test
  12. $('#template_queue').parent().before( '<div id="AR_AMExportArea" style="background-color:#FFF;padding:10px;height:auto; width:100%;display:none;"></div><div><button id="exportAM">Export</button><button id="importAM">Import</button></div>' );
  13. $( '#exportAM' ).on( "click", function() {
  14. var exportList = [];
  15. $( '#template_queue' ).children( '.sortable_row' ).each( function() {
  16. exportList.push( {
  17. "building": $( this ).data( "building" ),
  18. "levelsUp": $( this ).find( '.level_relative' ).text().match(/\d+/)[0]
  19. } );
  20. } )
  21. $( "#AR_AMExportArea" ).text( JSON.stringify( exportList ) ).show();
  22. } )
  23.  
  24. $( '#importAM' ).on( "click", function() {
  25. var importedList = JSON.parse( prompt( "Voer hier de export van de AM in" ) );
  26. var buildingsList = [];
  27. $.each( importedList, function() {
  28. buildingsList.push( this.building + ':' + this.levelsUp );
  29. } )
  30. $('#queue_data').val( buildingsList.join(';') ).closest( 'form' ).removeAttr('onsubmit').find(':submit').click();
  31. } )
  32. } )
Add Comment
Please, Sign In to add comment