BTSLR COIN/NITRO Timer - bitsler.com

3/20/2020, 12:03:44 AM

当前为 2020-03-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name BTSLR COIN/NITRO Timer - bitsler.com
  3. // @namespace Violentmonkey Scripts
  4. // @match https://www.bitsler.com/*
  5. // @grant none
  6. // @version 1.06
  7. // @author Saaho2019
  8. // @description 3/20/2020, 12:03:44 AM
  9. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  10. // ==/UserScript==
  11. $(document).ready(function() {
  12. $(".bal-wrapper").append(
  13. '<button class="btn btn-success btn-deposit" id="btslrCounter">BTSLR</button>'
  14. );
  15. $(".bal-wrapper").append(
  16. '<button class="btn btn-success btn-deposit" id="nitroCounter">Nitro</button>'
  17. );
  18. $(".bal-container").append(
  19. '<div id="nitroTimer" style="display:none"><span class="minutes" id="nitroMinutes"></span> minutes <span class="seconds"id="nitroSeconds"></span> seconds </div>'
  20. );
  21. $(".bal-container").append(
  22. '<div id="btslrTimer"><span class="minutes" id="btslrMinutes"></span> minutes <span class="seconds"id="btslrSeconds"></span> seconds </div>'
  23. );
  24. $("#btslrTimer,#nitroTimer").css({
  25. "background-color": "#FFFF00",
  26. color: "#FF0000",
  27. "font-family": "Arial",
  28. "font-size": "12pt",
  29. "margin-left": "12px"
  30. });
  31. $("#btslrSeconds,#nitroSeconds").css({
  32. color: "#333",
  33. margin: "0 3px 0 15px",
  34. "font-size": "15px"
  35. });
  36. $("#btslrMinutes,#nitroMinutes").css({
  37. color: "#333",
  38. margin: "0 3px 0 15px",
  39. "font-size": "15px"
  40. });
  41. $(
  42. '<audio id="chatAudio"><source src="https://notificationsounds.com/notification-sounds/slow-spring-board-longer-tail-571/download/mp3" type="audio/wav"></audio>'
  43. ).appendTo(".bal-wrapper");
  44.  
  45. if (isLogin()) {
  46. if (checkVipLevel()) {
  47. if (
  48. window.localStorage.getItem("timebtslr") === null ||
  49. window.localStorage.getItem("timebtslr") === "10:00"
  50. ) {
  51. $("#btslrCounter").show();
  52. $("#btslrTimer").hide();
  53. } else if (
  54. window.localStorage.getItem("timenitro") === null ||
  55. window.localStorage.getItem("timenitro") === "59:59"
  56. ) {
  57. $("#nitroCounter").show();
  58. $("#nitroTimer").hide();
  59. } else {
  60. console.log(window.localStorage.getItem("timebtslr"));
  61. window.localStorage.getItem("timebtslr");
  62. customFun.setTimer(window.localStorage.getItem("timebtslr"), "btslr");
  63. customFun.setTimer(window.localStorage.getItem("timenitro"), "nitro");
  64. $("#btslrCounter").hide();
  65. $("#btslrTimer").show();
  66. $("#nitroTimer").show();
  67. }
  68. }
  69.  
  70. $("#btslrCounter").click(function() {
  71. $("#btslrCounter").hide();
  72. $("#btslrTimer").show();
  73. customFun.setTimer("10:00", "btslr");
  74. });
  75. $("#nitroCounter").click(function() {
  76. $("#nitroCounter").hide();
  77. $("#nitroTimer").show();
  78.  
  79. customFun.setTimer("59:59", "nitro");
  80. });
  81. }
  82. });
  83.  
  84. customFun = {
  85. setTimer: function(time, name) {
  86. var timer2 =
  87. window.localStorage.getItem("time" + name) ||
  88. window.localStorage.setItem("time" + name, time);
  89. timer2 = window.localStorage.getItem("time" + name);
  90. var interval = setInterval(function() {
  91. var timer = timer2.split(":");
  92. //by parsing integer, I avoid all extra string processing
  93. var minutes = parseInt(timer[0], 10);
  94. var seconds = parseInt(timer[1], 10);
  95. --seconds;
  96. minutes = seconds < 0 ? --minutes : minutes;
  97. if (minutes < 0) clearInterval(interval);
  98. seconds = seconds < 0 ? 59 : seconds;
  99. seconds = seconds < 10 ? "0" + seconds : seconds;
  100. if (minutes < 0) {
  101. $("#" + name + "Timer").hide();
  102. $("#" + name + "Counter").show();
  103. resetStartTime(name);
  104. var timerId = setInterval(function() {
  105. console.log(name);
  106. $("#chatAudio")[0].play();
  107. if (name == "nitro") {
  108. // console.log('hahahha');
  109. $(".na-username")
  110. .get(0)
  111. .click();
  112. // $('.na-burger').get(0).click();
  113. // $(".ns-nav button").attr("aria-expanded","true");
  114. } else {
  115. var list = document.getElementsByClassName("bal-amount")[0];
  116. var demo = list.getElementsByClassName("currency-small")[0];
  117. demo.alt == "BTSLR"
  118. ? $(".btn-claim")
  119. .get(0)
  120. .click()
  121. : alert("Time to claim your BTSLR COIN");
  122. }
  123. clearTimeout(timerId);
  124. }, 1000);
  125. } else {
  126. $("#" + name + "Minutes").text(minutes);
  127. $("#" + name + "Seconds").text(seconds);
  128. timer2 = minutes + ":" + seconds;
  129. window.localStorage.setItem("time" + name, timer2);
  130. }
  131. }, 1000);
  132. }
  133. };
  134.  
  135. function checkVipLevel() {
  136. const nonNitro = [
  137. "platinum",
  138. "diamond black",
  139. "diamond",
  140. "diamond_master",
  141. "diamond_legend"
  142. ];
  143. var vipLevel = document
  144. .getElementsByClassName("na-user")[0]
  145. .getElementsByTagName("div")[0].classList[1];
  146. console.log(vipLevel);
  147. return nonNitro.includes(vipLevel);
  148. }
  149. function isLogin() {
  150. var loggedIn = document
  151. .getElementsByClassName("cs-button")[0]
  152. .getElementsByTagName("span")[0].textContent.length;
  153. if (loggedIn > 1) {
  154. console.log("***************Logged in**********************");
  155. return true;
  156. }
  157. }
  158. function resetStartTime(name) {
  159. name == "btslr" ? (k = "10:00") : (k = "59:59");
  160. window.localStorage.setItem("time" + name, k);
  161. }