Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // @match        *://*.freebitco.in/*
  2.  
  3. // ==/UserScript==
  4.  
  5. (function() {
  6.     'use strict';
  7.  
  8.     let config = {
  9. //        timeout: 4,            // Use -1 to disable the timeout functionality. In minutes. Max time the monitor will wait for a result/roll.
  10. //                               // After timeout is reached, the Manager/Monitor will assume something is wrong
  11. //                               // (usually faucet tab being accidentally closed or failed to connect)
  12. //                               // Will trigger a refresh on the Monitor website and carry on the process
  13. //        postponeMinutes: 3,   // Minutes to wait before retrying a faucet that timed out
  14.         fb: {
  15.             activateRPBonus: false // will try to activate the highest RP Roll Bonus available for the account (100, 50 25, ... points per roll),
  16.         }
  17.     }
  18.     let persistence, interactions, FBProcessor;
  19.     let helpers = {
  20.         cleanString: function(input) {
  21.             var output = "";
  22.             for (var i=0; i<input.length; i++) {
  23.                 if (input.charCodeAt(i) <= 127) {
  24.                     output += input.charAt(i);
  25.                 }
  26.             }
  27.             return output;
  28.         },
  29.         shuffle: function (array) {
  30.             let currentIndex = array.length, temporaryValue, randomIndex;
  31.             while (0 !== currentIndex) {
  32.                 randomIndex = Math.floor(Math.random() * currentIndex);
  33.                 currentIndex -= 1;
  34.                 temporaryValue = array[currentIndex];
  35.                 array[currentIndex] = array[randomIndex];
  36.                 array[randomIndex] = temporaryValue;
  37.             }
  38.             return array;
  39.         },
  40.         randomMs: function (a, b){
  41.             return a + (b - a) * Math.random();
  42.         },
  43.         addMinutes: function(date, mins) {
  44.             return date.setMinutes(date.getMinutes() + parseInt(mins) + 1);
  45.         },
  46.         randomInt: function(min, max) {
  47.             return Math.floor(Math.random() * (max - min + 1) + min);
  48.         },
  49.         addMilliseconds: function(date, ms) {
  50.             return date.setMilliseconds(date.getMilliseconds() + ms);
  51.         },
  52.         getRandomMillisecondsFromMinutesRange(minute, rangeDiffInPercentage) {
  53.             const msCenter = minute * 60 * 1000;
  54.             const msRangeDiff = Math.round(msCenter * rangeDiffInPercentage / 100);
  55.             return helpers.randomMs(msCenter - msRangeDiff, msCenter + msRangeDiff);
  56.         },
  57.     }
  58.     let objectGenerator = {
  59.         createPersistence: function() {
  60.             const prefix = 'autoWeb_';
  61.             function save(key, value, parseIt = false) {
  62.                 GM_setValue(prefix + key, parseIt ? JSON.stringify(value) : value);
  63.             };
  64.             function load(key, parseIt = false) {
  65.                 let value = GM_getValue(prefix + key);
  66.                 if(value && parseIt) {
  67.                     value = JSON.parse(value);
  68.                 }
  69.                 return value;
  70.             };
  71.             return {
  72.                 save: save,
  73.                 load: load
  74.             };
  75.         },
  76.  
  77.         createFBProcessor: function() {
  78.             let timeWaiting= 0;
  79.             let countdownMinutes;
  80.             function run() {
  81.                 setTimeout(findCountdownOrRollButton, helpers.randomMs(12000, 15000));
  82.             };
  83.             function findCountdownOrRollButton() {
  84.                 if ( isCountdownVisible() ) {
  85.                     timeWaiting = 0;
  86.                     countdownMinutes = +document.querySelectorAll('.free_play_time_remaining.hasCountdown .countdown_amount')[0].innerHTML + 1;
  87.                     return;
  88.                 }
  89.                 if ( isRollButtonVisible() ) {
  90.                     if (config.fb.activateRPBonus) {
  91.                         if (!document.getElementById('bonus_container_free_points')) {
  92.                             document.querySelector('a.rewards_link').click();
  93.                             activateBonus(0);
  94.                         }
  95.                     }
  96.                     if (isHCaptchaVisible()) {
  97.                         waitForCaptcha();
  98.                     } else {
  99.                         clickRoll();
  100.                     }
  101.                 }
  102.             };
  103.             function isCountdownVisible() {
  104.                 return document.querySelectorAll('.free_play_time_remaining.hasCountdown .countdown_amount').length > 0;
  105.             };
  106.             function isHCaptchaVisible() {
  107.                 let hCaptchaFrame = document.querySelector('.h-captcha > iframe');
  108.                 if (hCaptchaFrame && $(hCaptchaFrame).is(':visible')) {
  109.                     return true;
  110.                 }
  111.                 return false;
  112.             };
  113.             function isRollButtonVisible() {
  114.                 return $(document.getElementById('free_play_form_button')).is(':visible');
  115.             };
  116.             function waitForCaptcha() {
  117.                 if ( document.querySelector('.h-captcha > iframe').getAttribute('data-hcaptcha-response').length > 0) {
  118.                     clickRoll();
  119.                 } else {
  120.                     if (timeWaiting/1000 > config.timeout * 60) {
  121.                         return;
  122.                     }
  123.                     timeWaiting += 10000;
  124.                     setTimeout(waitForCaptcha, helpers.randomMs(10000, 12000));
  125.                 }
  126.             };
  127.             function clickRoll() {
  128.                     document.getElementById('free_play_form_button').click();
  129.                     setTimeout(waitForCaptcha, helpers.randomMs(4000, 6000));
  130.             };
  131.             function closePopup() {
  132.                 let closePopupBtn = document.querySelector('.reveal-modal.open .close-reveal-modal');
  133.                 if (closePopupBtn) {
  134.                     closePopupBtn.click();
  135.                 }
  136.             };
  137.             return {
  138.                 run: run
  139.             };
  140.         }
  141.     };
  142.     /**
  143.     * Prevents alert popups to be able to reload the faucet if invisible captcha validation fails
  144.     */
  145.     function overrideSelectNativeJS_Functions () {
  146.         window.alert = function alert (message) {
  147.             console.log (message);
  148.         }
  149.     }
  150.     function addJS_Node (text, s_URL, funcToRun) {
  151.         var scriptNode= document.createElement ('script');
  152.         scriptNode.type= "text/javascript";
  153.         if (text)scriptNode.textContent= text;
  154.         if (s_URL)scriptNode.src= s_URL;
  155.         if (funcToRun)scriptNode.textContent = '(' + funcToRun.toString() + ')()';
  156.         var element = document.getElementsByTagName ('head')[0] || document.body || document.documentElement;
  157.         element.appendChild (scriptNode);
  158.     }
  159.  
  160.     FBProcessor = objectGenerator.createFBProcessor();
  161.     setTimeout(FBProcessor.run, helpers.randomMs(2000, 5000));
  162. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement