Advertisement
Hirsw0w

[Datdrop] House edge calculator script

Jan 12th, 2021
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. var cases = [];
  2. fetch("https://api.datdrop.com/api/dropcase/", {
  3. "headers": {
  4. "accept": "application/json",
  5. "accept-language": "he-IL,he;q=0.9,en-US;q=0.8,en;q=0.7,nl;q=0.6",
  6. "sec-fetch-dest": "empty",
  7. "sec-fetch-mode": "cors",
  8. "sec-fetch-site": "same-site",
  9. "x-application-id": "730",
  10. "x-client-id": "15828987403100.204253287691756",
  11. "x-client-version": "7",
  12. "x-language": "en",
  13. "x-nonce": "3004542"
  14. },
  15. "referrer": "https://datdrop.com/",
  16. "referrerPolicy": "no-referrer-when-downgrade",
  17. "body": null,
  18. "method": "GET",
  19. "mode": "cors",
  20. "credentials": "omit"
  21. }).then((response) => response.json()).then((myJson) => {
  22. cases = myJson;
  23. var count = 0;
  24. var cases = cases.filter((a) => a.stock == "in_stock" && a.human_price < 350).sort((a, b) => a.human_price - b.human_price);
  25. for(var c of cases) {
  26. var slug = c.slug;
  27. callTimeOut(slug, count++);
  28.  
  29. }
  30.  
  31. function callTimeOut(caseName, count) {
  32. setTimeout(function() {
  33. calculateCase(caseName);
  34. }, 1000 * count);
  35. }
  36. });
  37. var output = "";
  38.  
  39. function calculateCase(caseName)
  40. {
  41. fetch("https://api.datdrop.com/api/dropcase/" + caseName, {
  42. "headers": {
  43. "accept": "application/json",
  44. "accept-language": "he-IL,he;q=0.9,en-US;q=0.8,en;q=0.7,nl;q=0.6",
  45. "sec-fetch-dest": "empty",
  46. "sec-fetch-mode": "cors",
  47. "sec-fetch-site": "same-site",
  48. "x-application-id": "730",
  49. "x-client-id": "15985402558040.49803865996272023",
  50. "x-client-version": "7",
  51. "x-language": "en",
  52. "x-nonce": "6905797"
  53. },
  54. "referrer": "https://datdrop.com/",
  55. "referrerPolicy": "strict-origin-when-cross-origin",
  56. "body": null,
  57. "method": "GET",
  58. "mode": "cors",
  59. "credentials": "omit"
  60. }).then((response) => response.json()).then((myJson) => {
  61. var items = myJson.items;
  62. var chances = myJson.chances;
  63.  
  64. var casePrice = myJson.human_price;
  65. var shouldBePrice = 0;
  66. for (var item of items) {
  67. var chance = chances[item.id].human_chance;
  68. var price = item.human_drop_price;
  69. shouldBePrice += price * chance;
  70. }
  71. var houseEdge = (1 - (1 / (casePrice / shouldBePrice))) * 100;
  72. output += "Case Name: " + myJson.name + " | Case Price: " + casePrice.toFixed(2) + " | Price should be: " + shouldBePrice.toFixed(2) + " | House Edge: " + houseEdge.toFixed(2) + "%\n";
  73. console.log("Case Name: " + myJson.name + " | Case Price: " + casePrice.toFixed(2) + " | Price should be: " + shouldBePrice.toFixed(2) + " | House Edge: " + houseEdge.toFixed(2) + "%");
  74. });
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement