Faucet Collector
  • Documentation
  • Example
  • Empty template
  • Full reference
  • Scripts

Class FaucetScript

usage:

using System;
using FaucetCollector.Script;

//And some comments.
public class MyOwnFaucetScript : FaucetScript
{
}
Namespace: FaucetCollector.Script
Syntax
public class FaucetScript : MarshalByRefObjectInfinite

Fields

AllowNextBlockedRequest

Auto allow the next request that otherwise would be blocked. It will be added as host to the ScriptFilters its allow Rules with Auto=true This can be usefull if a script by default blocks all requests except its base/current host but in case the website would navigate to a shortlink

Declaration
public bool AllowNextBlockedRequest

CheckForPopupsEnabled

Declaration
public bool CheckForPopupsEnabled

ChromeDriverProcessIds

Declaration
public List<int> ChromeDriverProcessIds

ChromeDriverProcessIdsLock

Declaration
public object ChromeDriverProcessIdsLock

ChromeLocation

Declaration
public static string ChromeLocation

ChromeTimeout

The timeout of page loads for Chrome

Declaration
public int ChromeTimeout

CommandTimeout

The timeout of commands send to Chrome

Declaration
public int CommandTimeout

DisableInternalProxy

Disables the use of the internal proxy - will only work if the user didn't enter a proxy server. Setting this to true will not proxy all requests thru FC and will also disable the internal filtering.

Declaration
public bool DisableInternalProxy

Driver

Provides access to the Browser. The methods listed in FaucetScript are easy to use method using the Driver. For the raw methods see: http://bit.ly/2nOuLgT

Declaration
public IWebDriver Driver

FailXPath

Property you need to set in the Start method. See https://faucetcollector.com/docs/index.html#start

You need to fill this property with a XPath that will be used to locate an element by this XPath after the claim is done. If it finds the element it will mark the claim as failed. Use | to speficy multiple XPaths

Declaration
public string FailXPath

FaucetAttempts

Declaration
public int FaucetAttempts

FaucetFailures

Declaration
public int FaucetFailures

FaucetStart

Declaration
public DateTime FaucetStart

IsSuccess

Declaration
public bool IsSuccess

IsTimeout

Declaration
public bool IsTimeout

Name

The name of the faucet script.

Declaration
public string Name

Reload

Set this property to true to reload the page before doing the next attempt.

Declaration
public bool Reload

ScriptFilters

List of filters that can be used to block, allow or proxy specific requests

Declaration
public ProxyFilters ScriptFilters

StoreCookies

Store cookies in a .cookie file after login and try to restore them on the next attempts.

Declaration
public bool StoreCookies

SuccessXPath

Property you need to set in the Start method. See https://faucetcollector.com/docs/index.html#start

You need to fill this property with a XPath that will be used to locate an element by this XPath after the claim is done. If it finds the element it will mark the claim as success. Use | to speficy multiple XPaths

Declaration
public string SuccessXPath

SystemFilters

List of filters that will be loaded from the assets

Declaration
public ProxyFilters SystemFilters

TimerIsCountingUp

If your faucet is using a timer that doesn't do a countdown, but a count up (like the moon faucets) you need to set this property to True.

Declaration
public bool TimerIsCountingUp

Title

The window title of the faucet. Used to identify and close popup windows. For more information check: https://faucetcollector.com/docs/index.html#start

Declaration
public string Title

Url

The Url of the faucet.

Declaration
public string Url

WasPause

Declaration
public bool WasPause

Properties

AssetDirectory

Declaration
public string AssetDirectory { get; }

ChromeDriver

Provides access to the Chrome Driver

Declaration
public ChromeDriver ChromeDriver { get; }

Context

Declaration
public FaucetContext Context { get; set; }

CurrentDirectory

Declaration
public static string CurrentDirectory { get; }

HasAssets

Declaration
public bool HasAssets { get; set; }

PausedUntil

Force the bot into a pause specified in seconds

Declaration
public DateTime? PausedUntil { get; set; }

ScriptId

Declaration
public string ScriptId { get; set; }

Settings

Provides access to the settings of the script. See https://faucetcollector.com/docs/index.html#settings

Declaration
public virtual FaucetSettings Settings { get; set; }

Started

Declaration
public bool Started { get; set; }

Methods

ActivateDefault()

Declaration
public void ActivateDefault()

ActivateFrame(IWebElement)

