Advertisement
sil3nced

City Finds

Mar 20th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. // ==UserScript==
  2. // @name City Find Hax
  3. // @namespace City Find Hax
  4. // @version 0.4
  5. // @description
  6. // @author AquaRegia
  7. // @match http://www.torn.com/city.php*
  8. // @match https://www.torn.com/city.php*
  9. // @match http://torn.com/city.php*
  10. // @match https://torn.com/city.php*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function(open) {
  15.  
  16. XMLHttpRequest.prototype.open = function(method, url, async, user, pass)
  17. {
  18. if(url.indexOf("step=mapData") != -1)
  19. {
  20. this.addEventListener("readystatechange", function()
  21. {
  22. if(this.readyState == 4)
  23. {
  24. var data = JSON.parse(atob(JSON.parse(this.responseText).territoryUserItems));
  25. console.log(data);
  26.  
  27.  
  28. jQuery("h4").after
  29. (
  30. jQuery("<div></div>").html
  31. (
  32. "Number of items currently in the city: " + data.length +
  33. "<br/>" +
  34. "Latest item spawned: " + (data.length > 0 ? data[data.length-1].title : "Nothing, no point in searching") +
  35. (data.length > 1 ? (
  36. "<br/>" +
  37. "Spawn rate (all time): " + function(a, b)
  38. {
  39. return ((a - b)/(data.length - 1)/3600).toFixed(1) + " hours per spawn";
  40.  
  41. }(parseInt(data[data.length-1].ts, 36), parseInt(data[0].ts, 36)) +
  42. "<br/>" +
  43. "Spawn rate (last " + Math.min(5, data.length) + "): " + function(a, b)
  44. {
  45. return ((a - b)/(Math.min(5, data.length) - 1)/3600).toFixed(1) + " hours per spawn";
  46. }(parseInt(data[data.length-1].ts, 36), parseInt(data[data.length-(Math.min(5, data.length))].ts, 36))) : "")
  47. ).css("clear", "left")
  48. .css("margin-bottom", "-20px")
  49. );
  50. }
  51. }, false);
  52. }
  53.  
  54. open.call(this, method, url, async, user, pass);
  55. };
  56.  
  57. })(XMLHttpRequest.prototype.open);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement