"Untitled Post" - Views: 27 · Hits: 27 - Type: Public

package Code.egb.com;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Cookie;
import java.util.Date;
import java.util.concurrent.*;
import java.util.regex.Pattern;
public class Code 
{
	static org.openqa.selenium.NoSuchElementException ignore;
	static Integer lost = new Integer (0);
	static String bet = "";
	static Double odds = new Double (1);
	static Integer time = new Integer (0);
	static Integer RiskAmount = new Integer (0);
	static Integer color = new Integer (2);
	static String colour = "";
	static Integer NoE =  new Integer (2);
	static String selectorForEvent;
	static String selectorForBet;

	static String TextTime;
	static WebElement Bet;
	private static WebDriver driver;
	public static void reset ()
	{
		lost = 0;
		odds = 1.0;
		time = 0;
		RiskAmount = 0;
		color = 2;
		NoE = 2;
	}
	public static void CheckForEvent()
	{
		try {
		System.out.println(NoE);
		MakeSelectorForBet();
		Bet = driver.findElement(By.cssSelector(selectorForBet));
	    bet = Bet.getText();
	    colour = Bet.getCssValue("color");
	    System.out.println(colour);
	    System.out.println(driver.findElement(By.xpath("xpath=//span[contains(.,'Live!')]")));
		}
		catch(Exception e)
		{
			NoE=2;
			CheckForEvent();
		}
		if(bet.equals("-")|!colour.equals("rgba(39, 156, 255, 1)"))
		{			
			NoE++;
			CheckForEvent();
		}
	}	

	public static void MakeSelectorForBet()
	{
		selectorForBet = ".table-bets__main-row:nth-child("+NoE.toString()+") .table-bets__col-1 .bet-rate";
	}