Declaration
public void ActivateFrame(IWebElement iframe)

ActivateManualSolveWindow()

Declaration
public void ActivateManualSolveWindow()

AddBrowserUrlToFilterAndReload(Boolean)

Will add the current page loaded in the browser to the Allow list and reloads the page Will return true if the rule is added and the reload has been completed. Will return false if the rule was already present.

Declaration
public bool AddBrowserUrlToFilterAndReload(bool deleteLastRule = true)

AddRule(FilterRule)

Adds a new rule on the last position to the filters

Declaration
public void AddRule(FilterRule rule)

AddRuleFirstPosition(FilterRule)

Adds a new rule on the first position to the filters

Declaration
public void AddRuleFirstPosition(FilterRule rule)

AfterCreateDriver()

Method that will be called right after the ChromeDriver is created and right before the first page is loaded

Declaration
public virtual int AfterCreateDriver()

AfterLogin()

Declaration
public virtual int AfterLogin()

AfterSolveCaptcha()

Declaration
public virtual int AfterSolveCaptcha()

AfterSolveFaucet()

Declaration
public virtual int AfterSolveFaucet()

ApplicationIsActivated()

Returns true if the current application has focus, false otherwise

Declaration
public static bool ApplicationIsActivated()

AssetDir(String)

Declaration
public string AssetDir(string category)

AssetLocation(ScriptAsset)

Declaration
public virtual string AssetLocation(ScriptAsset asset)

AssetType(ScriptAsset)

Declaration
public virtual string AssetType(ScriptAsset asset)

AttributeContains(IWebElement, String, String)

Declaration
public bool AttributeContains(IWebElement element, string attribute, string contains)

AttributeNotContains(IWebElement, String, String)

Declaration
public bool AttributeNotContains(IWebElement element, string attribute, string contains)

AutoClickReCaptcha()

Declaration
public virtual bool AutoClickReCaptcha()

BeforeCreateDriver()

Method that will be called right before the ChromeDriver is created

Declaration
public virtual int BeforeCreateDriver()

BeforeLogin()

Declaration
public virtual int BeforeLogin()

BeforeSolveCaptcha()

Declaration
public virtual int BeforeSolveCaptcha()

BeforeSolveFaucet()

Declaration
public virtual int BeforeSolveFaucet()

CheckFaucetResult()

Declaration
public virtual int CheckFaucetResult()

CheckForBrowserFailMessage(Exception)

Declaration
public virtual void CheckForBrowserFailMessage(Exception exception = null)

CheckForPopups(Boolean)

Declaration
public int CheckForPopups(bool waitBeforePopupCheck = true)

CheckTimer()

Most faucets have a timer. With this method you can check if we need to wait before we can do the claim. You can return 0 if everything is fine and we don't have to wait. Everything above 0 means the bot will wait that amount in seconds.

Declaration
public virtual int CheckTimer()

ClaimAttempt()

Registers an Attempt

Declaration
public void ClaimAttempt()

ClaimError()

Marks the claim as a error

Declaration
public void ClaimError()

ClaimFailed()

Marks the claim as a failure

Declaration
public void ClaimFailed()

ClaimStart()

Registers the script as starting

Declaration
public void ClaimStart()

ClaimSuccess()

Marks the claim as a success

Declaration
public void ClaimSuccess()

ClearRules()

Removes all the rules from the filter

Declaration
public void ClearRules()

Click(IWebElement, Boolean)

Clicks on an element.

Declaration
public int Click(IWebElement element, bool waitBeforePopupCheck = true)

CloseWhatsNewTab()

Declaration
public virtual void CloseWhatsNewTab()

CutSolveMediaOverlay(Bitmap)

Declaration
public Bitmap CutSolveMediaOverlay(Bitmap solveMediaOverlay)

DeleteAutoRules()

Removes al the rules that have the Auto property on True

Declaration
public void DeleteAutoRules()

DeleteLastRule()

Removes that rule that was added as last rule

Declaration
public void DeleteLastRule()

Disable()

Disabled the faucet (unchecks the checkbox on the Faucets tab in the bot)

Declaration
public virtual void Disable()

DoGeetest()

Declaration
public virtual int DoGeetest()

DoGeetestV4()

Declaration
public virtual int DoGeetestV4()

DoHCaptcha()

Declaration
public virtual int DoHCaptcha()

DoInit()

Declaration
public virtual int DoInit()

