Zombs Retextured (Browser)

Retextured but for browser

  1. // ==UserScript==
  2. // @name Zombs Retextured (Browser)
  3. // @namespace https://discord.gg/fcf3SH6sHJ
  4. // @version 1.0
  5. // @description Retextured but for browser
  6. // @author Jamz
  7. // @match https://zombsroyale.io/
  8. // @icon https://www.google.com/s2/favicons?domain=zombsroyale.io
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. var config = [
  13. ["3 Little Monkies","Colossal Bat Wings"],
  14. ["Bat","Saturn Chute"],
  15. ["8-Bit Blade", "Surtr Blade"],
  16. ["Happy","Poop"],
  17. ["Albert","8-Bit Default"],
  18. ["Bounty Hunter (Blue)","8-Bit Glasses"],
  19. ["Alien Intel Gatherer","Daedalus Wings"],
  20. ["Galaxy","Adept Wizard"],
  21. ["Giant Bot","Afro (Blue)"],
  22. ["Xeno","Afro (Orange)"],
  23. ["Scientist","Afro (Peach)"],
  24. ["Demon Wings","Alien Tentacles"],
  25. ["Berry Branch Wings","Android Utility Pack"],
  26. ["Antler Crown","Toucan Wings"],
  27. ["Alien Beast","Afro (Pink)"],
  28. ["Alien Brain","Afro (Purple)"],
  29. ["Purple Spear","All-Seeing Sword"],
  30. ["Alien Beast Claws","Anchor Sword (Blue)"],
  31. ["Discord Nitro Gloves","Anchor Sword (Light Purple)"],
  32. ["Chief Tribal Mask","Afro (Red)"],
  33. ["Spooky Skull","Afro (Sky)"],
  34. ["Spooky Flame Wings","Azure Football Pack"],
  35. ["American Wings","Baby Koala"],
  36. ["Dino Wings","Ballooned Tail"],
  37. ["Bone Wings","Bottled Message"],
  38. ["Evil Wings","Bow Tied"],
  39. ["Cat Tail","Brilliant Shells"],
  40. ["Unlucky Cat","Afro (White)"],
  41. ["Ankylosaur Fossil","Aggro Lobster"],
  42. ["Apep","Air Daredevil"],
  43. ["Terror","Alien Automaton"],
  44. ["Terror Eyes","Alien Identifier"],
  45. ["Terror Corruption","Amazonian Manatee"],
  46. ["Black Knight","Ancient Wizard Dragon"],
  47. ["Block Of Coal","Android"],
  48. ]
  49.  
  50.  
  51. // here we will modify the response
  52. function modifyResponse(response) {
  53.  
  54. var original_response, modified_response, string_original;
  55.  
  56. if (this.readyState === 4) {
  57. if (!response.target.responseURL.includes("/api/shop/available")) return
  58.  
  59. // we need to store the original response before any modifications
  60. // because the next step will erase everything it had
  61. var enc = new TextEncoder("utf-8");
  62. var dec = new TextDecoder("utf-8");
  63. original_response = JSON.parse(dec.decode(response.target.response));
  64.  
  65. // here we "kill" the response property of this request
  66. // and we set it to writable
  67. Object.defineProperty(this, "response", { writable: true });
  68.  
  69. config.forEach(function (retexture) {
  70. var findIndex = original_response.items.findIndex((o) => o.name == retexture[0]);
  71. var replaceIndex = original_response.items.findIndex((o) => o.name == retexture[1]);
  72. var ogFindSku = original_response.items[findIndex].sku
  73. var ogReplaceSku = original_response.items[replaceIndex].sku
  74. original_response.items[findIndex].sku = ogReplaceSku
  75. original_response.items[replaceIndex].sku = ogFindSku
  76. })
  77.  
  78. this.response = enc.encode(JSON.stringify(original_response))
  79. }
  80. }
  81.  
  82. // here we listen to all requests being opened
  83. function openBypass(original_function) {
  84.  
  85. return function (method, url, async) {
  86.  
  87. // here we listen to the same request the "original" code made
  88. // before it can listen to it, this guarantees that
  89. // any response it receives will pass through our modifier
  90. // function before reaching the "original" code
  91. this.addEventListener("readystatechange", modifyResponse);
  92.  
  93. // here we return everything original_function might
  94. // return so nothing breaks
  95. return original_function.apply(this, arguments);
  96.  
  97. };
  98.  
  99. }
  100.  
  101. // here we override the default .open method so that
  102. // we can listen and modify the request before the original function get its
  103. XMLHttpRequest.prototype.open = openBypass(XMLHttpRequest.prototype.open);
  104. // to see the original response just remove/comment the line above
  105.  
  106. /---END RETEXTURE-----------------------------------------------------------------/// ==UserScript==