/// <summary> /// Populate DOM with username and passowrd. /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <returns></returns> private async Task <bool> GetFravoriteBrowserWithCreds() { try { this.password = await FavoriteBrowser.InvokeScriptAsync("eval", new string[] { jsQueryPassword }); } catch (Exception ex) { return(false); } bool isAllUserTextIdsTried = false; //string[] strTokensForAllUserTextIds = new string[] { "userid", "userName", "email", "text" }; ; if (!string.IsNullOrEmpty(this.password)) { for (int i = 0; i < this.UserNameType.Length && !isAllUserTextIdsTried; i++) { try { string jsQueryForEvalUsername = String.Format(jsQueryUserName, UserNameType[i]); this.username = await FavoriteBrowser.InvokeScriptAsync("eval", new string[] { jsQueryForEvalUsername }); isAllUserTextIdsTried = true; } catch { } } if (string.IsNullOrEmpty(this.username)) { isAllUserTextIdsTried = false; for (int i = 0; i < this.UserName.Length && !isAllUserTextIdsTried; i++) { try { string jsQueryForEvalUsername = String.Format(jsQueryUserName2, UserName[i]); this.username = await FavoriteBrowser.InvokeScriptAsync("eval", new string[] { jsQueryForEvalUsername }); isAllUserTextIdsTried = true; } catch { } } } } if (!string.IsNullOrEmpty(this.password) && !string.IsNullOrEmpty(this.username)) { return(true); } else { return(false); } }
private async void GetShareContent(DataRequest request) { string[] urls = { "document.location.href;" }; string url = string.Empty; url = await FavoriteBrowser.InvokeScriptAsync("eval", urls); DataPackage requestData = request.Data; requestData.Properties.Title = "Title"; requestData.Properties.Description = ""; // The description is optional. requestData.SetWebLink(new Uri(url)); }
/// <summary> /// Populate DOM with username and passowrd. /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <returns></returns> private async Task <bool> PopulateFravoriteBrowserWithCreds(string userName, string password) { try { string jsQueryForEvalPassword = String.Format(jsQueryPassword + "=\"{0}\"", password); await FavoriteBrowser.InvokeScriptAsync("eval", new string[] { jsQueryForEvalPassword }); } catch (Exception) { return(false); } bool isAllUserTextIdsTried = false; //string[] strTokensForAllUserTextIds = new string[] { "userid", "userName", "email", "text" }; //for (int i = 0; i < strTokensForAllUserTextIds.Length && !isAllUserTextIdsTried; i++) //{ // try // { // string jsQueryForEvalUsername = String.Format(jsQueryUserName + "=\"{1}\"", strTokensForAllUserTextIds[i], userName); // await FavoriteBrowser.InvokeScriptAsync("eval", new string[] { jsQueryForEvalUsername }); // isAllUserTextIdsTried = true; // } // catch // { // if (i == strTokensForAllUserTextIds.Length) // { // return false; // } // } //} for (int i = 0; i < this.UserName.Length && !isAllUserTextIdsTried; i++) { try { string jsQueryForEvalUsername = String.Format(jsQueryUserName2 + "=\"{1}\"", UserName[i], userName); await FavoriteBrowser.InvokeScriptAsync("eval", new string[] { jsQueryForEvalUsername }); isAllUserTextIdsTried = true; } catch { } } if (!isAllUserTextIdsTried) { for (int i = 0; i < this.UserNameType.Length && !isAllUserTextIdsTried; i++) { try { string jsQueryForEvalUsername = String.Format(jsQueryUserName + "=\"{1}\"", UserNameType[i], userName); await FavoriteBrowser.InvokeScriptAsync("eval", new string[] { jsQueryForEvalUsername }); isAllUserTextIdsTried = true; } catch { } } } return(true); }