DoLogin()

Declaration
public virtual int DoLogin()

DoReCaptcha()

Declaration
public virtual int DoReCaptcha()

DoSolveCaptcha()

Declaration
public virtual int DoSolveCaptcha()

DoSolveFaucet()

Declaration
public virtual int DoSolveFaucet()

DoSolveImageCaptcha(IWebElement, IWebElement, Bitmap)

Declaration
public virtual int DoSolveImageCaptcha(IWebElement imageElement, IWebElement inputElement, Bitmap image = null)

DoSolveMediaCaptcha(IWebElement)

Declaration
public virtual int DoSolveMediaCaptcha(IWebElement solveMediaInput)

ElementByClass(String, Int32)

Tries to find an element on the website by a class See https://faucetcollector.com/docs/index.html#element-by-class

Declaration
public IWebElement ElementByClass(string className, int timeout = 1)

ElementById(String, Int32)

Tries to find an element on the website by id See https://faucetcollector.com/docs/index.html#element-by-id

Declaration
public IWebElement ElementById(string id, int timeout = 1)

ElementByLinkText(String, Int32)

Tries to find an element on the website by link text See https://faucetcollector.com/docs/index.html#element-by-linktext

Declaration
public IWebElement ElementByLinkText(string linkText, int timeout = 1)

ElementByName(String, Int32)

Tries to find an element on the website by name See https://faucetcollector.com/docs/index.html#element-by-name

Declaration
public IWebElement ElementByName(string id, int timeout = 1)

ElementByXPath(String, Int32)

Tries to find an element on the website by xpath See https://faucetcollector.com/docs/index.html#element-by-xpath

Declaration
public IWebElement ElementByXPath(string id, int timeout = 1)

ElementsByXPath(String, Int32)

Finds all elements on the page that match the XPath and returns them in a list See https://faucetcollector.com/docs/index.html#element-by-xpath

Declaration
public List<IWebElement> ElementsByXPath(string xpath, int timeout = 1)

ErrorCreatingDriver(Exception)

Method that will be called when it failed to create the ChromeDriver. Return false (default) then it will let the script fail and handle the error. Return true it will consider you handled the error and try again soon.

Declaration
public virtual bool ErrorCreatingDriver(Exception exception)

ErrorScript(Exception)

Declaration
public virtual void ErrorScript(Exception exception)

ExecuteAntiFingerprint(IWebDriver)

Declaration
public void ExecuteAntiFingerprint(IWebDriver driver)

ExecuteScript(String, Object[])

Will execute a javascript method on the faucet. If you return something in the javascript you use that result in your script. For example:

ExecuteScript("App.claimCallback();");

You can also use an element as argument for the script. This example clicks on it:

var element = ElementById("some-element");
ExecuteScript("arguments[0].click()", element);

Return some text from the website:

var timerText = Convert.ToString(ExecuteScript("return $('.timer')[0].innerText"));

See https://faucetcollector.com/docs/index.html#executescript

Declaration
public object ExecuteScript(string script, params object[] args)

ExtractToDirectory(ZipArchive, String)

Declaration
public static void ExtractToDirectory(ZipArchive archive, string destinationDirectoryName)

Fail(String, Boolean, Int32, Int32)

Return its a fail. It will Log the message and tells the bot we want to reload the page before the next attempt.

Declaration
public virtual int Fail(string message, bool reload = true, int minSec = 10, int maxSec = 15)

FindElement(By, Int32)

Declaration
public IWebElement FindElement(By by, int timeout = 1)

FindElements(By, Int32)

Declaration
public List<IWebElement> FindElements(By by, int timeout = 1)

FlagCaptchaAsInvalid()

Declaration
public void FlagCaptchaAsInvalid()

GetBaseUrl()

The initial Url that is used to load the script

Declaration
public string GetBaseUrl()

GetBoolSetting(String)

Declaration
public bool GetBoolSetting(string name)

GetBrowserUrl()

Returns the current Url that is in the browser

Declaration
public string GetBrowserUrl()

GetBrowserUrlFilter()

The current loaded hostname in the browser surrounded by * example.com

Declaration
public string GetBrowserUrlFilter()

GetChromeLocation(ILogger)

Declaration
public static string GetChromeLocation(ILogger logger)

GetCookies()

Declaration
public string GetCookies()

GetCurrentUrl()

The current url that is being loaded by GoToUrl

