public static async Task <Helpers.Cookie[]> GetAndCacheLoversLabCookies(BaseCefBrowser browser, Action <string> updateStatus, CancellationToken cancel) { updateStatus("Please Log Into Lovers Lab"); browser.Address = "https://www.loverslab.com/login"; async Task <bool> CleanAds() { try { await browser.EvaluateJavaScript <string>( "document.querySelectorAll(\".ll_adblock\").forEach(function (itm) { itm.innerHTML = \"\";});"); } catch (Exception ex) { Utils.Error(ex); } return(false); } var cookies = new Helpers.Cookie[0]; while (true) { cancel.ThrowIfCancellationRequested(); await CleanAds(); cookies = (await Helpers.GetCookies("loverslab.com")); if (cookies.FirstOrDefault(c => c.Name == "ips4_member_id") != null) { break; } await Task.Delay(500, cancel); } cookies.ToEcryptedJson("loverslabcookies"); return(cookies); }
public async Task <Helpers.Cookie[]> GetAndCacheCookies(IWebDriver browser, Action <string> updateStatus, CancellationToken cancel) { updateStatus($"Please Log Into {SiteName}"); await browser.NavigateTo(_loginUri); var cookies = new Helpers.Cookie[0]; while (true) { cancel.ThrowIfCancellationRequested(); await WhileWaiting(browser); cookies = (await browser.GetCookies(_cookieDomain)); if (cookies.FirstOrDefault(c => c.Name == _cookieName) != null) { break; } await Task.Delay(500, cancel); } cookies.ToEcryptedJson(_encryptedKeyName); return(cookies); }