	public static void OpenWithCookies()
	{
		driver = new ChromeDriver();
		InjectCookie();
		driver.get("https://egb.com/play/simple_bets");
        driver.manage().window().maximize();
	    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
	    
	    CheckForEvent();
		System.out.println(NoE);
	    System.out.println(Bet.getText());
	    odds = Double.parseDouble(Bet.getText());	    //System.out.println(odds);
	    System.out.println("Found suitable event under number "+(NoE-1) +" with odds "+odds);
	    
	    JavascriptExecutor js = (JavascriptExecutor) driver;
	    String scroll = "window.scrollBy(0,"+NoE*50+")";
	    js.executeScript(scroll);
	    System.out.println("Scrolling...");
	    Bet.click();

	    WebElement Time = driver.findElement(By.cssSelector(".match-details__item-time-left"));
	    TextTime = Time.getText();//	    System.out.println(TextTime);
	    Pattern ptn = Pattern.compile(":");
	    String[] parts = ptn.split(TextTime);
        for(int i = 0;i<parts.length;i++)
        {
        	System.out.println(parts[i]);
            if(i==0) 
            	{time += Integer.parseInt(parts[i])*3600;}
            if(i==1)
            {time+= Integer.parseInt(parts[i])*60;}
            if(i==2)
            {time+=Integer.parseInt(parts[i]);}
            
        }//	    System.out.println(time);
	}
	public static void Increase()
	{
		WebElement IncreaseButton = driver.findElement(By.cssSelector(".field-number__increase"));
		while((odds*RiskAmount)<=(lost+RiskAmount))
		{
			IncreaseButton.click();
			RiskAmount++;
		}
	    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
		System.out.println("risking "+RiskAmount);
		
	}
	public static void MakeBet()
	{	    
		try
		{
		driver.findElement(By.cssSelector(".match-details__place-bet")).click();
		driver.findElement(By.cssSelector(".modal-popup-content__submit-row > .btn:nth-child(2)")).click();
//		driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
//    	driver.findElement(By.cssSelector(".modal-popup-content__submit-row_alert > .btn")).click();
		driver.quit();
		}
		catch(Exception e)
		{
			driver.quit();		
			odds = 1.0;
			time = 0;
			RiskAmount = 0;
			color = 2;
			NoE = 2;
			OpenWithCookies();
    		driver.findElement(By.cssSelector(".tabs__link--popup:nth-child(2)")).click();//Playmoney
    		Increase();
    		MakeBet();
		}
    }
	public static void Wait()
	{
		try 
		{
			System.out.println("Waiting for "+TextTime+" for event to start.");
			System.out.println(time);
			Thread.sleep(time*1000);
			System.out.println("Event started.");
		} 
		catch(InterruptedException e) 
		{
			System.out.println("Waiting failed...");
		}
	}
	public static void InjectCookie() 
	{
		driver.get("https://egb.com/");
		driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
		driver.manage().addCookie(new Cookie("__cfduid", "d0f6a3b3b27eab8f6ca06395b8e7603151536996974", ".egb.com", "/", new Date (2019, 9, 15, 10, 36, 15), false, true));
		driver.manage().addCookie(new Cookie("__cfduid", "dc4856a662bd7684cdbec10283b37f9081536996976", ".egbcdn.net", "/", new Date (2019, 9, 15, 10, 36, 16), false, true));
		driver.manage().addCookie(new Cookie("__zlcmid", "oPhdy6JXM8KKv5", ".egb.com", "/", new Date (2020, 4, 25, 9, 21, 32), false, false));
		driver.manage().addCookie(new Cookie("_ga", "GA1.2.1505928688.1540699283", ".egb.com", "/", new Date (2021, 4, 17, 4, 36, 10), false, false));
		driver.manage().addCookie(new Cookie("__zlcprivacy", "1", ".egb.com", "/", new Date (2019, 11, 16, 20, 11, 35), false, false));
		driver.manage().addCookie(new Cookie("_egb_session", "UlA5Wm9VQzZ4NWo2Tm1tV1I4YTRtczArVzlqU3cxM1o4OHJLejlsSGcvKzF5Q2xxcW9WODhOdnNxOFhWQXdGR0ZSM3M0Q2dwZTBMSFVpV2NpbFZqTm9IMEVmTDRZTlRoejhHOS9rMXFDTnBWMzBSNVBIMWpiN3VqNk5SRkpreGFicnV2WEc2Q2JLWkxqejhXZEtrMTlOL2EybGNWdjVlYWdWMjJhN2VkZUFkOXFQcFI5eFRCM0NlVTJlTFAyNkRrM0Z2VVZiLzZlN0dlZHdxTU95Qlc1cG5Pd0l4ZUhkV1ZwemhaeitJQnh4KzN2T2E3MEQvNENRWWlkTGxwdFpMdlNiKzNURVJqWFJRQTNYN0Q0Y1ZGTVE9PS0tZ3JTcEF4WHBaOUlNWmpFQVprOXZtdz09--4434fba7433cc9cc4d092a99d3444e26e4cd2c1f", "egb.com", "/", new Date (2019, 5, 26, 9, 47, 36), false, true));
		driver.manage().addCookie(new Cookie("cloudflare_uid", "7yysnxMFPFPv1fgnEUUV5tVgtFUMem56pvx19UCv", "egb.com", "/", new Date (2039, 4, 26, 9, 53, 03), false, false));
		driver.manage().addCookie(new Cookie("cookies_policy", "1", "egb.com", "/", new Date (2023, 9, 14, 10, 38, 27), false, false));
		driver.manage().addCookie(new Cookie("is_first_time", "0", "egb.com", "/", new Date (2038, 9, 15, 10, 36, 15), false, false));
		driver.manage().addCookie(new Cookie("lang", "en", "egb.com", "/", new Date(2024, 3, 1, 21, 11, 02), false, false));
		driver.manage().addCookie(new Cookie("onlyFutureMatches", "true", "egb.com", "/", new Date (2024, 4, 19, 11, 39, 06), false, false));
		driver.manage().addCookie(new Cookie("chat-menu", "false", "egb.com", "/", new Date (2024, 4, 23, 18, 10, 01), false, false));		
		driver.manage().addCookie(new Cookie("filters", "[]", "egb.com", "/", new Date (2024, 5, 17, 20, 59, 13), false, false));

	}
	public static void Check()
	{
			try {
				driver = new ChromeDriver();
				InjectCookie();
				driver.get("https://egb.com/");
				driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
				driver.manage().window().maximize();
				driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
				driver.findElement(By.cssSelector(".user__name")).click();
				driver.findElement(By.cssSelector(".user-menu > .user-nav:nth-child(2) > .user-nav__item:nth-child(2) > span:nth-child(2)")).click();
				WebElement Bet = driver.findElement(By.cssSelector("#mySimpleBets > div.table-my-bets.js-table > div:nth-child(2)"));
				String colour = Bet.getCssValue("color");
				if(colour.equals("rgba(252, 93, 93, 1)")){color = 0;System.out.println("Recognized lost, increasing risk...");};
				if(colour.equals("rgba(31, 203, 99, 1)")){color = 1;System.out.println("Recognized won, starting new cycle...");}
//				System.out.println(colour);
				driver.quit();
			}
			catch(org.openqa.selenium.NoSuchElementException ignoreT)
			{
				driver.quit();
				Check();
			}
	}
	public static void Calculate()
	{
		if(color == 1){reset();}
	    else
	    {
	    	lost+=RiskAmount; System.out.println(lost);
	    	RiskAmount = 0;
	    	color=2;
	    }
	}
	public static void loop()
	{
	    	try
	    	{
	    		OpenWithCookies();
	    		System.out.println("Opened cycle.");
	    		driver.findElement(By.cssSelector(".tabs__link--popup:nth-child(2)")).click(); //Playmoney
	    		Increase();
	    		MakeBet();
	    		System.out.println("Made bet. Quitting driver");
	    	    driver.quit();
    			Wait();
	    		while(color == 2)
	    			{
	    			try 
	    			{
	    				System.out.println("Waiting event calculation.");
	    				Thread.sleep(900000);
	    			} 
	    				catch(InterruptedException e) 
	    				{
	    					System.out.println("Waiting failed...");
	    				}
			    	System.out.println("Waited 15 minutes, cheking.");
	    			Check();
	    			}
	    		Calculate();
	    	}
	    	catch(Exception t)
	    	{
	    			{driver.quit();System.out.println(t);}
	    			loop();
	    	}
	    	loop();
	}
	public static void main(String[] args)
	  {
		System.setProperty("webdriver.chrome.driver", "C:\\Users\\airna\\Downloads\\chromedriver_win32.74\\chromedriver.exe");
	    loop();
	  }
}