Vulcun Loot Autoclicker + Streams scan

Autoscans streams for drops and enters the loot in background.

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/16574/103806/Vulcun%20Loot%20Autoclicker%20%2B%20Streams%20scan.js

  1. // ==UserScript==
  2. // @name Vulcun Loot Autoclicker + Streams scan
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.2
  5. // @description Autoscans streams for drops and enters the loot in background.
  6. // @author Mihai Morcov
  7. // @match https://vulcun.com/user/lobby*
  8. // @grant none
  9. // ==/UserScript==
  10. /* jshint -W097 */
  11. /**
  12. * Copyright (c) 2015-2016 Mihai Morcov. All rights reserved. Do not copy and redistribute this without permission. Free for personal use only.
  13. *
  14. * v2 is here!
  15. *
  16. * Hello dear Vulcunians,
  17. * The waiting is finally over. A very smart autolooter is here and ready to grow.
  18. * If this script helps you and you get rich please consider donating me for a coffee.
  19. * Helps with the coding sessions. (Paypal: kapaky@gmail.com)
  20. *
  21. * What you should do:
  22. * Open https://vulcun.com/user/lobby#page-live in a new tab
  23. *
  24. * The script will scan streams and enter the contest 5 seconds after the countdown reach 00:00.
  25. * You only need one tab open.
  26. * Also it displays actual timers, not 'pulse' image as Vulcun does :)
  27. *
  28. * How it works:
  29. * The script does not open tabs anymore (from v2). Entering a contest is done in background.
  30. * 1. Initializes the stream list
  31. * 2. Sets the loot drop countdown for each stream
  32. * 3. Will enter the contest when a stream countdown is ready. (in background)
  33. * 4. Will rescan the contest for it's new loot drop countdown after 60 seconds.
  34. *
  35. * 5. Will also refresh the stream list every 10 minutes
  36. *
  37. * Good luck!
  38. *
  39. * PS: Use the Feedback forum if you have problems.
  40. */
  41.  
  42. 'use strict';
  43.  
  44. var MSG_TWITCH_PLAYER_HIDDEN = "Twitch player is hidden by the Vulcun Loot Autoclicker script, to improve the performance.";
  45.  
  46. var firebase;
  47. var eta=0;
  48. var streams;
  49. var contests = {};
  50. var localTimeDelay = 0;
  51.  
  52. function scan() {
  53. document.title = "Vulcun Loot Autoclicker v2 : Scanning...";
  54. streams = $('#vu-game-listing-ongoing .vu-channel-tab');
  55. var noOfStreams = streams.length;
  56. if(noOfStreams <= 0) {
  57. location.reload();
  58. }
  59.  
  60. adjustLocalTime();
  61.  
  62. console.info(new Date() + " Begin cycling through "+noOfStreams+" streams...");
  63.  
  64. $(CON).append(
  65. '<div class="panel panel-default" style="border: 1px solid; color: #333">'+
  66. '<div class="panel-heading">'+
  67. '<span >Vulcun Loot Autoclicker v2 - No more multiple tabs. This will do all the work.</span>'+
  68. '<span class="badge" style="float:right; background-color: #124585; border: 1px solid; ">Paypal: kapaky@gmail.com</span>'+
  69. '<span class="badge" style="float:right; background-color: white; color: #124585; border: 1px solid;">◔ ◡ ◔</span>'+
  70. '<span class="badge" style="float:right; background-color: white; color: #124585; border: 1px solid;">Getting items ?</span>'+
  71. '</div>'+
  72. '<div class="panel-body">'+
  73. '<ul class="list-group" id="loot-streams"><li style="border-bottom: 0px; margin-bottom: 5px; color: black;" class="list-group-item">Streams list, with timers! how cool is that :) </li></ul>'+
  74. '</div></div>');
  75.  
  76. for (var i = 0; i < noOfStreams; i++) {
  77. setTimeout(function (i) {
  78. //console.log('i='+i);
  79. var stream = streams[i];
  80. var uniqueId = $(stream).attr('data-league');
  81. var channelName = $("div[data-league='" + uniqueId + "'] .indexVideoPanelTitle").text();
  82. firebase = new Firebase("https://lootdrop.firebaseio.com/lootdrop_v2/");
  83. firebase.child('eta/' + uniqueId).once('value', function (snap) {
  84. eta = snap.val();
  85. console.log('uid=' + uniqueId + ', eta=' + eta);
  86. if (eta != null && eta * 1000 > now()) {
  87. // console.log(uniqueId + ", " +eta);
  88. contests[uniqueId + ''] = eta;
  89. var remaining = eta * 1000 - now() + 5000;
  90. setTimeout(enterContest, remaining, uniqueId);
  91. } else {
  92. log('Received eta value for ' + uniqueId + ' was null or negative. Skipping...');
  93. }
  94. });
  95.  
  96. addStreamRow(i + 1, uniqueId, channelName);
  97. }, i * 100, i);
  98. }
  99.  
  100. setInterval(function() {
  101. for (var key in contests) {
  102. //console.log("key="+key);
  103. if (key != undefined) {
  104. var remaining = contests[key] * 1000 - now();
  105. if (remaining >= 0) {
  106. updateStreamRow(key, remaining);
  107. }
  108. }
  109. }
  110. }, 1000);
  111.  
  112. setTimeout(function() {
  113. console.debug('Checking if streams are stuck in Starting...')
  114. var ok=false;
  115. for (var key in contests) {
  116. //console.log("key="+key);
  117. if (key != undefined) {
  118. ok = true;
  119. }
  120. }
  121. if(!ok) {
  122. console.debug("OK=false, refreshing.");
  123. location.reload();
  124. } else {
  125. console.debug("Streams are fine. Continue...");
  126. }
  127. }, 15000);
  128. }
  129.  
  130. function now() {
  131. return new Date().getTime() + localTimeDelay;
  132. }
  133.  
  134. function adjustLocalTime() {
  135. $.ajax({
  136. url: "/api/time",
  137. success: function(time){
  138. localTimeDelay = time*1000 - new Date().getTime();
  139. },
  140. async: false
  141. });
  142.  
  143. if(localTimeDelay == 0) {
  144. console.log("Your clock is synchronized with vulcun server.");
  145. } else if(localTimeDelay < 0) {
  146. console.log("Your clock is ahead of vulcun server with " + parseInt(-localTimeDelay/1000) + " seconds");
  147. } else {
  148. console.log("Your clock is behind of vulcun server with " + parseInt(localTimeDelay/1000) + " seconds");
  149. }
  150. }
  151.  
  152. function addStreamRow(index, uniqueId, channelName) {
  153. $('#loot-streams').append('<li style="border-bottom: 0px; margin-bottom: 10px;" class="list-group-item"><span style="margin-right: 10px; font-size: small;" class="label label-default" id="loot'+uniqueId+'">Starting...</span>' + index + '. ' + channelName+'</li>');
  154. }
  155.  
  156. function updateStreamRow(key, remaining) {
  157. var timer = $('#loot' + key);
  158. var timerColor = '';
  159. if(remaining < 120000) {
  160. timerColor = 'red';
  161. } else if (remaining < 480000) {
  162. timerColor = '#e5b933';
  163. } else {
  164. timerColor = '#92b449';
  165. }
  166.  
  167. timer.css('background-color', timerColor);
  168. timer.html("Loot drop in: " + convertTime(remaining));
  169. }
  170.  
  171. var CONSOLE_ID = "autolooter-console";
  172. var CON = '#' + CONSOLE_ID;
  173.  
  174. function hidePlayer() {
  175. var playerDiv = $('#channel-player-container');
  176. playerDiv.attr('class', '');
  177. playerDiv.attr('style', 'color: red;');
  178. playerDiv.html("<div id='" + CONSOLE_ID + "' </div>");
  179. var con = $(CON);
  180. $(CON).append('<span style="color: red"><b>' + MSG_TWITCH_PLAYER_HIDDEN + '</b></span><br/>');
  181. }
  182.  
  183. function log(message) {
  184. console.log(new Date() + " : " + message);
  185. }
  186.  
  187. function enterContest(id) {
  188.  
  189. $.ajax({
  190. type: "POST",
  191. url: "https://vulcun.com/api/enterlootdrop",
  192. data: {'league_id': id},
  193. success: function (resp) {
  194. }
  195. });
  196.  
  197. log(" ADDED Contest Entry for " + id + ". Check inventory in few minutes to see if you win!");
  198. $('#loot' + id).html("Entry submitted! Rescanning the timer...");
  199.  
  200. setTimeout(function(uniqueId) {
  201. log('Rescan ' + uniqueId);
  202. var channelName = $("div[data-league='" + uniqueId + "'] .indexVideoPanelTitle").text();
  203. firebase = new Firebase("https://lootdrop.firebaseio.com/lootdrop_v2/");
  204. firebase.child('eta/' + uniqueId).once('value', function (snap) {
  205. eta = snap.val();
  206. console.log('uid=' + uniqueId + ', eta=' + eta);
  207. if(eta != null) {
  208. contests[uniqueId + ''] = eta;
  209.  
  210. var remaining = eta * 1000 - now() + 5000;
  211.  
  212. if (remaining >= 0) {
  213. console.log('A new contest entry will be added for ' + uniqueId + ' in eta=' + remaining);
  214. setTimeout(enterContest, remaining, uniqueId);
  215. } else {
  216. console.log(uniqueId + " is offline");
  217. var timer = $('#loot' + uniqueId);
  218. timer.html("The stream is offline.");
  219. }
  220. }
  221. });
  222. }, 60000, id);
  223. }
  224.  
  225. setTimeout(function() {
  226. if(location.href == 'https://vulcun.com/user/lobby') {
  227. location.assign('https://vulcun.com/user/lobby#page-live');
  228. }
  229.  
  230. if(location.href != 'https://vulcun.com/user/lobby#page-live') {
  231. return;
  232. }
  233.  
  234. setTimeout(function() {
  235. location.reload();
  236. }, REFRESH_STREAMS_INTERVAL);
  237.  
  238. hidePlayer();
  239.  
  240. scan();
  241. }, 2000);
  242.  
  243. function convertTime(time) {
  244. var millis= time % 1000;
  245. time = parseInt(time/1000);
  246. var seconds = time % 60;
  247. time = parseInt(time/60);
  248. var minutes = time % 60;
  249. time = parseInt(time/60);
  250. var hours = time % 24;
  251.  
  252. var sec, min, hrs;
  253. if (seconds < 10) sec = "0" + seconds;
  254. else sec = "" + seconds;
  255. if (minutes < 10) min = "0" + minutes;
  256. else min = "" + minutes;
  257. if (hours < 10) hrs = "0" + hours;
  258. else hrs = "" + hours;
  259.  
  260. if (hours == 0) return min + ":" + sec;
  261. else return hrs + ":" + min + ":" + sec;
  262. }