Declaration
public string GetCurrentUrl()

GetDateTimeSetting(String)

Declaration
public DateTime? GetDateTimeSetting(string name)

GetDirectoryLength(String)

Declaration
public long GetDirectoryLength(string path)

GetDoubleSetting(String, Int32, Int32)

Declaration
public double GetDoubleSetting(string name, int defaultValue = 0, int decimals = -1)

GetErrorPageText()

Declaration
public virtual string GetErrorPageText()

GetFaucetWaitTime()

Can be used to return the number of seconds the bot needs to wait before it can make a claim.

Declaration
public virtual int GetFaucetWaitTime()

GetGeetestCaptchaId()

Declaration
public virtual string GetGeetestCaptchaId()

GetGeetestChallenge()

Declaration
public virtual string GetGeetestChallenge()

GetGeetestKey()

Declaration
public virtual string GetGeetestKey()

GetGeetestUrl()

Declaration
public virtual string GetGeetestUrl()

GetGeetestValue(String)

Declaration
public virtual string GetGeetestValue(string key)

GetHCaptchaSiteKey()

Declaration
public virtual string GetHCaptchaSiteKey()

GetHCaptchaUrl()

Declaration
public virtual string GetHCaptchaUrl()

GetIntSetting(String, Int32)

Declaration
public int GetIntSetting(string name, int defaultValue = 0)

GetPassword(String)

Declaration
public string GetPassword(string name)

GetReCaptchaUrl()

Declaration
public virtual string GetReCaptchaUrl()

GetSetting(String)

Declaration
public string GetSetting(string name)

GetSiteKey()

Declaration
public virtual string GetSiteKey()

GetSolveMediaAudio()

Declaration
protected byte[] GetSolveMediaAudio()

GetWaitSetting()

Returns the number of seconds the user wants to wait before doing the next claim. It can be changed by the track/slide component after you click on the faucet in the bot.

Declaration
public int GetWaitSetting()

GoToUrl(String)

Declaration
public void GoToUrl(string url)

HideBrowser()

Declaration
public void HideBrowser()

ImageDifference(Bitmap, Bitmap)

Declaration
public float ImageDifference(Bitmap img1, Bitmap img2)

IsEmptyBitmap(Bitmap)

Declaration
public bool IsEmptyBitmap(Bitmap bmp)

IsLoggedIn()

Declaration
public virtual bool IsLoggedIn()

IsVisible(IWebElement)

Returns if an element is found and visible

Declaration
public bool IsVisible(IWebElement element)

KillTree(Process, TimeSpan)

Declaration
public void KillTree(Process process, TimeSpan timeout)

Log(String, Level, Boolean)

Logs a message in the grid that is on the bottom of the bot

Declaration
public virtual void Log(string msg, Level level = null, bool textBox = true)

ModifyCaptchaServiceParameters(CaptchaService, CaptchaType, Dictionary<String, Object>)

Declaration
public virtual void ModifyCaptchaServiceParameters(CaptchaService captchaService, CaptchaType captchaType, Dictionary<string, object> parameters)

ModifyCaptchaServiceParameters(CaptchaService, CaptchaType, MultipartFormDataContent)

Declaration
public virtual void ModifyCaptchaServiceParameters(CaptchaService captchaService, CaptchaType captchaType, MultipartFormDataContent parameters)

ModifyChromeOptions(ChromeOptions)

Gives the option to change the ChromeOptions right before the ChromeDriver is created

Declaration
public virtual void ModifyChromeOptions(ChromeOptions options)

MoveToElement(IWebElement)

Declaration
public void MoveToElement(IWebElement toElement)

MoveToElement(IWebElement, Int32, Int32)

Declaration
public void MoveToElement(IWebElement toElement, int offsetX, int offsetY)

MoveToElementAndClick(IWebElement, Int32, Int32)

Declaration
public void MoveToElementAndClick(IWebElement toElement, int offsetX, int offsetY)

Notification(String)

Declaration
public virtual void Notification(string message)

OnInterception(String, String)

Declaration
public virtual string OnInterception(string url, string response)

PrepareBitmap(Bitmap)

Declaration
public Bitmap PrepareBitmap(Bitmap original)

Quit()

Declaration
public void Quit()

Random(Int32, Int32)

Returns a random number between min and max value (min is inclusive, max is exclusive)

Declaration
public int Random(int min, int max)

