energ1zer's Primedice Add-On Suite

A collection of helpful, user-made addons that are all activated automatically every time one visits Primedice.

  1. // ==UserScript==
  2. // @name energ1zer's Primedice Add-On Suite
  3. // @namespace http://cntrlcntr.pw
  4. // @version 0.1
  5. // @description A collection of helpful, user-made addons that are all activated automatically every time one visits Primedice.
  6. // @author energ1zer
  7. // @grant none
  8. // @include *primedice.com*
  9. // @exclude
  10. // ==/UserScript==
  11.  
  12. // --------------------------------
  13. // PrimeDice - Bet Amount to USD
  14. // --------------------------------
  15. // By: paradocks for mah niggah dank
  16. // --------------------------------
  17. var loss = '.live-data__profit-lost';
  18. var win = '.live-data__profit-won';
  19. var currentprice;
  20.  
  21. function btcPrice() {
  22. var result = null;
  23. $.ajax({
  24. url: 'https://blockchain.info/q/24hrprice',
  25. type: 'get',
  26. dataType: 'html',
  27. async: false,
  28. success: function(data) {
  29. result = data;
  30. }
  31. });
  32. currentprice = result;
  33. start();
  34. }
  35. btcPrice();
  36.  
  37. function start() {
  38. setInterval(function() {
  39. var curPrice = currentprice;
  40. for(i = 0; i < $(loss).length; i++) {
  41. var newValue = $(loss)[i].innerText.substr(0, 11);
  42. var USD = (currentprice * (newValue)).toFixed(2);
  43. $(loss)[i].innerText = newValue + '($' + USD + ')';
  44.  
  45.  
  46. }
  47. for(i = 0; i < $(win).length; i++) {
  48. var newValue = $(win)[i].innerText.substr(0, 10);
  49. var USD = (currentprice * (newValue)).toFixed(2);
  50. $(win)[i].innerText = newValue + '($' + USD + ')';
  51.  
  52. }
  53. }, 1500);
  54. }
  55. // USD Converter End
  56. /*
  57. // Serlite's Faucet Timer
  58. */
  59. var sinceLastClaim = 0;
  60. var $fTimer = null;
  61. var $fTimerWrapper = null;
  62. var fIntervalRef = null;
  63. var fTimerHider = {17: false, 18: false, 90:false};
  64.  
  65. initializeTimer();
  66.  
  67. // Creates GUI and begins timer countdown
  68. function initializeTimer(){
  69.  
  70. if (!window.jQuery.ui){
  71. $("body").append("<script src='//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.js'></script>");
  72. }
  73.  
  74. // Delay to allow jQuery UI to load
  75. setTimeout(function(){
  76. $("body").append("<div class='faucet-timer' style='background:#FFF; border:2px solid #b4b9cd; position:fixed; z-index:9999; top:100px; left:200px; color:#6d738c; padding:15px; font-size:1em'><p style='margin-bottom:10px;'>Since last claim:</p><p><span class='time-counter' style='font-weight:bold;'>00:00</span></p></div>");
  77.  
  78. // Caching reference
  79. $fTimer = $(".faucet-timer .time-counter");
  80. $fTimerWrapper = $(".faucet-timer");
  81. $fTimerWrapper.draggable();
  82.  
  83. fIntervalRef = setInterval(updateFaucetTime, 1000);
  84.  
  85. // Reset timer if claim button is pressed
  86. $(document).on("click", "button.btn.btn--primary.btn--huge.btn--block", function(){
  87. if ($(this).text() == "Claim"){
  88. sinceLastClaim = 0;
  89. writeFaucetTime(formattedFaucetTime());
  90. setTimerCol();
  91.  
  92. // Reset interval ensure precision
  93. clearInterval(fIntervalRef);
  94. fIntervalRef = setInterval(updateFaucetTime, 1000);
  95. }
  96. });
  97.  
  98. // Register key down in combo
  99. $(document).keydown(function(e){
  100. if (e.keyCode in fTimerHider){
  101. fTimerHider[e.keyCode] = true;
  102.  
  103. // Ctrl + Alt + Z, toggle visible
  104. if (fTimerHider[17] && fTimerHider[18] && fTimerHider[90]){
  105. $fTimerWrapper.toggle();
  106. }
  107. }
  108. });
  109.  
  110. // Register key up in combo
  111. $(document).keyup(function(e){
  112. if (e.keyCode in fTimerHider){
  113. fTimerHider[e.keyCode] = false;
  114. }
  115. });
  116.  
  117. }, 1500);
  118. }
  119.  
  120. // Increment timer value
  121. function updateFaucetTime(){
  122. sinceLastClaim++;
  123. writeFaucetTime(formattedFaucetTime());
  124. setTimerCol();
  125. }
  126.  
  127. // Format time into more readable string
  128. function formattedFaucetTime(){
  129. var minutes = Math.floor(sinceLastClaim/60).toString();
  130. var seconds = (sinceLastClaim%60).toString();
  131.  
  132. // Adding leading zeroes
  133. if (minutes.length == 1){
  134. minutes = "0" + minutes;
  135. }
  136. if (seconds.length == 1){
  137. seconds = "0" + seconds;
  138. }
  139.  
  140. return (minutes + ":" + seconds);
  141. }
  142.  
  143. // Change timer text
  144. function writeFaucetTime(faucetTime){
  145. $fTimer.text(faucetTime);
  146. }
  147.  
  148. // Change colour according to time
  149. function setTimerCol(){
  150. if (sinceLastClaim >= 180){
  151. $fTimer.css("color","#5fb365");
  152. }
  153. else{
  154. $fTimer.css("color","#6d738c");
  155. }
  156. }
  157. /*
  158. //
  159. */