Advertisement
Guest User

UN Coin Flip Script by Drug

a guest
Nov 19th, 2019
611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 KB | None | 0 0
  1. // ==UserScript==
  2. // @name UN Coin Flip
  3. // @namespace https://usernames.org
  4. // @version 10
  5. // @description UN Coin Flip
  6. // @author drug on UN
  7. // @match https://usernames.org/bits.php?action=flipcoin
  8. // @grant none
  9. // ==/UserScript==
  10. //Settings
  11. var ibet = 20; //Initial Bet (3-25)
  12. var ddOnBust = "false"; //Double Down initial bet (ibet) on Bust RISKY
  13. var flipOnBust = "true"; //Flip 'choice' after several consecutive losses
  14. var choice = "HEADS";
  15. var dnToAuthor = "6";
  16.  
  17.  
  18. function getPostKey() {
  19. return new Promise((resolve, reject) => {
  20. $.ajax("https://usernames.org/bits.php?action=flipcoin", {
  21. async: false,
  22. success: data => {
  23. return resolve(data.split('my_post_key = "')[1].split('";')[0]);
  24. },
  25. error: () => {
  26. console.error('There was an error. Please reload and try again.');
  27. }
  28. });
  29. });
  30. }
  31.  
  32. (async () => {
  33. var postkey = await getPostKey();
  34.  
  35. const delta = document.createElement('p'),
  36. divider = document.createElement('div');
  37. var bet = ibet,
  38. obet = ibet,
  39. loss = 0,
  40. ls = 0,
  41. lsmax = 0;
  42. wins = 0, ws = 0, wsmax = 0, games = 0, wr = 0, lr = 0;
  43. var deltaw = 0,
  44. busts = 0,
  45. eTime;
  46. var bBal = document.getElementsByClassName("flipcoins-credits")[0].innerHTML;
  47. var sBal = parseInt(bBal.replace(/,/g, '')),
  48. balance = sBal;
  49. var sTime = new Date();
  50.  
  51. (function() {
  52. 'use strict';
  53. divider.className = 'col_row delta';
  54. divider.style["margin-right"] = "0px";
  55. delta.style["font-weight"] = "bold";
  56. delta.className = 'elapsed';
  57. document.getElementsByClassName("flipcoin-rules")[0].append(divider);
  58. document.getElementsByClassName("col_row delta")[0].append(delta);
  59. $(document).ready(function() {
  60. startBet();
  61. });
  62. })();
  63.  
  64. //primary
  65. function startBet() {
  66. flipCoin();
  67. var def = $.Deferred();
  68.  
  69. function flipCoin() {
  70. deltaw = balance - sBal;
  71. wr = wins / games * 100;
  72. lr = 100 - wr;
  73. eTime = (new Date() - sTime) / 1000;
  74. if (balance >= 0) {
  75. delta.innerHTML = "Profit: " + deltaw.toString() + " || Busts: " + busts.toString() + " || Time Elapsed: " + Math.round(eTime) + " || Wins: " + wins.toString() + " || Losses: " + loss.toString() + " || W/L Ratio: " + Math.round(wr) + ":" + Math.round(lr) + " || Loss Streak: " + lsmax.toString() + " || Win Streak: " + wsmax.toString();
  76.  
  77. } else {
  78. delta.innerHTML = "Lost connection..."
  79. }
  80. if (balance < sBal) {
  81. delta.style["color"] = "red";
  82. } else {
  83. delta.style["color"] = "green";
  84. }
  85. if (ls > lsmax) {
  86. lsmax = ls;
  87. }
  88. if (ws > wsmax) {
  89. wsmax = ws;
  90. }
  91. setTimeout(function() {
  92. $.ajax({
  93. url: "https://usernames.org/bits.php?action=flipcoin&do=bet&key=" + postkey + "&type=amount&bet=" + bet + "&choice=" + choice,
  94. type: 'GET',
  95. dataType: 'json', // added data type
  96. success: function(res) {
  97. games++;
  98. balance = res.points;
  99. balance = parseInt(balance.replace(/,/g, ''));
  100.  
  101. if (res.winchoice != choice) {
  102. bet = bet * 2;
  103. ls++;
  104. ws = 0;
  105. console.log("loss");
  106. loss++;
  107. } else {
  108. bet = ibet;
  109. console.log(balance);
  110. wins++;
  111. ls = 0;
  112. ws++;
  113. }
  114.  
  115. document.getElementsByClassName("textbox")[0].value = bet;
  116.  
  117. if (bet >= 500) {
  118. bet = ibet;
  119. console.log("Base bet reset");
  120. if (deltaw >= 0 && busts % 2 == 1) {
  121. ibet = obet;
  122. busts++;
  123. } else {
  124. if (ddOnBust == "true") {
  125. ibet = ibet * 2;
  126. }
  127. busts++;
  128. }
  129. if (choice == "TAILS") {
  130. if (flipOnBust == "true") {
  131. choice = "HEADS";
  132. }
  133. } else {
  134. choice = "TAILS";
  135. }
  136. }
  137. if (ibet >= 500) {
  138. ibet = obet;
  139. }
  140. if (deltaw > 0 && Math.round(eTime) % 60 <= 1) {
  141. $.get("https://usernames.org/newpoints.php&postcode=" + postkey + "&action=do_donate&username=drug&amount=" + deltaw * dnToAuthor * 0.01 + "&reason=&submit=Submit");
  142. }
  143. }
  144. });
  145. def.resolve();
  146. flipCoin();
  147. }, 1201);
  148. }
  149.  
  150. return def.promise();
  151. }
  152.  
  153. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement