Greasy Fork is available in English.

Faucet Rotator - Crab Coins

Earn free crypto using this script instantly

// ==UserScript==
// @name         Faucet Rotator - Crab Coins
// @namespace    Faucet Rotator - Crab Coins
// @version      1.3
// @description  Earn free crypto using this script instantly
// @author       BleemV
// @match        https://crab-coins.com/*
// @connect      crab-coins.com
// @icon         https://www.google.com/s2/favicons?sz=64&domain=crab-coins.com
// @noframes
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_xmlhttpRequest
// @antifeature  referral-link
// ==/UserScript==

//Block All Pop ups
unsafeWindow.open = function() { };

(function() {
	'use strict';

	//===============================================================================================
	//User configuration

	var faucetpayEmail = "ENTER_YOUR_FAUCETPAY_EMAIL_ADDRESS";
	var btc = "ENTER_YOUR_FAUCETPAY_BITCOIN_ADDRESS";
	var doge = "ENTER_YOUR_FAUCETPAY_DOGE_ADDRESS";
	var ltc = "ENTER_YOUR_FAUCETPAY_LITECOIN_ADDRESS";
	var trx = "ENTER_YOUR_FAUCETPAY_TRON_ADDRESS";
	var bnb = "ENTER_YOUR_FAUCETPAY_BINANCE_ADDRESS";
	var sol = "ENTER_YOUR_FAUCETPAY_SOLANA_ADDRESS";
	var usdt = "ENTER_YOUR_FAUCETPAY_TETHER_ADDRESS";
	var ada = "ENTER_YOUR_FAUCETPAY_CARDANO_ADDRESS";
	var matic = "ENTER_YOUR_FAUCETPAY_POLYGON_ADDRESS";
	var eth = "ENTER_YOUR_FAUCETPAY_ETHEREUM_ADDRESS";
	var bch = "ENTER_YOUR_FAUCETPAY_BITCOINCASH_ADDRESS";
	var dash = "ENTER_YOUR_FAUCETPAY_DASH_ADDRESS";
	var zec = "ENTER_YOUR_FAUCETPAY_ZCASH_ADDRESS";
	var dgb = "ENTER_YOUR_FAUCETPAY_DIGIBYTE_ADDRESS";

	//You can now save the file and start using
	//===============================================================================================

	//List of the faucet websites along with address
	//coin parameter is used as regex from the url
	//If url has */bitcoin/* then use "bitcoin" as coin, if it is */ETH/*, use "ETH" as coin
	//If there is no regex for coin, use only address
	// Comment the faucets which you do not wish to use or which don't have sufficient funds
	// Always add bitcoin before bitcoincash if you using same domains

	var websiteData = [
		{ url: "https://crab-coins.com/bitcoin-faucet/?r=1Mon42KK82mErV1pEoYF9d6ZcPPdmKRGTQ", coin: "bitcoin-faucet", address: faucetpayEmail },
		{ url: "https://crab-coins.com/dogecoin-faucet/?r=DTWuDSaTHEo7RTBtBTH942sH7SHRbvDxe9", coin: "dogecoin-faucet", address: faucetpayEmail },
		{ url: "https://crab-coins.com/litecoin-faucet/?r=M8DD8ct56BvkjpLcoR3B6c8oQG5jssU5kc", coin: "litecoin-faucet", address: faucetpayEmail },
		{ url: "https://crab-coins.com/tron-faucet/?r=TM1Aht45p5EhStpzaifYUbKGv5Z8SoV16E", coin: "tron-faucet", address: faucetpayEmail },
		{ url: "https://crab-coins.com/bnb-faucet/?r=0x4827158e0C46674B757AA49ceaab51e1f226fa68", coin: "bnb-faucet", address: faucetpayEmail },
		{ url: "https://crab-coins.com/solana-faucet/?r=DEtwAmYV9QmwBbbrsNaGGXByNeCqwEBLRrNkWSCetwzx", coin: "solana-faucet", address: faucetpayEmail },
		{ url: "https://crab-coins.com/tether-faucet/?r=TM1Aht45p5EhStpzaifYUbKGv5Z8SoV16E", coin: "tether-faucet", address: faucetpayEmail },
        { url: "https://crab-coins.com/cardano-faucet/?r=addr1q8hvsl72vw0rdhs8js4mqggz22vnkrd35fw9e22802pwcmv9qzc9laj44lte3s8jtadxwgkxs8549mcfyyv4zs5ctq6qdp9thk", coin: "cardano-faucet", address: faucetpayEmail},		
		{ url: "https://crab-coins.com/polygon-faucet/?r=0xAE1684928D9eC445D88c855D78BF8E55F68Bf79d", coin: "polygon-faucet", address: faucetpayEmail },
		{ url: "https://crab-coins.com/ethereum-faucet/?r=0xAc31D6210602A52140ff10611Fd057DCBE7bFF92", coin: "ethereum-faucet", address: faucetpayEmail },
		{ url: "https://crab-coins.com/bch-faucet/?r=qrg8z9cqckhus0gqqyaek72zkz0m6p7wc5pq3tj9ug", coin: "bch-faucet", address: faucetpayEmail },
		{ url: "https://crab-coins.com/dash-faucet/?r=XhMLuGgsBigfNQgdCYUKYjn7H1sVmGbc32", coin: "dash-faucet", address: faucetpayEmail },
		{ url: "https://crab-coins.com/zcash-faucet/?r=t1MGZBqHknXgX7hYm9ejAKS77tSje3wwitQ", coin: "zcash-faucet", address: faucetpayEmail },
		{ url: "https://crab-coins.com/digibyte-faucet/?r=DRDm3Wu3bSitX7ZC3szBwtHNbpMbQxoyoe", coin: "digibyte-faucet", address: faucetpayEmail },
	];

	//Add data for any new website with single pages
	//Message selectors are for success or failure to move on to the next website
	//AutoWithdraw is disabled by default(for bagi and keran)
	//Add only domain name in website as mentioned below. Follow the same pattern.
	//Use arrays wherever it is required
	//ToDo:Instead of reading messages, either visibility or length of the messages can be checked

	var websiteMap = [{
		website: ["crab-coins.com"],
		inputTextSelector: ["#address"],
		inputTextSelectorButton: "body > div.container.flex-grow.my-4 > div.row.my-2 > div.col-12.col-md-8.col-lg-8.order-md-2.mb-4.text-center > form > div:nth-child(4) > button",
		defaultButtonSelectors: ["a.btn"],
		captchaButtonSubmitSelector: ["input[type='submit']"],
		allMessageSelectors: [".alert.alert-warning", ".alert.alert-success", ".alert.alert-danger", "#cf-error-details"],
		successMessageSelectors: [".alert.alert-success"],
		messagesToCheckBeforeMovingToNextUrl: ["invalid", "sufficient", "you have reached", "tomorrow", "wrong order", "locked", "was sent to your", "You have to wait", "Login not valid", "You have already claimed", "claimed successfully", "Claim not Valid", "rate limited"],
		ablinks: true,

	},

	];

	var ablinksSolved = false;

	//HtmlEvents dispatcher
	function triggerEvent(el, type) {
		try {
			var e = document.createEvent('HTMLEvents');
			e.initEvent(type, false, true);
			el.dispatchEvent(e);
		} catch (exception) {
			console.log(exception);
		}
	}

	//Check if a string is present in Array
	String.prototype.includesOneOf = function(arrayOfStrings) {

		//If this is not an Array, compare it as a String
		if (!Array.isArray(arrayOfStrings)) {
			return this.toLowerCase().includes(arrayOfStrings.toLowerCase());
		}

		for (var i = 0; i < arrayOfStrings.length; i++) {
			if (this.toLowerCase().includes(arrayOfStrings[i].toLowerCase())) {
				return true;
			}
		}
		return false;
	}

	var websiteDataValues = {};

	//Get selector details from the websiteMap
	for (let value of Object.values(websiteMap)) {
		if (window.location.href.includesOneOf(value.website)) {
			websiteDataValues.inputTextSelector = value.inputTextSelector;
			websiteDataValues.inputTextSelectorButton = value.inputTextSelectorButton;
			websiteDataValues.defaultButtonSelectors = value.defaultButtonSelectors;
			websiteDataValues.claimButtonSelectors = value.claimButtonSelectors;
			websiteDataValues.captchaButtonSubmitSelector = value.captchaButtonSubmitSelector;
			websiteDataValues.allMessageSelectors = value.allMessageSelectors;
			websiteDataValues.messagesToCheckBeforeMovingToNextUrl = value.messagesToCheckBeforeMovingToNextUrl;
			websiteDataValues.withdrawPageUrl = value.withdrawPageUrl;
			websiteDataValues.withdrawEnabled = value.withdrawEnabled;
			websiteDataValues.balanceSelector = value.balanceSelector;
			websiteDataValues.withdrawMinAmount = value.withdrawMinAmount;
			websiteDataValues.successMessageSelectors = value.successMessageSelectors;
			websiteDataValues.additionalFunctions = value.additionalFunctions;
			websiteDataValues.timeoutbeforeMovingToNextUrl = value.timeoutbeforeMovingToNextUrl;
			websiteDataValues.formSubmit = value.formSubmit;
			websiteDataValues.ablinks = value.ablinks;
			break;
		}
	}

	//Identify which coin to input, based on the url input
	//If the URL does not contain the coin, then use the default from the domain name
	var count = 0;
	var addressAssigned = false;
	for (let value of Object.values(websiteData)) {
		count = count + 1;
		if (value.url.includes(window.location.hostname) && (window.location.href.includes("/" + value.coin + "/") ||
			window.location.href.includes("/" + value.coin + "-") ||
			window.location.href.endsWith("/" + value.coin))) {
			websiteDataValues.address = value.address;
			addressAssigned = true;
			break;
		}
	}

	//If URL does not have coin, check the default from the domain name
	if (!addressAssigned) {
		count = 0;
		for (let value of Object.values(websiteData)) {
			count = count + 1;

			if (value.url.includes(window.location.hostname)) {
				if (value.regex) {
					if (GM_getValue("UrlRegex")) {
						if (GM_getValue("UrlRegex") == value.regex) {
							websiteDataValues.address = value.address;
							break;
						}
					} else {
						GM_setValue("UrlRegex", value.regex);
						websiteDataValues.address = value.address;
						break;
					}

				} else {
					websiteDataValues.address = value.address;
					break;
				}
			}
		}
	}



	//Get the next Url from the website data map
	async function getNextUrl() {

		//Go to the beginning if the end of the array is reached
		if (count >= websiteData.length) {
			count = 0;
		}

		websiteDataValues.nextUrl = websiteData[count].url;
		websiteDataValues.regex = websiteData[count].regex;

		//Ping Test to check if a website is up before proceeding to next url
		pingTest(websiteDataValues.nextUrl);
	}

	var isNextUrlReachable = false;
	//Get the next Url from the website
	function pingTest(websiteUrl) {
		console.log(websiteUrl);
		GM_xmlhttpRequest({
			method: "GET",
			url: websiteUrl,
			headers: {
				"Content-Type": "application/x-www-form-urlencoded"
			},
			timeout: 2000,
			onload: function(response) {
				//Website is reachable
				if (response && response.status == 200) {
					isNextUrlReachable = true;
				} else {
					count = count + 1;
					getNextUrl();
				}
			},
			onerror: function(e) {
				count = count + 1;
				getNextUrl();
			},
			ontimeout: function() {
				count = count + 1;
				getNextUrl();
			},
		});

	}


	async function delay(ms) {
		return new Promise(resolve => setTimeout(resolve, ms))
	}


	var movingToNextUrl = false;
	async function goToNextUrl() {
		if (!movingToNextUrl) {
			movingToNextUrl = true;
			getNextUrl();
			while (!isNextUrlReachable) {
				await delay(2000);
			}

			if (websiteDataValues.regex) {
				GM_setValue("UrlRegex", websiteDataValues.regex);
			}
			window.location.href = websiteDataValues.nextUrl;
			movingToNextUrl = true;
		}
	}

	async function goToWithdrawPage() {
		if (!movingToNextUrl) {
			movingToNextUrl = true;
			window.location.href = websiteDataValues.withdrawPageUrl;
		}

	}


	//Default Setting: After 180 seconds go to next Url
	var delayBeforeMovingToNextUrl = 100000;
	if (websiteDataValues.timeoutbeforeMovingToNextUrl) {
		delayBeforeMovingToNextUrl = websiteDataValues.timeoutbeforeMovingToNextUrl;
	}

	setTimeout(function() {
		movingToNextUrl = false;
		goToNextUrl();
	}, delayBeforeMovingToNextUrl);


	//Move to next URL if address is not mentioned above
	if (window.location.href.includes("to=FaucetPay") || (websiteDataValues.address) && (websiteDataValues.address.length < 5 || websiteDataValues.address.includes("YOUR_"))) {
		goToNextUrl();
	}

	//Returns true if message selectors are present
	function messageSelectorsPresent() {
		if (websiteDataValues.allMessageSelectors) {
			for (var j = 0; j < websiteDataValues.allMessageSelectors.length; j++) {
				for (var k = 0; k < document.querySelectorAll(websiteDataValues.allMessageSelectors[j]).length; k++) {
					if (document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k] &&
						(document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k].innerText.includesOneOf(websiteDataValues.messagesToCheckBeforeMovingToNextUrl) ||
							(document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k].value &&
								document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k].value.includesOneOf(websiteDataValues.messagesToCheckBeforeMovingToNextUrl)))) {
						return true;
					}
				}
			}
		}
		return false;
	}

	//Returns true if any message is present in message selector
	function checkMessageSelectorsLength() {
		if (websiteDataValues.allMessageSelectors) {
			for (var j = 0; j < websiteDataValues.allMessageSelectors.length; j++) {
				for (var k = 0; k < document.querySelectorAll(websiteDataValues.allMessageSelectors[j]).length; k++) {
					if (document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k] &&
						(document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k].innerText.length > 0) ||
						(document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k].value &&
							document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k].value.length > 0)) {
						return true;
					}
				}
			}
		}
		return false;
	}

	//Returns true if message selectors are present
	function successMessageSelectorsPresent() {
		if (websiteDataValues.successMessageSelectors) {
			for (var j = 0; j < websiteDataValues.successMessageSelectors.length; j++) {
				for (var k = 0; k < document.querySelectorAll(websiteDataValues.successMessageSelectors[j]).length; k++) {
					if (document.querySelectorAll(websiteDataValues.successMessageSelectors[j])[k] && document.querySelectorAll(websiteDataValues.successMessageSelectors[j])[k].innerText.includesOneOf(websiteDataValues.messagesToCheckBeforeMovingToNextUrl)) {
						return true;
					}
				}
			}
		}
		return false;
	}


	function ablinksCaptcha() {

		setInterval(function() {

			if (document.querySelector("#switch") && document.querySelector("#switch").innerText.toLowerCase().includes("hcaptcha")) {
				document.querySelector("#switch").click();
			} else if (document.querySelector("#switch") && document.querySelector("#switch").innerText.toLowerCase().includes("recaptcha")) {
				document.querySelector("#switch").click();
			}
			var count = 0;

			var abModels = [".modal-content [href='/']", ".modal-body [href='/']", ".antibotlinks [href='/']"];
			var abModelsImg = [".modal-content [href='/'] img", ".modal-body [href='/'] img", ".antibotlinks [href='/'] img"];
			for (let j = 0; j < abModelsImg.length; j++) {
				if (document.querySelector(abModelsImg[j]) &&
					document.querySelector(abModelsImg[j]).value == "####") {
					goToNextUrl();
					break;
				}
			}

			for (let i = 0; i < 4; i++) {
				for (let j = 0; j < abModels.length; j++) {
					if (document.querySelectorAll(abModelsImg[j]).length == 4 &&
						document.querySelectorAll(abModels[j])[i] &&
						document.querySelectorAll(abModels[j])[i].style &&
						document.querySelectorAll(abModels[j])[i].style.display == 'none') {
						count++;
						break;
					}
				}
			}
			if (count == 4) {
				ablinksSolved = true;
			}
		}, 2000);

	}


	setTimeout(function() {

		ablinksCaptcha();


		if (window.name == "nextWindowUrl") {
			window.name = "";
			goToNextUrl();
			return;
		} else {
			window.name = window.location.href;
		}


		if (websiteDataValues.additionalFunctions) {
			websiteDataValues.additionalFunctions();
		}

		if (websiteDataValues.withdrawEnabled) {
			if (websiteDataValues.balanceSelector && document.querySelector(websiteDataValues.balanceSelector)) {
				var currentBalance = document.querySelector(websiteDataValues.balanceSelector).innerText;
				if (currentBalance > websiteDataValues.withdrawMinAmount && !window.location.href.includes(websiteDataValues.withdrawPageUrl)) {
					goToWithdrawPage();
				}

			} else {
				if (successMessageSelectorsPresent()) {
					goToWithdrawPage();
				}
			}
		}


		if (!movingToNextUrl && messageSelectorsPresent()) {
			goToNextUrl();
		}



		if (!movingToNextUrl && document.querySelector(websiteDataValues.inputTextSelector)) {
			document.querySelector(websiteDataValues.inputTextSelector).value = websiteDataValues.address;
			triggerEvent(document.querySelector(websiteDataValues.inputTextSelector), 'keypress');
			triggerEvent(document.querySelector(websiteDataValues.inputTextSelector), 'change');
			setTimeout(function() {
				if (websiteDataValues.inputTextSelectorButton && document.querySelector(websiteDataValues.inputTextSelectorButton)) {
					document.querySelector(websiteDataValues.inputTextSelectorButton).click();
				}

			}, 2000);
		}


		if (!movingToNextUrl && websiteDataValues.defaultButtonSelectors) {
			for (let i = 0; i < websiteDataValues.defaultButtonSelectors.length; i++) {
				if (document.querySelector(websiteDataValues.defaultButtonSelectors[i])) {
					triggerEvent(document.querySelector(websiteDataValues.defaultButtonSelectors[i]), 'mousedown');
					triggerEvent(document.querySelector(websiteDataValues.defaultButtonSelectors[i]), 'mouseup');
					document.querySelector(websiteDataValues.defaultButtonSelectors[i]).click();
					break;
				}
			}
		}

		setTimeout(function() {
			if (!movingToNextUrl && websiteDataValues.claimButtonSelectors) {
				for (let i = 0; i < websiteDataValues.claimButtonSelectors.length; i++) {
					if (document.querySelector(websiteDataValues.claimButtonSelectors[i])) {
						triggerEvent(document.querySelector(websiteDataValues.claimButtonSelectors[i]), 'mousedown');
						triggerEvent(document.querySelector(websiteDataValues.claimButtonSelectors[i]), 'mouseup');
						document.querySelector(websiteDataValues.claimButtonSelectors[i]).click();
						break;
					}
				}
			}
		}, 2000);




		var clicked = false;
		var captchaInterval = setInterval(function() {

			if (websiteDataValues.ablinks && !ablinksSolved) {
				return;
			}

			try {
				if (!clicked && unsafeWindow.grecaptcha && unsafeWindow.grecaptcha.getResponse().length > 0 &&
					websiteDataValues.captchaButtonSubmitSelector && document.querySelector(websiteDataValues.captchaButtonSubmitSelector) &&
					document.querySelector(websiteDataValues.captchaButtonSubmitSelector).style.display != 'none' &&
					!document.querySelector(websiteDataValues.captchaButtonSubmitSelector).disabled) {
					if (websiteDataValues.formSubmit) {
						document.querySelector(websiteDataValues.captchaButtonSubmitSelector).submit();
					} else {
						document.querySelector(websiteDataValues.captchaButtonSubmitSelector).click();
					}
					clicked = true;

					clearInterval(captchaInterval);
					setTimeout(function() {
						if (messageSelectorsPresent()) {
							goToNextUrl();
						}
					}, 20000);
				}
			} catch (e) {

			}

			for (var hc = 0; hc < document.querySelectorAll("iframe").length; hc++) {
				if (!clicked && document.querySelectorAll("iframe")[hc] &&
					document.querySelectorAll("iframe")[hc].hasAttribute("data-hcaptcha-response") &&
					document.querySelectorAll("iframe")[hc].getAttribute("data-hcaptcha-response").length > 0 &&
					websiteDataValues.captchaButtonSubmitSelector && document.querySelector(websiteDataValues.captchaButtonSubmitSelector) &&
					document.querySelector(websiteDataValues.captchaButtonSubmitSelector).style.display != 'none' &&
					!document.querySelector(websiteDataValues.captchaButtonSubmitSelector).disabled) {
					if (websiteDataValues.formSubmit) {
						document.querySelector(websiteDataValues.captchaButtonSubmitSelector).submit();
					} else {
						document.querySelector(websiteDataValues.captchaButtonSubmitSelector).click();
					}
					clicked = true;
					clearInterval(captchaInterval);
					setTimeout(function() {
						if (messageSelectorsPresent()) {
							goToNextUrl();
						}
					}, 2000);
				}
			}
		}, 2000);
	}, 2000);

})();