Guest User

Untitled

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