Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Reflection;
- using System.Text;
- using System.Threading;
- using System.Xml;
- using IMLokesh.Extensions;
- using IMLokesh.Http;
- using IMLokesh.RandomUtility;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using ns0;
- using OpenQA.Selenium;
- using OpenQA.Selenium.Chrome;
- using OpenQA.Selenium.Interactions;
- namespace Better_Nike_Bot.Utilities {
- // Token: 0x020000B1 RID: 177
- public static class WebUtilities {
- // Token: 0x060005DC RID: 1500 RVA: 0x0001ED48 File Offset: 0x0001CF48
- public static List < Cookie > GetAllCookies(this CookieContainer cc) {
- List < Cookie > list = new List < Cookie > ();
- Hashtable hashtable = (Hashtable) cc.GetType().InvokeMember("m_domainTable", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField, null, cc, new object[0]);
- foreach(object obj in hashtable.Values) {
- SortedList sortedList = (SortedList) obj.GetType().InvokeMember("m_list", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField, null, obj, new object[0]);
- foreach(object obj2 in sortedList.Values) {
- CookieCollection cookieCollection = (CookieCollection) obj2;
- foreach(object obj3 in cookieCollection) {
- Cookie item = (Cookie) obj3;
- list.Add(item);
- }
- }
- }
- return list;
- }
- // Token: 0x060005DD RID: 1501 RVA: 0x0004BC34 File Offset: 0x00049E34
- public static JObject XmlToJson(this string xml) {
- XmlDocument xmlDocument = new XmlDocument();
- xmlDocument.LoadXml(xml);
- return JObject.Parse(JsonConvert.SerializeXmlNode(xmlDocument));
- }
- // Token: 0x060005DE RID: 1502 RVA: 0x0004BC5C File Offset: 0x00049E5C
- public static string Base64Encode(this string plainText) {
- byte[] bytes = Encoding.UTF8.GetBytes(plainText);
- return Convert.ToBase64String(bytes);
- }
- // Token: 0x060005DF RID: 1503 RVA: 0x0004BC7C File Offset: 0x00049E7C
- public static void SetLocaleChinaCookies(Http http) {
- foreach(string text in new string[] {
- "nike_locale=cn/zh_cn",
- "NIKE_COMMERCE_COUNTRY=CN",
- "NIKE_COMMERCE_LANG_LOCALE=zh_CN",
- "CONSUMERCHOICE=cn/zh_cn"
- }) {
- string[] array2 = text.Split(new char[] {
- '='
- });
- Cookie cookie = new Cookie(array2[0], array2[1]) {
- Secure = true,
- Domain = ".nike.com"
- };
- http.Cookies.Add(new Uri("https://nike.com/join"), cookie);
- }
- }
- // Token: 0x060005E0 RID: 1504 RVA: 0x0004BD20 File Offset: 0x00049F20
- public static void SetLocaleCookies(Http http) {
- string str = "nike_locale={0}/{1}\r\nNIKE_COMMERCE_COUNTRY={2}\r\nNIKE_COMMERCE_LANG_LOCALE={1}\r\nCONSUMERCHOICE={0}/{1}".With(new object[] {
- Delegate905.smethod_0(),
- Delegate879.smethod_0(),
- Delegate677.smethod_0()
- });
- foreach(string text in str.GetLinesArray(true)) {
- string[] array = text.Split(new char[] {
- '='
- });
- Cookie cookie = new Cookie(array[0], array[1]) {
- Secure = true,
- Domain = ".nike.com"
- };
- http.Cookies.Add(new Uri("https://nike.com/join"), cookie);
- }
- }
- // Token: 0x060005E1 RID: 1505 RVA: 0x0004BDD0 File Offset: 0x00049FD0
- public static IWebElement SelectElement(this IWebDriver driver, string selector) {
- IWebElement result = null;
- try {
- result = driver.FindElement(By.CssSelector(selector));
- } catch (Exception) {}
- return result;
- }
- // Token: 0x060005E2 RID: 1506 RVA: 0x0004BE04 File Offset: 0x0004A004
- public static IEnumerable < IWebElement > SelectElements(this IWebDriver driver, string selector) {
- List < IWebElement > result = new List < IWebElement > ();
- try {
- result = driver.FindElements(By.CssSelector(selector)).ToList < IWebElement > ();
- } catch (Exception) {}
- return result;
- }
- // Token: 0x060005E3 RID: 1507 RVA: 0x0004BE40 File Offset: 0x0004A040
- public static void SendKeysWithPause(this IWebElement element, string data, int pause = 10) {
- for(int i = 0; i < data.Length; i++) {
- element.SendKeys(data[i].ToString());
- Thread.Sleep(pause);
- }
- }
- // Token: 0x060005E4 RID: 1508 RVA: 0x0004BE7C File Offset: 0x0004A07C
- public static void SendKeysWithClick(this IWebElement element, IWebDriver driver, string keys, bool randomOffset = true, int maxOffset = 20) {
- Actions actions = new Actions(driver);
- int num = randomOffset ? RandomHelper.RandomInt(0, maxOffset) : 0;
- int num2 = randomOffset ? RandomHelper.RandomInt(0, maxOffset) : 0;
- actions.MoveToElement(element, num, num2).Click().SendKeys(element, keys).Build().Perform();
- }
- // Token: 0x060005E5 RID: 1509 RVA: 0x0004BED0 File Offset: 0x0004A0D0
- public static void SendClickWithMovement(this IWebElement element, IWebDriver driver, bool randomOffset = true, int maxOffset = 5) {
- Actions actions = new Actions(driver);
- int num = randomOffset ? RandomHelper.RandomInt(0, maxOffset) : 0;
- int num2 = randomOffset ? RandomHelper.RandomInt(0, maxOffset) : 0;
- actions.MoveToElement(element, num, num2).Click().Build().Perform();
- }
- // Token: 0x060005E6 RID: 1510 RVA: 0x0004BF18 File Offset: 0x0004A118
- public static void MoveTo(this IWebElement element, IWebDriver driver, bool randomOffset = true, int maxOffset = 5) {
- Actions actions = new Actions(driver);
- int num = randomOffset ? RandomHelper.RandomInt(0, maxOffset) : 0;
- int num2 = randomOffset ? RandomHelper.RandomInt(0, maxOffset) : 0;
- actions.MoveToElement(element, num, num2).Build().Perform();
- }
- // Token: 0x060005E7 RID: 1511 RVA: 0x00004DF3 File Offset: 0x00002FF3
- public static void AddRandomElements(this ChromeDriver driver, string selector = "body") {
- driver.ExecuteScript("function getRandomInt(max) {\r\n return Math.floor(Math.random() * Math.floor(max));\r\n }\r\n \r\n for(x=0; x<200;x++) {\r\n var mybnbdiv = document.createElement('div');\r\n var bnb_parent = document.querySelector('SELECTOR');\r\n mybnbdiv.className = 'bnbnike' + getRandomInt(10000);\r\n mybnbdiv.style.width = getRandomInt(50) + 'px';\r\n mybnbdiv.style.height = getRandomInt(50) + 'px';\r\n mybnbdiv.style.display = 'inline-block';\r\n bnb_parent.appendChild(mybnbdiv);\r\n }".Replace("SELECTOR", selector), new object[0]);
- }
- // Token: 0x060005E8 RID: 1512 RVA: 0x0004BF5C File Offset: 0x0004A15C
- public static bool CheckAbck(this IWebDriver driver) {
- IJavaScriptExecutor javaScriptExecutor = (IJavaScriptExecutor) driver;
- string text = ((string) javaScriptExecutor.ExecuteScript("return document.cookie", new object[0])) ? ? "";
- return text.Contains("~0~");
- }
- // Token: 0x060005E9 RID: 1513 RVA: 0x0004BF9C File Offset: 0x0004A19C
- public static string GetAkamaiCookies(this IWebDriver driver) {
- IJavaScriptExecutor javaScriptExecutor = (IJavaScriptExecutor) driver;
- string text = ((string) javaScriptExecutor.ExecuteScript("return document.cookie", new object[0])) ? ? "";
- if(text.Contains("~0~")) {
- return text;
- }
- return "";
- }
- // Token: 0x060005EA RID: 1514 RVA: 0x0004BFE4 File Offset: 0x0004A1E4
- public static void TryClickRandomElement(this IWebDriver driver, IEnumerable < IWebElement > els) {
- try {
- if(els.IsAny < IWebElement > ()) {
- Actions actions = new Actions(driver);
- actions.MoveToElement(els.GetRandom < IWebElement > (), RandomHelper.RandomInt(0, 20), RandomHelper.RandomInt(0, 20)).Click().Build().Perform();
- }
- } catch (Exception) {}
- }
- // Token: 0x060005EB RID: 1515 RVA: 0x0004C040 File Offset: 0x0004A240
- public static void TryRandomContextClick(this IWebDriver driver, int maxBodyOffset = 300) {
- try {
- Actions actions = new Actions(driver);
- actions.MoveToElement(Delegate133.smethod_0(driver, "body"), RandomHelper.RandomInt(0, maxBodyOffset), RandomHelper.RandomInt(0, maxBodyOffset)).ContextClick().SendKeys(Keys.Alt).Build().Perform();
- } catch (Exception) {}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement