Greasy Fork is available in English.

Vulcun Loot Autoclicker + Streams scan

Autoscans streams for drops and enters the loot in background.

  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 REFRESH_STREAMS_INTERVAL = 10 * 60 * 1000; // refresh the streams list after 10 minutes
  45.  
  46. var MSG_TWITCH_PLAYER_HIDDEN = "Twitch player is hidden by the Vulcun Loot Autoclicker script, to improve the performance.";
  47.  
  48. var firebase;
  49. var eta=0;
  50. var streams;
  51. var contests = {};
  52. var localTimeDelay = 0;
  53.  
  54. function scan() {
  55. document.title = "Vulcun Loot Autoclicker v2 : Scanning...";
  56. streams = $('#vu-game-listing-ongoing .vu-channel-tab');
  57. var noOfStreams = streams.length;
  58. if(noOfStreams <= 0) {
  59. location.reload();
  60. }
  61.  
  62. adjustLocalTime();
  63.  
  64. console.info(new Date() + " Begin cycling through "+noOfStreams+" streams...");
  65.  
  66. $(CON).append(
  67. '<div class="panel panel-default" style="border: 1px solid; color: #333">'+
  68. '<div class="panel-heading">'+
  69. '<span >Vulcun Loot Autoclicker v2 - No more multiple tabs. This will do all the work.</span>'+
  70. '<span class="badge" style="float:right; background-color: #124585; border: 1px solid; ">Paypal: kapaky@gmail.com</span>'+
  71. '<span class="badge" style="float:right; background-color: white; color: #124585; border: 1px solid;">◔ ◡ ◔</span>'+
  72. '<span class="badge" style="float:right; background-color: white; color: #124585; border: 1px solid;">Getting items ?</span>'+
  73. '</div>'+
  74. '<div class="panel-body">'+
  75. '<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>'+
  76. '</div></div>');
  77.  
  78. for (var i = 0; i < noOfStreams; i++) {
  79. setTimeout(function (i) {
  80. //console.log('i='+i);
  81. var stream = streams[i];
  82. var uniqueId = $(stream).attr('data-league');
  83. var channelName = $("div[data-league='" + uniqueId + "'] .indexVideoPanelTitle").text();
  84. firebase = new Firebase("https://lootdrop.firebaseio.com/lootdrop_v2/");
  85. firebase.child('eta/' + uniqueId).once('value', function (snap) {
  86. eta = snap.val();
  87. console.log('uid=' + uniqueId + ', eta=' + eta);
  88. if (eta != null && eta * 1000 > now()) {
  89. // console.log(uniqueId + ", " +eta);
  90. contests[uniqueId + ''] = eta;
  91. var remaining = eta * 1000 - now() + 5000;
  92. setTimeout(enterContest, remaining, uniqueId);
  93. } else {
  94. log('Received eta value for ' + uniqueId + ' was null or negative. Skipping...');
  95. }
  96. });
  97.  
  98. addStreamRow(i + 1, uniqueId, channelName);
  99. }, i * 100, i);
  100. }
  101.  
  102. setInterval(function() {
  103. for (var key in contests) {
  104. //console.log("key="+key);
  105. if (key != undefined) {
  106. var remaining = contests[key] * 1000 - now();
  107. if (remaining >= 0) {
  108. updateStreamRow(key, remaining);
  109. }
  110. }
  111. }
  112. }, 1000);
  113.  
  114. setTimeout(function() {
  115. console.debug('Checking if streams are stuck in Starting...')
  116. var ok=false;
  117. for (var key in contests) {
  118. //console.log("key="+key);
  119. if (key != undefined) {
  120. ok = true;
  121. }
  122. }
  123. if(!ok) {
  124. console.debug("OK=false, refreshing.");
  125. location.reload();
  126. } else {
  127. console.debug("Streams are fine. Continue...");
  128. }
  129. }, 15000);
  130. }
  131.  
  132. function now() {
  133. return new Date().getTime() + localTimeDelay;
  134. }
  135.  
  136. function adjustLocalTime() {
  137. $.ajax({
  138. url: "/api/time",
  139. success: function(time){
  140. localTimeDelay = time*1000 - new Date().getTime();
  141. },
  142. async: false
  143. });
  144.  
  145. if(localTimeDelay == 0) {
  146. console.log("Your clock is synchronized with vulcun server.");
  147. } else if(localTimeDelay < 0) {
  148. console.log("Your clock is ahead of vulcun server with " + parseInt(-localTimeDelay/1000) + " seconds");
  149. } else {
  150. console.log("Your clock is behind of vulcun server with " + parseInt(localTimeDelay/1000) + " seconds");
  151. }
  152. }
  153.  
  154. function addStreamRow(index, uniqueId, channelName) {
  155. $('#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>');
  156. }
  157.  
  158. function updateStreamRow(key, remaining) {
  159. var timer = $('#loot' + key);
  160. var timerColor = '';
  161. if(remaining < 120000) {
  162. timerColor = 'red';
  163. } else if (remaining < 480000) {
  164. timerColor = '#e5b933';
  165. } else {
  166. timerColor = '#92b449';
  167. }
  168.  
  169. timer.css('background-color', timerColor);
  170. timer.html("Loot drop in: " + convertTime(remaining));
  171. }
  172.  
  173. var CONSOLE_ID = "autolooter-console";
  174. var CON = '#' + CONSOLE_ID;
  175.  
  176. function hidePlayer() {
  177. var playerDiv = $('#channel-player-container');
  178. playerDiv.attr('class', '');
  179. playerDiv.attr('style', 'color: red;');
  180. playerDiv.html("<div id='" + CONSOLE_ID + "' </div>");
  181. var con = $(CON);
  182. $(CON).append('<span style="color: red"><b>' + MSG_TWITCH_PLAYER_HIDDEN + '</b></span><br/>');
  183. }
  184.  
  185. function log(message) {
  186. console.log(new Date() + " : " + message);
  187. }
  188.  
  189. function enterContest(id) {
  190.  
  191. $.ajax({
  192. type: "POST",
  193. url: "https://vulcun.com/api/enterlootdrop",
  194. data: {'league_id': id},
  195. success: function (resp) {
  196. }
  197. });
  198.  
  199. log(" ADDED Contest Entry for " + id + ". Check inventory in few minutes to see if you win!");
  200. $('#loot' + id).html("Entry submitted! Rescanning the timer...");
  201.  
  202. setTimeout(function(uniqueId) {
  203. log('Rescan ' + uniqueId);
  204. var channelName = $("div[data-league='" + uniqueId + "'] .indexVideoPanelTitle").text();
  205. firebase = new Firebase("https://lootdrop.firebaseio.com/lootdrop_v2/");
  206. firebase.child('eta/' + uniqueId).once('value', function (snap) {
  207. eta = snap.val();
  208. console.log('uid=' + uniqueId + ', eta=' + eta);
  209. if(eta != null) {
  210. contests[uniqueId + ''] = eta;
  211.  
  212. var remaining = eta * 1000 - now() + 5000;
  213.  
  214. if (remaining >= 0) {
  215. console.log('A new contest entry will be added for ' + uniqueId + ' in eta=' + remaining);
  216. setTimeout(enterContest, remaining, uniqueId);
  217. } else {
  218. console.log(uniqueId + " is offline");
  219. var timer = $('#loot' + uniqueId);
  220. timer.html("The stream is offline.");
  221. }
  222. }
  223. });
  224. }, 60000, id);
  225. }
  226.  
  227. setTimeout(function() {
  228. if(location.href == 'https://vulcun.com/user/lobby') {
  229. location.assign('https://vulcun.com/user/lobby#page-live');
  230. }
  231.  
  232. if(location.href != 'https://vulcun.com/user/lobby#page-live') {
  233. return;
  234. }
  235.  
  236. setTimeout(function() {
  237. location.reload();
  238. }, REFRESH_STREAMS_INTERVAL);
  239.  
  240. hidePlayer();
  241.  
  242. scan();
  243. }, 2000);
  244.  
  245. function convertTime(time) {
  246. var millis= time % 1000;
  247. time = parseInt(time/1000);
  248. var seconds = time % 60;
  249. time = parseInt(time/60);
  250. var minutes = time % 60;
  251. time = parseInt(time/60);
  252. var hours = time % 24;
  253.  
  254. var sec, min, hrs;
  255. if (seconds < 10) sec = "0" + seconds;
  256. else sec = "" + seconds;
  257. if (minutes < 10) min = "0" + minutes;
  258. else min = "" + minutes;
  259. if (hours < 10) hrs = "0" + hours;
  260. else hrs = "" + hours;
  261.  
  262. if (hours == 0) return min + ":" + sec;
  263. else return hrs + ":" + min + ":" + sec;
  264. }