Top Tankers Improvements

try to take over the world!

  1. // ==UserScript==
  2. // @name Top Tankers Improvements
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match http://worldoftanks.eu/en/top_tankers/*
  8. // @grant none
  9. // @namespace https://greasyfork.org/users/63466
  10. // ==/UserScript==
  11.  
  12. jQuery(window).load(function()
  13. {
  14. var userID = $.cookie("cm.options.user_id");
  15.  
  16. if (userID)
  17. {
  18. var vehicleDataUrl = "http://worldoftanks.eu/aow/vehicles/by_filters/?filter%5Bnation%5D=&filter%5Blanguage%5D=en&filter%5Bpremium%5D=0%2C1&filter%5Baccount_id%5D=" + userID;
  19.  
  20. var globalStore = {};
  21. var globalRank = {};
  22.  
  23. $.when(
  24. $.getJSON(vehicleDataUrl, function(data)
  25. {
  26. if (data['status'] == 'ok')
  27. {
  28. var allVehicles = data['data']['data'];
  29.  
  30. globalStore.data = new Array();
  31.  
  32. for (var i = 0; i < allVehicles.length; i++)
  33. {
  34. var vehicle = {};
  35. vehicle.name = allVehicles[i][4];
  36. vehicle.tier = allVehicles[i][2];
  37. vehicle.id = allVehicles[i][5];
  38. vehicle.rank = 0;
  39. vehicle.delta = 0;
  40.  
  41. var singleVehicleUrl = "http://worldoftanks.eu/aow/ratings/accounts/by_vehicle/?vehicle_cd=" + vehicle.id + "&vehicle_tier=" + vehicle.tier + "&lang=en&page=1&page_size=1&extra_accounts=" + userID;
  42. $.getJSON(singleVehicleUrl, function(data2)
  43. {
  44. if (data2['status'] == 'ok')
  45. {
  46. var rank = {};
  47.  
  48. rank.rank = data2.data.extra_account[0]['rank'];
  49. rank.delta = data2.data.extra_account[0]['rank_delta'];
  50. rank.id = data2.data.extra_account[0]['vehicle_cd'];
  51.  
  52. $.each(globalStore.data, function()
  53. {
  54. if (this.id == rank.id)
  55. {
  56. this.rank = rank.rank;
  57. this.delta = rank.delta;
  58. this.id = rank.id;
  59. var string = "<div style='display:block;margin-left:auto;margin-right:auto;top:0;position:absolute;padding-top:20px;'>Rank: " + this.rank + " \nDelta " + this.delta + "</div>";
  60. $('a[href$="/' + this.name + '/"]').append(string);
  61. }
  62. });
  63. }
  64.  
  65. });
  66.  
  67. globalStore.data.push(vehicle);
  68. }
  69. }
  70. })
  71. .fail(function()
  72. {
  73. console.log("Cannot get vehicles for user " + userID);
  74. })
  75.  
  76. ).then(function()
  77. {
  78. console.log("Data Collected");
  79. });
  80. };
  81. });