TAMPERMONKEY BOT: StormGain Miner Trigger every 4 hours & 16 Faucets Auto Collected [Poor Mans Mining Deluxe]


SUBMITTED BY: PimpDaddy

DATE: July 4, 2021, 2:35 p.m.

FORMAT: Text only

SIZE: 79.9 kB

HITS: 971

  1. // ==UserScript==
  2. // @name [satology] Auto Claim Multiple Faucets with Monitor UI
  3. // @description Freebitco.in, StormGain Miner, 15 Faucets + Promo Codes + Autologin.
  4. // @description Automatic activation of StormGain Miner every 4 hours and hourly claim of free ADA, BNB, BTC, DASH, DOGE, ETH, LINK, LTC, NEO, STEAM, TRX, USDC, USDT, XEM, XRP
  5. // @version 1.1.4
  6. // @author satology
  7. // @namespace satology.onrender.com
  8. // @homepage https://satology.onrender.com/faucets/referrals
  9. // @note ----------------------------------------I M P O R T A N T---------------------------------------------------------------------------------------
  10. // @note YOU MUST HAVE A hCaptcha solver INSTALLED to claim from the faucets
  11. // @note I recommend this script: https://greasyfork.org/en/scripts/425854-hcaptcha-solver-automatically-solves-hcaptcha-in-browser
  12. // @note ------------------------------------------------------------------------------------------------------------------------------------------------
  13. // @note ---------------------------------------- LAST UPDATES ------------------------------------------------------------------------------------------
  14. // @note [@1.1.0] Added Freebitco.in and autologin for @cryptosfaucets
  15. // @note > You can enable autologin/credentials in the config object
  16. // @note > You can enable activation of daily RPBonus for FreeBitco.in in the config object
  17. // @note > Added boolean setToEnglish (DEFAULT TRUE) at localeConfig object, to change the language of the faucets to English.
  18. // @note ---------------------------------------- LAST UPDATES ------------------------------------------------------------------------------------------
  19. // @note ------------------------------------------------------------------------------------------------------------------------------------------------
  20. // @note MAIN FEATURES:
  21. // @note > Automatic hourly rolls for 16 faucets: Freebitco.in and @CryptosFaucets (ADA, BNB, BTC, DASH, DOGE, ETH, LINK, LTC, NEO, STEAM, TRX, USDC, USDT, XEM, XRP)
  22. // @note > Automatic activation of StormGain Miner (free BTC every 4 hours)
  23. // @note > Accepts promotion codes (http://twitter.com/cryptosfaucets, free roll shortlinks) for the 15 faucets
  24. // @note > Simple Monitor UI on top of a website to track progress (claims, next rolls, promo codes)
  25. // @note ------------------------------------------------------------------------------------------------------------------------------------------------
  26. // @note IMPORTANT CONSIDERATIONS:
  27. // @note 0. You need to enable popups on the Manager UI website to be able to open the faucets
  28. // @note 2. FAUCETS WEBSITES MUST OPEN IN ENGLISH TO BE ABLE TO RECOGNIZE IF THE PROMO CODE WAS ACCEPTED
  29. // @note In case you don't want to have them in English, you need to change the 3 strings the code uses for validation
  30. // @note (Search for localeStrings in the code and replace them)
  31. // @note 3. Autorolls will trigger ONLY when the faucet was opened by the Manager UI.
  32. // @note This is to allow users to navigate the websites to get the ShortLinks extra rolls, for example,
  33. // @note without having to stop the script.
  34. // @note 5. You can disable faucets from the script in case you need to or you are not registered yet.
  35. // @note It would be great if you could use my referral links listed below if you need an account.
  36. // @note To disable them, just set enabled: false in the webList array, save the script & refresh the manager
  37. // @note 6. All data stored for tracking and to be displayed is stored locally in your environment. Nothing is uploaded.
  38. // @note Always open to feedback. I'd be glad to hear from you if you find any bugs, have suggestions or new enhancements/features you'd like to see
  39. // @note ------------------------------------------------------------------------------------------------------------------------------------------------
  40. // @note ----------------------------------------I M P O R T A N T---------------------------------------------------------------------------------------
  41. // @note [@1.0.11] Modified timeouts and removed auto refresh. YOU MUST HAVE A hCaptcha solver INSTALLED to claim from the faucets now as they've added it and it's working.
  42. // @note I recommend this script: https://greasyfork.org/en/scripts/425854-hcaptcha-solver-automatically-solves-hcaptcha-in-browser
  43. // @note ------------------------------------------------------------------------------------------------------------------------------------------------
  44. // @note ------------------------------------------------------------------------------------------------------------------------------------------------
  45. // @note Requested for upcoming updates:
  46. // @note - Enable/Disable faucet from the Manager UI, add extra column with conversion
  47. // @note - Implement FaucetPay PTC autoclicker (https://faucetpay.io/?r=1140585)
  48. // @note - Add bagi.co.in
  49. // @note ------------------------------------------------------------------------------------------------------------------------------------------------
  50. // @note Links to create new accounts using my referral:
  51. // @note https://faucetpay.io/?r=1140585
  52. // @note https://freebitco.in/?r=46334826
  53. // @note https://app.stormgain.com/friend/BNS17722452
  54. // @note https://freecardano.com/?ref=346495
  55. // @note https://freebinancecoin.com/?ref=176633
  56. // @note https://freebitcoin.io/?ref=506599
  57. // @note https://freedash.io/?ref=132684
  58. // @note https://free-doge.com/?ref=199022
  59. // @note https://freeethereum.com/?ref=218020
  60. // @note https://freechainlink.io/?ref=84537
  61. // @note https://free-ltc.com/?ref=127524
  62. // @note https://freeneo.io/?ref=107888
  63. // @note https://freesteam.io/?ref=122086
  64. // @note https://free-tron.com/?ref=237317
  65. // @note https://freeusdcoin.com/?ref=139322
  66. // @note https://freetether.com/?ref=190533
  67. // @note https://freenem.com/?ref=295274
  68. // @note https://coinfaucet.io/?ref=808298
  69. // @note ------------------------------------------------------------------------------------------------------------------------------------------------
  70. // @note If you wanna team up or just share some ideas, you can contact me at satology@protonmail.com
  71. // @note ------------------------------------------------------------------------------------------------------------------------------------------------
  72. // @grant GM_setValue
  73. // @grant GM_getValue
  74. // @grant window.close
  75. // @grant GM_openInTab
  76. // @icon https://www.google.com/s2/favicons?domain=stormgain.com
  77. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js
  78. // @match https://satology.onrender.com/faucets/referrals*
  79. // @match https://app.stormgain.com/crypto-miner/
  80. // @match https://freecardano.com/*
  81. // @match https://freebinancecoin.com/*
  82. // @match https://freebitcoin.io/*
  83. // @match https://freedash.io/*
  84. // @match https://free-doge.com/*
  85. // @match https://freeethereum.com/*
  86. // @match https://freechainlink.io/*
  87. // @match https://free-ltc.com/*
  88. // @match https://freeneo.io/*
  89. // @match https://freesteam.io/*
  90. // @match https://free-tron.com/*
  91. // @match https://freeusdcoin.com/*
  92. // @match https://freetether.com/*
  93. // @match https://freenem.com/*
  94. // @match https://coinfaucet.io/*
  95. // @match https://freebitco.in/
  96. // ==/UserScript==
  97. (function() {
  98. 'use strict';
  99. /**
  100. * Specific string values to check if a promotion code was succesfully processed (used via indexOf).
  101. * Defaults are set for English.
  102. * If you want to view the faucets in another language, you will need to change the following values
  103. */
  104. const localeConfig = {
  105. setToEnglish: true, // will set the faucets to English
  106. stringSearches: {
  107. promoCodeAccepted: 'roll',
  108. promoCodeUsed: 'already used',
  109. promoCodeInvalid: 'not found',
  110. promoCodeInvalid2: 'only alphanumeric',
  111. promoCodeInvalid3: 'ended'
  112. }
  113. };
  114. const WebType = {
  115. CRYPTOSFAUCETS: 1,
  116. STORMGAIN: 2,
  117. FREEBITCOIN: 3
  118. };
  119. const CFUrlType = {
  120. HOME: 0,
  121. FREE: 1,
  122. CONTACTTWITTER: 2,
  123. PROMOTION: 3,
  124. STATS: 4,
  125. SETTINGS: 5,
  126. FREEROLLS: 6,
  127. IGNORE: 99
  128. };
  129. const PromoStatus = {
  130. NOCODE: 0,
  131. PENDING: 1,
  132. ACCEPTED: 2,
  133. USEDBEFORE: 3,
  134. INVALID: 4,
  135. UNKNOWNERROR: 5
  136. };
  137. const RandomInteractionLevel = {
  138. NONE: 0,
  139. LOW: 1,
  140. MEDIUM: 2,
  141. HIGH: 3
  142. };
  143. let config = {
  144. timeout: 4, // Use -1 to disable the timeout functionality. In minutes. Max time the monitor will wait for a result/roll.
  145. // After timeout is reached, the Manager/Monitor will assume something is wrong
  146. // (usually faucet tab being accidentally closed or failed to connect)
  147. // Will trigger a refresh on the Monitor website and carry on the process
  148. postponeMinutes: 65, // Minutes to wait before retrying a faucet that timed out
  149. cf: {
  150. autologin: false,
  151. credentials: {
  152. mode: 1, // POSSIBLE VALUES:
  153. // 1: Use email/password saved through the script
  154. // 2: Waits for the credentials to be added manually or by a third party software/extension.
  155. // Useful if you use different email/password combinations on each faucet
  156. email: 'YOUR@EMAIL.com',
  157. password: 'YOURPASSWORD'
  158. }
  159. },
  160. fb: {
  161. activateRPBonus: false // will try to activate the highest RP Roll Bonus available for the account (100, 50 25, ... points per roll),
  162. }
  163. }
  164. let persistence, shared, manager, ui, CFPromotions, interactions, SGProcessor, CFProcessor, CFHistory, FBProcessor;
  165. let helpers = {
  166. cleanString: function(input) {
  167. var output = "";
  168. for (var i=0; i<input.length; i++) {
  169. if (input.charCodeAt(i) <= 127) {
  170. output += input.charAt(i);
  171. }
  172. }
  173. return output;
  174. },
  175. shuffle: function (array) {
  176. let currentIndex = array.length, temporaryValue, randomIndex;
  177. while (0 !== currentIndex) {
  178. randomIndex = Math.floor(Math.random() * currentIndex);
  179. currentIndex -= 1;
  180. temporaryValue = array[currentIndex];
  181. array[currentIndex] = array[randomIndex];
  182. array[randomIndex] = temporaryValue;
  183. }
  184. return array;
  185. },
  186. getPrintableTime: function (date = new Date()) {
  187. return ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2) + ':' + ('0' + date.getSeconds()).slice(-2)
  188. },
  189. getPrintableDateTime: function (date) {
  190. if (date != null) {
  191. return ('0' + date.getDate()).slice(-2) + '/' + ('0' + (date.getMonth() + 1)).slice(-2) + ' ' + ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2);
  192. } else {
  193. return '';
  194. }
  195. },
  196. getEnumText: function (enm, value) {
  197. return Object.keys(enm).find(key => enm[key] === value);
  198. },
  199. randomMs: function (a, b){
  200. return a + (b - a) * Math.random();
  201. },
  202. addMinutes: function(date, mins) {
  203. return date.setMinutes(date.getMinutes() + parseInt(mins) + 1);
  204. },
  205. randomInt: function(min, max) {
  206. return Math.floor(Math.random() * (max - min + 1) + min);
  207. },
  208. addMilliseconds: function(date, ms) {
  209. return date.setMilliseconds(date.getMilliseconds() + ms);
  210. },
  211. getRandomMillisecondsFromMinutesRange(minute, rangeDiffInPercentage) {
  212. const msCenter = minute * 60 * 1000;
  213. const msRangeDiff = Math.round(msCenter * rangeDiffInPercentage / 100);
  214. return helpers.randomMs(msCenter - msRangeDiff, msCenter + msRangeDiff);
  215. },
  216. getEmojiForPromoStatus: function(promoStatus) {
  217. switch (promoStatus) {
  218. case PromoStatus.NOCODE:
  219. return '⚪';
  220. break;
  221. case PromoStatus.PENDING:
  222. return '⏳';
  223. break;
  224. case PromoStatus.ACCEPTED:
  225. return '✔️';
  226. break;
  227. case PromoStatus.USEDBEFORE:
  228. return '🕙';
  229. break;
  230. case PromoStatus.INVALID:
  231. return '❌';
  232. break;
  233. case PromoStatus.UNKNOWNERROR:
  234. return '❗';
  235. break;
  236. }
  237. },
  238. getHost: function(url, withHttps = false) {
  239. if (url.includes('//')) {
  240. url = url.split('//')[1];
  241. }
  242. url = url.split('/')[0];
  243. return withHttps ? ('https://' + url) : url;
  244. },
  245. cf: {
  246. getUrlType: function(url) {
  247. if (url.endsWith('/free')) {
  248. return CFUrlType.FREE;
  249. }
  250. if (url.includes('/promotion/')) {
  251. return CFUrlType.PROMOTION;
  252. }
  253. if (url.endsWith('/contact-twitter')) {
  254. return CFUrlType.CONTACTTWITTER;
  255. }
  256. if (url.endsWith('/free-rolls')) {
  257. return CFUrlType.FREEROLLS;
  258. }
  259. if (url.endsWith('/settings')) {
  260. return CFUrlType.SETTINGS;
  261. }
  262. if (url.endsWith('/stats')) {
  263. return CFUrlType.STATS;
  264. }
  265. if (url.endsWith('/')) {
  266. url = url.slice(0, -1);
  267. if (url == helpers.getHost(url, true)) {
  268. return CFUrlType.HOME;
  269. }
  270. }
  271. return CFUrlType.IGNORE;
  272. }
  273. }
  274. }
  275. let objectGenerator = {
  276. createPersistence: function() {
  277. const prefix = 'autoWeb_';
  278. function save(key, value, parseIt = false) {
  279. GM_setValue(prefix + key, parseIt ? JSON.stringify(value) : value);
  280. };
  281. function load(key, parseIt = false) {
  282. let value = GM_getValue(prefix + key);
  283. if(value && parseIt) {
  284. value = JSON.parse(value);
  285. }
  286. return value;
  287. };
  288. return {
  289. save: save,
  290. load: load
  291. };
  292. },
  293. createShared: function() {
  294. let flowControl;
  295. function isOpenedByManager(currentHost) {
  296. loadFlowControl();
  297. if(!flowControl) {
  298. return false;
  299. }
  300. let millisecondsDistance = new Date() - flowControl.requestedTime;
  301. // if(flowControl.opened || flowControl.host != currentHost || millisecondsDistance > 120000) {
  302. if(flowControl.opened || (flowControl.host != currentHost && !flowControl.expectedHosts.includes(currentHost)) || millisecondsDistance > 120000) {
  303. return false;
  304. }
  305. return true;
  306. };
  307. function setFlowControl(id, url, webType, expectedHosts) {
  308. flowControl = {
  309. id: id,
  310. url: url,
  311. host: helpers.getHost(url),
  312. type: webType,
  313. requestedTime: new Date(),
  314. opened: false,
  315. expectedHosts: expectedHosts,
  316. error: false,
  317. result: {}
  318. };
  319. persistence.save('flowControl', flowControl, true);
  320. };
  321. function wasVisited(expectedId) {
  322. loadFlowControl();
  323. return flowControl.id == expectedId && flowControl.opened;
  324. };
  325. function hasErrors(expectedId) {
  326. return flowControl.id == expectedId && flowControl.error;
  327. };
  328. function getResult() {
  329. return flowControl.result;
  330. };
  331. function getCurrent() {
  332. let current = {};
  333. current.url = flowControl.url;
  334. current.host = flowControl.host;
  335. current.type = flowControl.type;
  336. return current;
  337. };
  338. function saveAndclose(runDetails, delay = 0) {
  339. markAsVisited(runDetails);
  340. if(delay) {
  341. setTimeout(window.close, delay);
  342. } else {
  343. window.close();
  344. }
  345. };
  346. function loadFlowControl() {
  347. flowControl = persistence.load('flowControl', true);
  348. };
  349. function markAsVisited(runDetails) {
  350. flowControl.opened = true;
  351. flowControl.result = runDetails;
  352. persistence.save('flowControl', flowControl, true);
  353. };
  354. function closeWithError(errorType, errorMessage) {
  355. flowControl.error = true;
  356. flowControl.result = {
  357. errorType: errorType,
  358. errorMessage: errorMessage
  359. };
  360. persistence.save('flowControl', flowControl, true);
  361. window.close();
  362. };
  363. return {
  364. setFlowControl: setFlowControl,
  365. wasVisited: wasVisited,
  366. isOpenedByManager: isOpenedByManager,
  367. getCurrent: getCurrent,
  368. getResult: getResult,
  369. closeWindow: saveAndclose,
  370. closeWithError: closeWithError,
  371. hasErrors: hasErrors
  372. };
  373. },
  374. createManager: function() {
  375. let timestamp = null;
  376. let timeWaiting = 0;
  377. let promoInterval;
  378. let webList = [
  379. { id: '1', name: 'ADA', url: 'https://freecardano.com/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  380. { id: '2', name: 'BNB', url: 'https://freebinancecoin.com/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  381. { id: '3', name: 'BTC', url: 'https://freebitcoin.io/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  382. { id: '4', name: 'DASH', url: 'https://freedash.io/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  383. { id: '5', name: 'ETH', url: 'https://freeethereum.com/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  384. { id: '6', name: 'LINK', url: 'https://freechainlink.io/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  385. { id: '7', name: 'LTC', url: 'https://free-ltc.com/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  386. { id: '8', name: 'NEO', url: 'https://freeneo.io/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  387. { id: '9', name: 'STEAM', url: 'https://freesteam.io/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  388. { id: '10', name: 'TRX', url: 'https://free-tron.com/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  389. { id: '11', name: 'USDC', url: 'https://freeusdcoin.com/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  390. { id: '12', name: 'USDT', url: 'https://freetether.com/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  391. { id: '13', name: 'XEM', url: 'https://freenem.com/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  392. { id: '14', name: 'XRP', url: 'https://coinfaucet.io/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  393. { id: '15', name: 'StormGain', url: 'https://app.stormgain.com/crypto-miner/', type: WebType.STORMGAIN, enabled: true },
  394. { id: '16', name: 'DOGE', url: 'https://free-doge.com/free', type: WebType.CRYPTOSFAUCETS, enabled: true },
  395. { id: '17', name: 'FreeBitco.in', url: 'https://freebitco.in/', type: WebType.FREEBITCOIN, enabled: true }
  396. ];
  397. function start(){
  398. loader.initialize();
  399. ui.init(getCFlist());
  400. update();
  401. promoInterval = setInterval(manager.readNewPromoCode, 5000);
  402. setTimeout(manager.process, 10000);
  403. };
  404. let loader = function() {
  405. function initialize() {
  406. setTimestamp();
  407. initializeWebList();
  408. initializePromotions();
  409. initializeHistory();
  410. };
  411. function initializeWebList() {
  412. let storedData = persistence.load('webList', true);
  413. if(storedData) {
  414. let newOnes = addNewOnes(storedData);
  415. if (newOnes) {
  416. newOnes.forEach( function (element, idx, arr) {
  417. storedData.push(element);
  418. });
  419. }
  420. let disabledList = webList.filter( x => !x.enabled ).map( x => x.id );
  421. storedData.forEach( function (element, idx, arr) {
  422. arr[idx].nextRoll = element.nextRoll ? new Date(element.nextRoll) : new Date();
  423. arr[idx].enabled = !disabledList.includes(element.id);
  424. });
  425. webList = storedData;
  426. setup();
  427. } else {
  428. setup(true);
  429. }
  430. };
  431. function addNewOnes(storedData) {
  432. let allIds = webList.map( x => x.id );
  433. let storedIds = storedData.map( x => x.id );
  434. let newOnes = allIds.filter( x => !storedIds.includes(x) );
  435. return webList.filter( x => newOnes.includes(x.id) );
  436. };
  437. function initializePromotions() {
  438. let storedData = persistence.load('CFPromotions', true);
  439. if (storedData) {
  440. storedData.forEach( function (element, idx, arr) {
  441. arr[idx].added = new Date(element.added);
  442. arr[idx].statusPerFaucet.forEach( function (el, i, a) {
  443. a[i].execTimeStamp = (el.execTimeStamp != null) ? new Date(el.execTimeStamp) : null;
  444. });
  445. });
  446. CFPromotions.load(storedData);
  447. }
  448. };
  449. function initializeHistory() {
  450. CFHistory.initOrLoad();
  451. };
  452. function setTimestamp() {
  453. timestamp = new Date().getTime();
  454. persistence.save('timestamp', timestamp);
  455. };
  456. function removeDisabledFaucets() {
  457. webList = webList.filter(x => x.enabled);
  458. };
  459. function setup(reset = false) {
  460. removeDisabledFaucets();
  461. if(reset) {
  462. helpers.shuffle(webList);
  463. }
  464. let timeDistance = 0;
  465. webList.forEach( function (element, idx, arr) {
  466. if (reset || !element.lastClaim) {
  467. arr[idx].lastClaim = 0;
  468. }
  469. if (reset || !element.aggregate) {
  470. arr[idx].aggregate = 0;
  471. }
  472. if (reset || !element.balance) {
  473. arr[idx].balance = 0;
  474. }
  475. if (reset || !element.stats) {
  476. arr[idx].stats = {};
  477. }
  478. if (reset || !element.nextRoll) {
  479. timeDistance += helpers.randomMs(10000, 15000);
  480. arr[idx].nextRoll = new Date(helpers.addMilliseconds(new Date(), timeDistance));
  481. }
  482. });
  483. };
  484. return {
  485. initialize: initialize
  486. };
  487. }();
  488. function update(sortIt = true) {
  489. if(sortIt) {
  490. webList.sort((a,b) => a.nextRoll.getTime() - b.nextRoll.getTime());
  491. }
  492. persistence.save('webList', webList, true);
  493. ui.refresh(webList, CFPromotions.getAll());
  494. updateRollStatsSpan();
  495. };
  496. function process() {
  497. if(isObsolete()) {
  498. return;
  499. }
  500. if(webList[0].nextRoll.getTime() < (new Date()).getTime()) {
  501. ui.log(`Opening ${webList[0].name}`);
  502. open();
  503. } else {
  504. let timeUntilNext = webList[0].nextRoll.getTime() - (new Date()).getTime() + helpers.randomMs(1000, 2000);
  505. ui.log(`Waiting ${(timeUntilNext/1000/60).toFixed(2)} minutes...`);
  506. setTimeout(manager.process, timeUntilNext);
  507. }
  508. };
  509. function isObsolete() {
  510. let savedTimestamp = persistence.load('timestamp');
  511. if (savedTimestamp && savedTimestamp > timestamp) {
  512. ui.log('<b>STOPING EXECUTION!<b> A new Manager UI window was opened. Process should continue there');
  513. clearInterval(promoInterval);
  514. return true;
  515. }
  516. return false;
  517. };
  518. function open(promoCode) {
  519. let navUrl = webList[0].url;
  520. if(promoCode) {
  521. navUrl = getPromoUrl(promoCode);
  522. ui.log(`Opening ${webList[0].name} with Promo Code [${promoCode}]`);
  523. }
  524. let expectedHosts = [];
  525. expectedHosts.push((new URL(navUrl)).host);
  526. if(webList[0].type == webList[0].type == WebType.STORMGAIN) {
  527. expectedHosts.push((new URL('https://www.google.com').host));
  528. expectedHosts.push((new URL('https://www.recaptcha.net').host));
  529. }
  530. shared.setFlowControl(webList[0].id, navUrl, webList[0].type, expectedHosts);
  531. setTimeout(manager.resultReader, 15000);
  532. // GM_openInTab(navUrl, 'loadInBackground');
  533. GM_openInTab(navUrl, { active: false});
  534. };
  535. function getPromoUrl(promoCode) {
  536. let url = webList[0].url;
  537. url = url.slice(0, url.length - 4);
  538. return url + "promotion/" + promoCode;
  539. }
  540. function resultReader() {
  541. if(isObsolete()) {
  542. return;
  543. }
  544. if(shared.wasVisited(webList[0].id)) {
  545. timeWaiting = 0;
  546. let result = shared.getResult();
  547. if (result) {
  548. updateWebListItem(result);
  549. if ( (webList[0].type == WebType.CRYPTOSFAUCETS) &&
  550. ( (result.claimed) || (result.promoStatus && result.promoStatus != PromoStatus.ACCEPTED) )) {
  551. let promoCode = CFPromotions.hasPromoAvailable(webList[0].id);
  552. if (promoCode) {
  553. update(false);
  554. open(promoCode);
  555. return;
  556. }
  557. }
  558. } else {
  559. ui.log(`Unable to read last run result, for ID: ${webList[0].id} > ${webList[0].name}`);
  560. }
  561. update(true);
  562. process();
  563. return;
  564. } else {
  565. timeWaiting += 15;
  566. if (!shared.hasErrors(webList[0].id) && !hasTimedOut()) {
  567. ui.log(`Waiting for ${webList[0].name} results...`, timeWaiting);
  568. setTimeout(manager.resultReader, 15000);
  569. return;
  570. // Handle Error
  571. let errorDetails = shared.getResult();
  572. ui.log(`${webList[0].name} closed with error: ${errorDetails.errorType} ${errorDetails.errorMessage}`);
  573. let millisecondsDelay = helpers.getRandomMillisecondsFromMinutesRange(config.postponeMinutes, 5);
  574. webList[0].nextRoll = new Date(helpers.addMilliseconds(new Date(), millisecondsDelay));
  575. update(true);
  576. window.location.reload();
  577. return;
  578. }
  579. if (shared.hasErrors(webList[0].id)) {
  580. webList[0].stats.errors = shared.getResult();
  581. ui.log(`${webList[0].name} closed with error: ${webList[0].stats.errors.errorType} ${webList[0].stats.errors.errorMessage}`);
  582. }
  583. if (hasTimedOut()) {
  584. if(webList[0].stats.countTimeouts) {
  585. webList[0].stats.countTimeouts += 1;
  586. } else {
  587. webList[0].stats.countTimeouts = 1;
  588. }
  589. ui.log(`Waited too much time for ${webList[0].name} results: triggering timeout`);
  590. }
  591. let millisecondsDelay = helpers.getRandomMillisecondsFromMinutesRange(config.postponeMinutes, 5);
  592. webList[0].nextRoll = new Date(helpers.addMilliseconds(new Date(), millisecondsDelay));
  593. update(true);
  594. window.location.reload();
  595. return;
  596. }
  597. };
  598. function hasTimedOut() {
  599. return config.timeout != -1 && (timeWaiting > (config.timeout * 60));
  600. };
  601. function updateWebListItem(result) {
  602. ui.log(`Updating data: ${JSON.stringify(result)}`);
  603. webList[0].stats.countTimeouts = 0;
  604. webList[0].stats.errors = null;
  605. if (result.claimed) {
  606. result.claimed = parseFloat(result.claimed);
  607. if(!isNaN(result.claimed)) {
  608. webList[0].lastClaim = result.claimed;
  609. webList[0].aggregate += result.claimed;
  610. }
  611. }
  612. if(result.balance) {
  613. webList[0].balance = result.balance;
  614. }
  615. if(result.nextRoll) {
  616. webList[0].nextRoll = new Date(result.nextRoll);
  617. }
  618. if(result.promoStatus) {
  619. CFPromotions.updateFaucetForCode(result.promoCode, webList[0].id, result.promoStatus);
  620. }
  621. if(result.rolledNumber) {
  622. CFHistory.addRoll(result.rolledNumber);
  623. }
  624. };
  625. function readNewPromoCode() {
  626. let promoCodeElement = $('#promo-code-new')[0];
  627. let promoCode = helpers.cleanString(promoCodeElement.innerText);
  628. let promoDisplayStatus = $('#promo-display-status')[0];
  629. if (promoCode == 'REMOVEALLPROMOS' ) {
  630. CFPromotions.removeAll();
  631. promoCodeElement.innerText = '';
  632. promoDisplayStatus.innerHTML = 'Promo codes removed!';
  633. ui.refresh(null, CFPromotions.getAll());
  634. } else if(promoCode != '') {
  635. CFPromotions.addNew(promoCode);
  636. promoCodeElement.innerText = '';
  637. $('#promo-text-input').val('');
  638. promoDisplayStatus.innerHTML = 'Code ' + promoCode + ' added!';
  639. ui.log(`Promo code ${promoCode} added`);
  640. ui.refresh(null, CFPromotions.getAll());
  641. }
  642. };
  643. function updateRollStatsSpan() {
  644. let rollsSpanElement = $('#rolls-span')[0];
  645. rollsSpanElement.innerText = CFHistory.getRollsMeta().join(',');
  646. };
  647. function getCFlist() {
  648. let items;
  649. items = webList.filter(f => f.type === WebType.CRYPTOSFAUCETS);
  650. items = items.map(x => {
  651. return {
  652. id: x.id,
  653. name: x.name
  654. };});
  655. items.sort((a, b) => (a.name > b.name) ? 1 : -1);
  656. return items;
  657. };
  658. return{
  659. init:start,
  660. process: process,
  661. resultReader: resultReader,
  662. getFaucetsForPromotion: getCFlist,
  663. readNewPromoCode: readNewPromoCode
  664. };
  665. },
  666. createUi: function() {
  667. let logLines = ['', '', '', '', ''];
  668. function init(cfFaucets) {
  669. appendCSS();
  670. appendJavaScript();
  671. appendHtml();
  672. createPromoTable(cfFaucets);
  673. };
  674. function appendCSS() {
  675. let css = '';
  676. $('head').append(css);
  677. };
  678. function appendJavaScript() {
  679. let js = '';
  680. js += '<script language="text/javascript">';
  681. js += 'var myBarChart;';
  682. js += 'function savePromoCode() {';
  683. js += 'var promoText = document.getElementById("promo-text-input");';
  684. js += 'var promoCode = document.getElementById("promo-code-new");';
  685. js += 'var promoDisplayStatus = document.getElementById("promo-display-status");';
  686. js += 'promoCode.innerHTML = promoText.value.trim();';
  687. js += 'promoDisplayStatus.innerHTML = "Adding code&nbsp&quot;<b>" + promoCode.innerHTML + "</b>&quot;... This could take around a minute. Please wait..."';
  688. js += '}';
  689. js += 'function removeAllPromos() {';
  690. js += 'var promoCode = document.getElementById("promo-code-new");';
  691. js += 'var promoDisplayStatus = document.getElementById("promo-display-status");';
  692. js += 'promoCode.innerHTML = "REMOVEALLPROMOS";';
  693. js += 'promoDisplayStatus.innerHTML = "Removing all promotion codes... This could take around a minute. Please wait..."';
  694. js += '}';
  695. js += 'function openStatsChart() {';
  696. js += 'if(myBarChart) { myBarChart.destroy(); }';
  697. js += 'let statsFragment = document.getElementById("stats-fragment");';
  698. js += 'if (statsFragment.style.display === "block") { statsFragment.style.display = "none"; document.getElementById("stats-button").innerText = "Lucky Number Stats"; } else {';
  699. js += 'statsFragment.style.display = "block"; document.getElementById("stats-button").innerText = "Close Stats";';
  700. js += 'var canvas = document.getElementById("barChart");';
  701. js += 'var ctx = canvas.getContext("2d");';
  702. js += 'var dataSpan = document.getElementById("rolls-span");';
  703. js += 'var data = {';
  704. js += 'labels: ["0000-9885", "9886-9985", "9986-9993", "9994-9997", "9998-9999", "10000"],';
  705. js += 'datasets: [ { fill: false, backgroundColor: [ "#990000", "#660066", "#000099", "#ff8000", "#ffff00", "#00ff00"],';
  706. js += 'data: dataSpan.innerText.split(",") } ] };';
  707. js += 'var options = { plugins: { legend: { display: false } }, title: { display: true, text: "Rolled Numbers", position: "top" }, rotation: -0.3 * Math.PI };';
  708. js += 'myBarChart = new Chart(ctx, { type: "pie", data: data, options: options }); } }';
  709. js += '</script>';
  710. $('head').append(js);
  711. };
  712. function appendHtml() {
  713. let html ='';
  714. html += '<pre style="width:100%;" id="console-log"><b>Loading...</b></pre>';
  715. html += '<section id="stats-fragment" class="fragment" style="display:none;"><div class="container-fluid bg-dark "><div class="container py-1 "><div class="row align-items-center text-center justify-content-center">';
  716. html += '<div class="col-md-3"><canvas id="barChart"></canvas><span id="rolls-span" style="display:none;"></span></div></div></div></div></div></section>';
  717. html += '<section id="table-struct" class="fragment "><div class="container-fluid bg-dark "><div class="container py-1 "><div class="row mx-0"><div class="title col-3 px-0 text-white"><h2>Schedule</h2></div>';
  718. html += '<div class="title col-6 w-100 text-white"></div><div class="title col-3 text-right"><a class="btn m-2 anchor btn-outline-primary" id="stats-button" onclick="openStatsChart()">Lucky Number Stats</a></div></div>';
  719. html += '<div class="row align-items-center text-center justify-content-end">';
  720. html += '<div class="col-12 order-lg-1 text-center"><div class="row justify-content-center"><div class="col table-responsive" id="schedule-container"></div></div></div></div></div></div></section>';
  721. html +='<section id="table-struct-promo" class="fragment "><div class="container-fluid bg-dark "><div class="container py-1 "><div class="row mx-0">';
  722. html +='<div class="title col-3 px-0 text-white"><h2>Promo Codes</h2></div><div class="title col-3 w-100 text-white">';
  723. html +='<div class="input-group my-0"><input type="text" class="form-control py-1" id="promo-text-input" placeholder="Type a Promo code...">';
  724. html +='<div class="input-group-append"><button class="btn btn-success" id="promo-button" onclick="savePromoCode()"><i class="fa fa-plus"></i></button>';
  725. html +='</div></div></div><div class="title col-4 text-white justify-content-end"><span id="promo-display-status" class="text-white"></span>';
  726. html +='<span id="promo-code-new" style="display:none;"></span></div><div class="title col-2 text-right"><a class="btn m-2 anchor btn-outline-danger" id="promo-button" onclick="removeAllPromos()">Remove All</a>';
  727. html +='</div></div><div class="row align-items-center text-center justify-content-end"><div class="col-12 order-lg-1 text-center">';
  728. html +='<div class="row justify-content-center"><div class="col table-responsive" id="promo-container"></div></div></div></div></div></div></section>';
  729. $('#referral-table').before(html);
  730. $('#schedule-container').append( createScheduleTable() );
  731. };
  732. function createPromoTable(faucets) {
  733. let tableStructure = '';
  734. tableStructure += '<table class="table table-bordered text-white" id="promo-table">';
  735. tableStructure += '<caption style="text-align: -webkit-center;">⏳ Pending ✔️ Accepted 🕙 Used Before ❌ Invalid code ❗ Unknown error ⚪ No code</caption>';
  736. tableStructure += '<thead><tr><th class="">Code</th><th class="">Added</th>';
  737. for (let i = 0, all = faucets.length; i < all; i++) {
  738. tableStructure += '<th data-faucet-id="' + faucets[i].id + '">' + faucets[i].name + '</th>';
  739. }
  740. tableStructure += '</tr></thead><tbody id="promo-table-body"></tbody></table>';
  741. $('#promo-container').append( tableStructure );
  742. };
  743. function createScheduleTable() {
  744. let tableStructure = '';
  745. tableStructure += '<table class="table table-bordered text-white" id="schedule-table"><thead><tr>';
  746. tableStructure += '<th class="hide-on-mobile">#</th><th class="">Name</th><th class="">Last Claim</th>';
  747. tableStructure += '<th class="hide-on-mobile">Aggregate</th><th class="hide-on-mobile">Balance</th><th class="">Next Roll</th>';
  748. tableStructure += '</tr></thead><tbody id="schedule-table-body"></tbody></table>';
  749. return tableStructure;
  750. };
  751. function loadScheduleTable(data) {
  752. let tableBody = '';
  753. for(let i=0, all = data.length; i < all; i++) {
  754. tableBody += '<tr class="align-middle" data-id="' + data[i].id + '">';
  755. tableBody +='<td class="align-middle hide-on-mobile">' + (i + 1).toString() + '</td>';
  756. tableBody +='<td class="align-middle">' + data[i].name + '</td>';
  757. tableBody +='<td class="align-middle">' + data[i].lastClaim.toFixed(8) + '</td>';
  758. tableBody +='<td class="align-middle hide-on-mobile">' + data[i].aggregate.toFixed(8) + '</td>';
  759. tableBody +='<td class="align-middle hide-on-mobile">' + (data[i].balance ? data[i].balance.split(' ')[0] : "") + '</td>';
  760. tableBody +='<td class="align-middle">' + helpers.getPrintableTime(data[i].nextRoll) + addBadges(data[i].stats) + '</td>';
  761. tableBody +='</tr>';
  762. }
  763. $('#schedule-table-body').html(tableBody);
  764. };
  765. function addBadges(stats) {
  766. let consecutiveTimeout = stats.countTimeouts;
  767. let otherErrors = stats.errors;
  768. let html = ' ';
  769. if (consecutiveTimeout) {
  770. html += `<span class="badge badge-pill badge-warning" title="${consecutiveTimeout} consecutive timeouts">${consecutiveTimeout}</span>`;
  771. }
  772. if (otherErrors) {
  773. html += `<span class="badge badge-pill badge-warning" title="${otherErrors.errorMessage}">${otherErrors.errorType}</span>`;
  774. }
  775. return html;
  776. }
  777. function loadPromotionTable(codes) {
  778. let tableBody = '';
  779. for(let c=0; c < codes.length; c++) {
  780. let data = codes[c];
  781. tableBody += '<tr data-promotiobn-id="' + data.id + '">';
  782. tableBody += '<td class="align-middle">' + data.code + '</td>';
  783. tableBody +='<td class="align-middle">' + helpers.getPrintableDateTime(data.added) + '</td>';
  784. for(let i=0, all = data.statusPerFaucet.length; i < all; i++) {
  785. tableBody +='<td class="align-middle" title="Runned @' + helpers.getPrintableDateTime(data.statusPerFaucet[i].execTimeStamp) + '">' + helpers.getEmojiForPromoStatus(data.statusPerFaucet[i].status ?? 0) + '</td>';
  786. }
  787. tableBody +='</tr>';
  788. }
  789. $('#promo-table-body').html(tableBody);
  790. };
  791. function refresh(scheduleData, promotionData) {
  792. if (scheduleData) {
  793. loadScheduleTable(scheduleData);
  794. }
  795. if (promotionData) {
  796. loadPromotionTable(promotionData);
  797. }
  798. };
  799. function log(msg, elapsed = false) {
  800. if(msg) {
  801. let previous = logLines[0].split('&nbsp')[1];
  802. if(elapsed && (previous == msg)) {
  803. logLines[0] = helpers.getPrintableTime() + '&nbsp' + msg + '&nbsp[Elapsed time:&nbsp' + elapsed + '&nbspseconds]';
  804. } else {
  805. logLines.pop();
  806. logLines.unshift(helpers.getPrintableTime() + '&nbsp' + msg);
  807. }
  808. $('#console-log').html(logLines.join('<br>'));
  809. }
  810. };
  811. return {
  812. init: init,
  813. refresh: refresh,
  814. loadPromotionTable: loadPromotionTable,
  815. log: log
  816. }
  817. },
  818. createCFPromotions: function() {
  819. let codes = [];
  820. function PromotionCode(id, code, repeatDaily = false) {
  821. this.id = id;
  822. this.code = code;
  823. this.added = new Date();
  824. this.statusPerFaucet = [];
  825. this.repeatDaily = repeatDaily;
  826. this.lastExecTimeStamp = null;
  827. };
  828. function getFaucetStatusInPromo(promo, faucetId) {
  829. let faucet = promo.statusPerFaucet.find(x => x.id == faucetId);
  830. return faucet.status ?? PromoStatus.NOCODE;
  831. };
  832. function addNew(code) {
  833. let newPromo = new PromotionCode(codes.length, code);
  834. newPromo.statusPerFaucet = manager.getFaucetsForPromotion();
  835. newPromo.statusPerFaucet.forEach(function (element, idx, arr) {
  836. arr[idx].status = PromoStatus.PENDING;
  837. arr[idx].execTimeStamp = null;
  838. });
  839. codes.push(newPromo);
  840. codes.sort((a, b) => (a.id < b.id) ? 1 : -1);
  841. save();
  842. };
  843. function getAll() {
  844. return codes;
  845. };
  846. function updateFaucetForCode(code, faucetId, newStatus) {
  847. let promo = codes.find(x => x.code == code);
  848. let faucet = promo.statusPerFaucet.find(x => x.id == faucetId);
  849. if(faucet) {
  850. faucet.status = newStatus;
  851. faucet.execTimeStamp = new Date();
  852. promo.lastExecTimeStamp = faucet.execTimeStamp;
  853. }
  854. save();
  855. };
  856. function hasPromoAvailable(faucetId) {
  857. let resp = false;
  858. codes.forEach(function (promotion, idx, arr) {
  859. let status = getFaucetStatusInPromo(promotion, faucetId);
  860. if (status == PromoStatus.PENDING) {
  861. resp = promotion.code;
  862. return;
  863. }
  864. });
  865. return resp;
  866. };
  867. function save() {
  868. persistence.save('CFPromotions', getAll(), true);
  869. };
  870. function load(data) {
  871. codes = data;
  872. };
  873. function removeAll() {
  874. codes = [];
  875. save();
  876. };
  877. return {
  878. addNew: addNew,
  879. removeAll: removeAll,
  880. getAll: getAll,
  881. load: load,
  882. updateFaucetForCode: updateFaucetForCode,
  883. hasPromoAvailable: hasPromoAvailable
  884. }
  885. },
  886. createInteractions: function(){
  887. let randomInteractionLevel = RandomInteractionLevel.MEDIUM;
  888. let maxActions = 0;
  889. let performedActions = -1;
  890. let selectableElements;
  891. let actions = {
  892. available: [
  893. function() {
  894. $('html, body').animate({
  895. scrollTop: helpers.randomInt(0, $('html, body').get(0).scrollHeight)
  896. }, {
  897. complete: setTimeout(interactions.addPerformed, helpers.randomMs(100, 3000)),
  898. duration: helpers.randomMs(100, 1500)
  899. });
  900. },
  901. function() {
  902. let element = interactions.selectableElements[helpers.randomInt(0, interactions.selectableElements.length - 1)];
  903. try {
  904. if (document.body.createTextRange) {
  905. const range = document.body.createTextRange();
  906. range.moveToElementText(element);
  907. range.select();
  908. } else if (window.getSelection) {
  909. const selection = window.getSelection();
  910. const range = document.createRange();
  911. range.selectNodeContents(element);
  912. selection.removeAllRanges();
  913. selection.addRange(range);
  914. }
  915. } catch (err) { }
  916. interactions.addPerformed();
  917. }
  918. ]
  919. };
  920. function start(selectableElements) {
  921. performedActions = 0;
  922. switch(randomInteractionLevel) {
  923. case RandomInteractionLevel.NONE:
  924. maxActions = 0;
  925. break;
  926. case RandomInteractionLevel.LOW:
  927. maxActions = helpers.randomInt(2, 4);
  928. break;
  929. case RandomInteractionLevel.MEDIUM:
  930. maxActions = helpers.randomInt(5, 8);
  931. break;
  932. case RandomInteractionLevel.HIGH:
  933. maxActions = helpers.randomInt(12, 16);
  934. break;
  935. }
  936. interactions.selectableElements = selectableElements;
  937. performActions();
  938. }
  939. function performActions() {
  940. if(performedActions >= maxActions) {
  941. return;
  942. }
  943. let delay = 0;
  944. for(let i = 0; i < maxActions; i++) {
  945. delay += helpers.randomMs(350, 1500);
  946. setTimeout(actions.available[helpers.randomInt(0, actions.available.length - 1)], delay);
  947. }
  948. }
  949. function addPerformed() {
  950. performedActions++;
  951. }
  952. function completed() {
  953. return (performedActions >= maxActions);
  954. }
  955. return {
  956. start: start,
  957. completed: completed,
  958. addPerformed: addPerformed,
  959. selectableElements: selectableElements
  960. };
  961. },
  962. createSGProcessor: function() {
  963. let timerSpans;
  964. function run() {
  965. if(isLoading()) {
  966. setTimeout(SGProcessor.run, helpers.randomMs(5000, 10000));
  967. return;
  968. } else {
  969. if(isMinerActive()) {
  970. processRunDetails();
  971. } else {
  972. activateMiner();
  973. }
  974. }
  975. };
  976. function isLoading() {
  977. return $('#loader-logo').length;
  978. };
  979. function isMinerActive() {
  980. timerSpans = $('.mb-8 .wrapper .mb-1 span');
  981. if(timerSpans.length > 0) {
  982. return true;
  983. } else {
  984. return false;
  985. }
  986. return (timerSpans.length === 0);
  987. };
  988. function activateMiner() {
  989. const activateButton = document.querySelector('.mb-8 .wrapper button');
  990. if (activateButton) {
  991. activateButton.click();
  992. setTimeout(SGProcessor.processRunDetails, helpers.randomMs(10000, 20000));
  993. } else {
  994. if(!is404Error()) {
  995. SGProcessor.processRunDetails()
  996. }
  997. }
  998. };
  999. function is404Error() {
  1000. const h1 = document.getElementsByTagName('h1');
  1001. if (h1.length > 0 && h1[0].innerText.includes('404')) {
  1002. window.location.reload();
  1003. return true;
  1004. }
  1005. return false;
  1006. }
  1007. function processRunDetails() {
  1008. let result = {};
  1009. result.nextRoll = helpers.addMinutes(new Date(), readCountdown().toString());
  1010. result.balance = readBalance();
  1011. shared.closeWindow(result);
  1012. };
  1013. function readCountdown() {
  1014. let mins = 15;
  1015. try {
  1016. let timeLeft = timerSpans.last().text().split(':');
  1017. if(timeLeft.length === 3) {
  1018. mins = parseInt(timeLeft[0]) * 60 + parseInt(timeLeft[1]);
  1019. }
  1020. } catch (err) { }
  1021. return mins;
  1022. };
  1023. function readBalance() {
  1024. let balance = "";
  1025. try {
  1026. balance = $('span.text-accent').first().text() + " BTC";
  1027. } catch (err) { }
  1028. return balance;
  1029. };
  1030. return {
  1031. run: run,
  1032. processRunDetails: processRunDetails
  1033. };
  1034. },
  1035. createCFProcessor: function() {
  1036. const NavigationProcess = {
  1037. ROLLING: 1,
  1038. PROCESSING_PROMOTION: 2,
  1039. LOGIN: 3
  1040. };
  1041. let navigationProcess;
  1042. let countdown;
  1043. let rollButton;
  1044. let promotionTag;
  1045. let timeWaiting= 0;
  1046. let loopingForErrors = false;
  1047. function run() {
  1048. navigationProcess = NavigationProcess.ROLLING;
  1049. displayStatusUi();
  1050. setTimeout(findCountdownOrRollButton, helpers.randomMs(2000, 5000));
  1051. };
  1052. function doLogin() {
  1053. navigationProcess = NavigationProcess.LOGIN;
  1054. displayStatusUi();
  1055. setTimeout(findLoginForm, helpers.randomMs(2000, 5000));
  1056. };
  1057. function isFullyLoaded() { //Waits 55 seconds max
  1058. if(document.readyState == 'complete' || timeWaiting == -1) {
  1059. $('#process-status')[0].innerHTML = 'Interacting';
  1060. timeWaiting = 0;
  1061. interact();
  1062. } else {
  1063. timeWaiting = -1;
  1064. $('#process-status')[0].innerHTML = 'Waiting for document fully loaded';
  1065. setTimeout(CFProcessor.isFullyLoaded, helpers.randomMs(45000, 55000));
  1066. }
  1067. };
  1068. function runPromotion() {
  1069. navigationProcess = NavigationProcess.PROCESSING_PROMOTION
  1070. displayStatusUi();
  1071. setTimeout(CFProcessor.findPromotionTag, helpers.randomMs(1000, 3000));
  1072. };
  1073. function findCountdownOrRollButton() {
  1074. if( isCountdownVisible() && !isRollButtonVisible() ) {
  1075. timeWaiting = 0;
  1076. processRunDetails();
  1077. } else if ( !isCountdownVisible() && isRollButtonVisible() ) {
  1078. timeWaiting = 0;
  1079. setTimeout(CFProcessor.isFullyLoaded, helpers.randomMs(1000, 5000));
  1080. } else {
  1081. if (timeWaiting/1000 > config.timeout * 60) {
  1082. shared.closeWithError('TIMEOUT', '');
  1083. return;
  1084. }
  1085. timeWaiting += 3000;
  1086. setTimeout(findCountdownOrRollButton, helpers.randomMs(2000, 5000));
  1087. }
  1088. };
  1089. function findLoginForm() {
  1090. if ( $('div.login-wrapper').is(':visible') ) {
  1091. //Other possible error is if recaptcha did not load yet... so maybe wait til the web is fully loaded for low connection issues
  1092. if( $('.login-wrapper .error').length > 0 && $('.login-wrapper .error')[0].innerHTML != '') {
  1093. let errorMessage = $('.login-wrapper .error').text();
  1094. shared.closeWithError('LOGIN_ERROR', errorMessage);
  1095. return;
  1096. }
  1097. if(!loopingForErrors) {
  1098. if(config.cf.credentials.mode == 1) {
  1099. timeWaiting = 0;
  1100. $('.login-wrapper input[name="email"]').val(config.cf.credentials.email);
  1101. $('.login-wrapper input[name="password"]').val(config.cf.credentials.password);
  1102. $('.login-wrapper button.login').click();
  1103. loopingForErrors = true;
  1104. } else {
  1105. if($('.login-wrapper input[name="email"]').val() != '' && $('.login-wrapper input[name="password"]').val() != '') {
  1106. $('.login-wrapper button.login').click();
  1107. $('#process-status')[0].innerHTML = 'Processing';
  1108. loopingForErrors = true;
  1109. } else {
  1110. $('#process-status')[0].innerHTML = 'Waiting for credentials...';
  1111. if (timeWaiting/1000 > (config.timeout / 1.5) * 60) {
  1112. shared.closeWithError('LOGIN_ERROR', 'No credentials were provided');
  1113. return;
  1114. }
  1115. }
  1116. }
  1117. }
  1118. }
  1119. if (timeWaiting/1000 > config.timeout * 60) {
  1120. shared.closeWithError('TIMEOUT', '');
  1121. return;
  1122. }
  1123. timeWaiting += 3000;
  1124. setTimeout(findLoginForm, helpers.randomMs(2000, 5000));
  1125. };
  1126. function interact() {
  1127. let selectables = []
  1128. selectables = selectables.concat($('td').toArray());
  1129. selectables = selectables.concat($('p').toArray());
  1130. selectables = selectables.concat($('th').toArray());
  1131. interactions.start(selectables);
  1132. setTimeout(CFProcessor.waitInteractions, helpers.randomMs(2000, 4000));
  1133. }
  1134. function waitInteractions() {
  1135. if(interactions.completed()) {
  1136. roll();
  1137. } else {
  1138. setTimeout(CFProcessor.waitInteractions, helpers.randomMs(2000, 4000));
  1139. }
  1140. }
  1141. function isCountdownVisible() {
  1142. countdown = $('.timeout-wrapper');
  1143. return ($(countdown).length > 0 && $(countdown[0]).is(':visible'));
  1144. };
  1145. function isRollButtonVisible() {
  1146. rollButton = $('.main-button-2.roll-button.bg-2');
  1147. return ($(rollButton).length > 0 && $(rollButton[0]).is(':visible'));
  1148. };
  1149. function roll() {
  1150. $('#process-status')[0].innerHTML = 'Roll triggered';
  1151. $(rollButton[0]).click();
  1152. setTimeout(findCountdownOrRollButton, helpers.randomMs(2000, 3000));
  1153. }
  1154. function isPromotionTagVisible() {
  1155. let pTags = $('p');
  1156. if (pTags.length > 0) {
  1157. promotionTag = $('p')[0];
  1158. return true;
  1159. }
  1160. return false;
  1161. };
  1162. function findPromotionTag() {
  1163. if( isPromotionTagVisible() ) {
  1164. processRunDetails();
  1165. } else {
  1166. setTimeout(CFProcessor.findPromotionTag, helpers.randomMs(2000, 5000));
  1167. }
  1168. };
  1169. function processRunDetails() {
  1170. let result = {};
  1171. if(navigationProcess == NavigationProcess.ROLLING) {
  1172. result.nextRoll = readCountdown();
  1173. result.claimed = readClaimed();
  1174. result.balance = readBalance();
  1175. if(result.claimed != 0) {
  1176. result.rolledNumber = readRolledNumber();
  1177. }
  1178. result.balance = readBalance();
  1179. } else if (navigationProcess == NavigationProcess.PROCESSING_PROMOTION) {
  1180. result.promoStatus = readPromoStatus();
  1181. result.promoCode = readPromoCode();
  1182. if (result.promoStatus == PromoStatus.ACCEPTED) {
  1183. result.nextRoll = helpers.addMinutes(new Date(), "-120");
  1184. }
  1185. }
  1186. shared.closeWindow(result);
  1187. };
  1188. function readCountdown() {
  1189. let minsElement = $('.timeout-container .minutes .digits');
  1190. let mins = "0";
  1191. if ($(minsElement).length > 0) {
  1192. mins = $(minsElement)[0].innerHTML;
  1193. }
  1194. if (mins) {
  1195. return helpers.addMinutes(new Date(), mins.toString());
  1196. } else {
  1197. return null;
  1198. }
  1199. };
  1200. function readClaimed() {
  1201. let claimed = 0;
  1202. try {
  1203. claimed = $('.result')[0].innerHTML;
  1204. claimed = claimed.trim();
  1205. claimed = claimed.slice(claimed.lastIndexOf(" ") + 1);
  1206. } catch(err) { }
  1207. return claimed;
  1208. };
  1209. function readRolledNumber() {
  1210. let number = 0;
  1211. try {
  1212. number = $('.lucky-number').toArray().map(x => x.innerText).join('');
  1213. number = parseInt(number);
  1214. } catch(err) { }
  1215. return number;
  1216. };
  1217. function readBalance() {
  1218. let balance = "";
  1219. try {
  1220. balance = $('.navbar-coins.bg-1 a').first().text();
  1221. } catch(err) { }
  1222. return balance;
  1223. };
  1224. function readPromoStatus() {
  1225. let promoStatus = PromoStatus.UNKNOWNERROR;
  1226. try {
  1227. if(promotionTag.innerHTML.indexOf(localeConfig.stringSearches.promoCodeAccepted) > 0) {
  1228. return PromoStatus.ACCEPTED;
  1229. } else if(promotionTag.innerHTML.indexOf(localeConfig.stringSearches.promoCodeUsed) > 0) {
  1230. return PromoStatus.USEDBEFORE;
  1231. } else if(promotionTag.innerHTML.indexOf(localeConfig.stringSearches.promoCodeInvalid) > 0) {
  1232. return PromoStatus.INVALID;
  1233. } else if(promotionTag.innerHTML.indexOf(localeConfig.stringSearches.promoCodeInvalid2) > 0) {
  1234. return PromoStatus.INVALID;
  1235. } else if(promotionTag.innerHTML.indexOf(localeConfig.stringSearches.promoCodeInvalid3) > 0) {
  1236. return PromoStatus.INVALID;
  1237. }
  1238. } catch ( err ) { }
  1239. return promoStatus;
  1240. };
  1241. function validatePromoString() {
  1242. };
  1243. function readPromoCode() {
  1244. var urlSplit = window.location.href.split('/');
  1245. return urlSplit[urlSplit.length - 1];
  1246. };
  1247. function displayStatusUi() {
  1248. $( 'body' ).prepend( '<div class="withdraw-button bg-2" style="top:30%; z-index:1500;" href="#">⚙️ <span id="process-status">Processing</span></div>' );
  1249. };
  1250. return {
  1251. run: run,
  1252. runPromotion: runPromotion,
  1253. findPromotionTag: findPromotionTag,
  1254. waitInteractions: waitInteractions,
  1255. isFullyLoaded: isFullyLoaded,
  1256. doLogin: doLogin
  1257. };
  1258. },
  1259. createCFHistory: function() {
  1260. let rollsMeta = [
  1261. { id: 0, range: '0000-9885', count: 0 },
  1262. { id: 1, range: '9886-9985', count: 0 },
  1263. { id: 2, range: '9986-9993', count: 0 },
  1264. { id: 3, range: '9994-9997', count: 0 },
  1265. { id: 4, range: '9998-9999', count: 0 },
  1266. { id: 5, range: '10000', count: 0 }
  1267. ];
  1268. function initOrLoad() {
  1269. let storedData = persistence.load('CFHistory', true);
  1270. if(storedData) {
  1271. rollsMeta = storedData;
  1272. }
  1273. };
  1274. function addRoll(number) {
  1275. switch(true) {
  1276. case (number <= 9885):
  1277. rollsMeta[0].count++;
  1278. break;
  1279. case (number <= 9985):
  1280. rollsMeta[1].count++;
  1281. break;
  1282. case (number <= 9993):
  1283. rollsMeta[2].count++;
  1284. break;
  1285. case (number <= 9997):
  1286. rollsMeta[3].count++;
  1287. break;
  1288. case (number <= 9999):
  1289. rollsMeta[4].count++;
  1290. break;
  1291. case (number == 10000):
  1292. rollsMeta[5].count++;
  1293. break;
  1294. default:
  1295. break;
  1296. }
  1297. save();
  1298. };
  1299. function getRollsMeta() {
  1300. return rollsMeta.map(x => x.count);
  1301. };
  1302. function save() {
  1303. persistence.save('CFHistory', rollsMeta, true);
  1304. };
  1305. return {
  1306. initOrLoad: initOrLoad,
  1307. addRoll: addRoll,
  1308. getRollsMeta: getRollsMeta
  1309. }
  1310. },
  1311. createFBProcessor: function() {
  1312. let timeWaiting= 0;
  1313. let countdownMinutes;
  1314. function run() {
  1315. setTimeout(findCountdownOrRollButton, helpers.randomMs(12000, 15000));
  1316. };
  1317. function findCountdownOrRollButton() {
  1318. if ( isCountdownVisible() ) {
  1319. timeWaiting = 0;
  1320. countdownMinutes = +document.querySelectorAll('.free_play_time_remaining.hasCountdown .countdown_amount')[0].innerHTML + 1;
  1321. let result = {};
  1322. result.balance = readBalance();
  1323. result.nextRoll = helpers.addMinutes(new Date(), countdownMinutes.toString());
  1324. shared.closeWindow(result);
  1325. return;
  1326. }
  1327. if ( isRollButtonVisible() ) {
  1328. if (config.fb.activateRPBonus) {
  1329. if (!document.getElementById('bonus_container_free_points')) {
  1330. document.querySelector('a.rewards_link').click();
  1331. activateBonus(0);
  1332. }
  1333. }
  1334. if (isHCaptchaVisible()) {
  1335. waitForCaptcha();
  1336. } else {
  1337. clickRoll();
  1338. }
  1339. }
  1340. };
  1341. function isCountdownVisible() {
  1342. return document.querySelectorAll('.free_play_time_remaining.hasCountdown .countdown_amount').length > 0;
  1343. };
  1344. function isHCaptchaVisible() {
  1345. let hCaptchaFrame = document.querySelector('.h-captcha > iframe');
  1346. if (hCaptchaFrame && $(hCaptchaFrame).is(':visible')) {
  1347. return true;
  1348. }
  1349. return false;
  1350. };
  1351. function isRollButtonVisible() {
  1352. return $(document.getElementById('free_play_form_button')).is(':visible');
  1353. };
  1354. function waitForCaptcha() {
  1355. if ( document.querySelector('.h-captcha > iframe').getAttribute('data-hcaptcha-response').length > 0) {
  1356. clickRoll();
  1357. } else {
  1358. if (timeWaiting/1000 > config.timeout * 60) {
  1359. shared.closeWithError('TIMEOUT', '');
  1360. return;
  1361. }
  1362. timeWaiting += 10000;
  1363. setTimeout(waitForCaptcha, helpers.randomMs(10000, 12000));
  1364. }
  1365. };
  1366. function clickRoll() {
  1367. try {
  1368. document.getElementById('free_play_form_button').click();
  1369. setTimeout(processRunDetails, helpers.randomMs(3000, 10000));
  1370. } catch (err) {
  1371. shared.closeWithError('CLICK_ROLL_ERROR', err);
  1372. }
  1373. };
  1374. function processRunDetails() {
  1375. if ($(document.getElementById('winnings')).is(':visible')) {
  1376. closePopup();
  1377. let result = {};
  1378. result.claimed = readClaimed();
  1379. result.balance = readBalance();
  1380. if(result.claimed != 0) {
  1381. result.rolledNumber = readRolledNumber();
  1382. result.nextRoll = helpers.addMinutes(new Date(), "60");
  1383. }
  1384. shared.closeWindow(result);
  1385. return;
  1386. }
  1387. if ($(document.getElementById('same_ip_error')).is(':visible')) {
  1388. shared.closeWithError('ROLL_ERROR', document.getElementById('same_ip_error').innerHTML);
  1389. return;
  1390. }
  1391. if($('#free_play_error').is(':visible')) {
  1392. shared.closeWithError('ROLL_ERROR', $('.free_play_error')[0].innerHTML);
  1393. return;
  1394. }
  1395. if ($('.free_play_result_error').is(':visible')) {
  1396. shared.closeWithError('ROLL_ERROR', $('.free_play_result_error')[0].innerHTML);
  1397. return;
  1398. }
  1399. if (timeWaiting/1000 > config.timeout * 60) {
  1400. shared.closeWithError('TIMEOUT', '');
  1401. return;
  1402. }
  1403. timeWaiting += 5000;
  1404. setTimeout(processRunDetails, helpers.randomMs(5000, 6000));
  1405. };
  1406. function closePopup() {
  1407. let closePopupBtn = document.querySelector('.reveal-modal.open .close-reveal-modal');
  1408. if (closePopupBtn) {
  1409. closePopupBtn.click();
  1410. }
  1411. };
  1412. function readRolledNumber() {
  1413. let rolled = 0;
  1414. try {
  1415. rolled = parseInt([... document.querySelectorAll('#free_play_digits span')].map( x => x.innerHTML).join(''));
  1416. } catch { }
  1417. return rolled;
  1418. };
  1419. function readBalance() {
  1420. let balance = 0;
  1421. try {
  1422. balance = document.getElementById('balance').innerHTML;
  1423. } catch { }
  1424. return balance;
  1425. };
  1426. function readClaimed() {
  1427. let claimed = 0;
  1428. try {
  1429. claimed = document.getElementById('winnings').innerHTML;
  1430. } catch { }
  1431. return claimed;
  1432. };
  1433. function activateBonus(i) {
  1434. if($(document.querySelector('#reward_point_redeem_result_container_div .reward_point_redeem_result_error')).is(':visible')) {
  1435. let closeBtn = document.querySelector('#reward_point_redeem_result_container_div .reward_point_redeem_result_box_close')
  1436. if ($(closeBtn).is(':visible')) {
  1437. closeBtn.click();
  1438. }
  1439. } else if ($(document.querySelector('#reward_point_redeem_result_container_div .reward_point_redeem_result_success')).is(':visible')) {
  1440. let closeBtn = document.querySelector('#reward_point_redeem_result_container_div .reward_point_redeem_result_box_close')
  1441. if ($(closeBtn).is(':visible')) {
  1442. closeBtn.click();
  1443. document.querySelector('#free_play_link_li a');
  1444. setTimeout(findCountdownOrRollButton, helpers.randomMs(10000, 12000));
  1445. return;
  1446. }
  1447. }
  1448. try {
  1449. let redeemButtons = document.querySelectorAll('#free_points_rewards button');
  1450. redeemButtons[i].click();
  1451. i = i + 1;
  1452. } catch (err) {
  1453. }
  1454. if(i > 4) {
  1455. document.querySelector('#free_play_link_li a');
  1456. setTimeout(findCountdownOrRollButton, helpers.randomMs(10000, 12000));
  1457. return;
  1458. }
  1459. setTimeout(activateBonus.bind(null, i), 5000);
  1460. };
  1461. return {
  1462. run: run
  1463. };
  1464. }
  1465. };
  1466. /**
  1467. * Prevents alert popups to be able to reload the faucet if invisible captcha validation fails
  1468. */
  1469. function overrideSelectNativeJS_Functions () {
  1470. window.alert = function alert (message) {
  1471. console.log (message);
  1472. }
  1473. }
  1474. function addJS_Node (text, s_URL, funcToRun) {
  1475. var scriptNode= document.createElement ('script');
  1476. scriptNode.type= "text/javascript";
  1477. if (text)scriptNode.textContent= text;
  1478. if (s_URL)scriptNode.src= s_URL;
  1479. if (funcToRun)scriptNode.textContent = '(' + funcToRun.toString() + ')()';
  1480. var element = document.getElementsByTagName ('head')[0] || document.body || document.documentElement;
  1481. element.appendChild (scriptNode);
  1482. }
  1483. function detectWeb() {
  1484. // Now detecting based on host to handle automatic redirects (for example: login request)
  1485. if(!shared.isOpenedByManager(window.location.host)) {
  1486. return;
  1487. }
  1488. let currentFromManager = shared.getCurrent();
  1489. if (currentFromManager.type == WebType.STORMGAIN) {
  1490. SGProcessor = objectGenerator.createSGProcessor();
  1491. setTimeout(SGProcessor.run, helpers.randomMs(10000, 20000));
  1492. return;
  1493. }
  1494. if (currentFromManager.type == WebType.CRYPTOSFAUCETS) {
  1495. let expectedCfUrlType = helpers.cf.getUrlType(currentFromManager.url);
  1496. let realCfUrlType = helpers.cf.getUrlType(window.location.href);
  1497. switch(expectedCfUrlType) {
  1498. case CFUrlType.FREE:
  1499. switch(realCfUrlType) {
  1500. case CFUrlType.FREE:
  1501. if(localeConfig.setToEnglish) {
  1502. let refValue = $('.nav-item a')[4].innerHTML;
  1503. if (refValue != 'Settings') {
  1504. window.location.href = '/set-language/en';
  1505. }
  1506. }
  1507. addJS_Node (null, null, overrideSelectNativeJS_Functions);
  1508. CFProcessor = objectGenerator.createCFProcessor();
  1509. interactions = objectGenerator.createInteractions();
  1510. setTimeout(CFProcessor.run, helpers.randomMs(1000, 3000));
  1511. break;
  1512. case CFUrlType.CONTACTTWITTER:
  1513. //TODO: mark as possibly banned
  1514. break;
  1515. case CFUrlType.HOME:
  1516. if (config.cf.autologin) {
  1517. addJS_Node (null, null, overrideSelectNativeJS_Functions);
  1518. CFProcessor = objectGenerator.createCFProcessor();
  1519. setTimeout(CFProcessor.doLogin, helpers.randomMs(1000, 3000));
  1520. } else {
  1521. shared.closeWithError('NEED_TO_LOGIN', '');
  1522. }
  1523. break;
  1524. default:
  1525. break;
  1526. }
  1527. break;
  1528. case CFUrlType.PROMOTION:
  1529. CFProcessor = objectGenerator.createCFProcessor();
  1530. interactions = objectGenerator.createInteractions();
  1531. setTimeout(CFProcessor.runPromotion, helpers.randomMs(5000, 10000));
  1532. break;
  1533. }
  1534. return;
  1535. }
  1536. if (currentFromManager.type == WebType.FREEBITCOIN) {
  1537. FBProcessor = objectGenerator.createFBProcessor();
  1538. setTimeout(FBProcessor.run, helpers.randomMs(2000, 5000));
  1539. return;
  1540. }
  1541. }
  1542. function init() {
  1543. shared = objectGenerator.createShared();
  1544. persistence = objectGenerator.createPersistence();
  1545. if(window.location.host === 'satology.onrender.com') {
  1546. manager = objectGenerator.createManager();
  1547. CFPromotions = objectGenerator.createCFPromotions();
  1548. ui = objectGenerator.createUi();
  1549. CFHistory = objectGenerator.createCFHistory();
  1550. manager.init();
  1551. } else {
  1552. detectWeb();
  1553. }
  1554. }
  1555. init();
  1556. })();

comments powered by Disqus