ReadResource(String)

Declaration
public string ReadResource(string name)

RemoveRule(FilterRule)

Removes a specific rule from the filters. Returns true if it did find it.

Declaration
public bool RemoveRule(FilterRule rule)

RemoveRule(String)

Removes the first rule that matches the host. Returns true if it deleted a rule

Declaration
public bool RemoveRule(string host)

RemoveRule(String, FilterAction)

Removes the first rule that matches the host and action. Returns true if it deleted a rule

Declaration
public bool RemoveRule(string host, FilterAction action)

RequestXHR(String)

Declaration
public virtual JToken RequestXHR(string url)

ResizeImage(Image, Size, Boolean)

Declaration
public Bitmap ResizeImage(Image image, Size size, bool preserveAspectRatio = true)

ResolveManual(Image, Boolean, Boolean, Boolean, String)

Declaration
public CaptchaRes ResolveManual(Image image, bool recaptcha = false, bool hcaptcha = false, bool geetestv4 = false, string sitekey = null)

RuleExist(String)

Returns true if there is a rule that matches the host

Declaration
public bool RuleExist(string host)

RuleExist(String, FilterAction)

Returns true if there is a rule that matches the host and action

Declaration
public bool RuleExist(string host, FilterAction action)

SaveCookies(Boolean)

Declaration
public void SaveCookies(bool force = false)

ScrollIntoView(IWebElement)

Will scroll the browser up or down (if needed) to get the element shown

Declaration
public void ScrollIntoView(IWebElement element)

SelectOptionByValue(IWebElement, String)

See https://faucetcollector.com/docs/index.html#selectoptionbyvalue

Declaration
public void SelectOptionByValue(IWebElement element, string value)

SetGeetestResponse(String, String, String)

Declaration
public virtual bool SetGeetestResponse(string challenge, string validate, string seccode)

SetGeetestV4Response(String, String, String, String, String)

Declaration
public virtual bool SetGeetestV4Response(string captchaId, string lotNumber, string passToken, string genTime, string captchaOutput)

SetHCaptchaResponse(String)

Declaration
public virtual bool SetHCaptchaResponse(string response)

SetReCaptchaResponse(String)

Declaration
public virtual bool SetReCaptchaResponse(string response)

SetSetting(String, Object)

Declaration
public void SetSetting(string name, object value)

SetText(IWebElement, String, Boolean)

Updates the text of an element. See https://faucetcollector.com/docs/index.html#settext

Declaration
public int SetText(IWebElement element, string text, bool checkForPopups = true)

ShowBrowser()

Declaration
public void ShowBrowser()

SolveCaptcha()

Declaration
public virtual int SolveCaptcha()

Start()

Declaration
public virtual void Start()

StartInterception(String)

Declaration
public virtual void StartInterception(string url)

StartNewBrowser(ChromeOptions, String)

Declaration
public virtual int StartNewBrowser(ChromeOptions options, string dataDir)

StartNewDriver()

Declaration
public ChromiumDriver StartNewDriver()

StopInterception()

Declaration
public virtual void StopInterception()

TakeScreenshot(CaptchaService, IWebElement, Bitmap, Nullable<Point>)

Declaration
public Bitmap TakeScreenshot(CaptchaService service, IWebElement element, Bitmap previousImage = null, Point? outerLocation = null)

UnZip(String, String)

Declaration
public static string UnZip(string path, string destination)

Wait(Int32)

Let the bot wait a number of seconds. See https://faucetcollector.com/docs/index.html#wait

Declaration
public void Wait(int sec)

Wait(Int32, Int32)

Let the bot wait a random number of seconds See https://faucetcollector.com/docs/index.html#wait

Declaration
public void Wait(int min = 1, int max = 2)

WaitForAttributeContains(IWebElement, String, String, Int32)

Declaration
public bool WaitForAttributeContains(IWebElement element, string attribute, string contains, int timeout = 25)

WaitForAttributeNotContains(IWebElement, String, String, Int32)

Declaration
public bool WaitForAttributeNotContains(IWebElement element, string attribute, string contains, int timeout = 25)

WaitToString(Int32)

Will show a formatted string from the number of seconds you include in it. For example:

var seconds = 100;
Log($"Waiting {WaitToString(seconds)}.");

will log: Waiting 1 minute and 40 seconds.

Declaration
public string WaitToString(int seconds)
Back to top