Ejemplo n.º 1
0
        internal void VysokaiaTemnitsaScript()
        {
            var application = new MyApplication();
            var commonUrls  = new CommonUrls();
            var difficulty  = new Difficulty();

            if (!FormsStorage.mainProgramForm.GoForTheCasketAndToEndCheckBox.Checked && !FormsStorage.mainProgramForm.GoForTheCasketCheckBox.Checked)
            {
                application.NavigateToUrl(difficulty.ChooseDungeonDifficulty(DungeonName, difficulty.GetDungeonDifficulty()));
                _dungeonButtons.enterInDungeon.WaitElementAndClick();
                _dungeonButtons.startBattle.WaitElementAndClick();
                GoInDungeonForTheItems();
            }
            else if (FormsStorage.mainProgramForm.GoForTheCasketAndToEndCheckBox.Checked == false)
            {
                application.NavigateToUrl(commonUrls.GetQuestUrl(DailyQuestName));
                _questsButtons.findGangButton.WaitElementAndClick();
                _dungeonButtons.enterInDungeon.WaitElementAndClick();
                _dungeonButtons.startBattle.WaitElementAndClick();
                GoInDungeonForTheCasketAndItems();
            }
            else if (FormsStorage.mainProgramForm.GoForTheCasketCheckBox.Checked == false)
            {
                application.NavigateToUrl(commonUrls.GetQuestUrl(DailyQuestName));
                _questsButtons.findGangButton.WaitElementAndClick();
                _dungeonButtons.enterInDungeon.WaitElementAndClick();
                _dungeonButtons.startBattle.WaitElementAndClick();
                GoInDungeonOnlyForTheCasket();
            }
        }
Ejemplo n.º 2
0
 static void AddTokenIfWithsix(HttpClient client, Uri uri, string token)
 {
     if ((token != null) && CommonUrls.IsWithSixUrl(uri))
     {
         client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
     }
 }
Ejemplo n.º 3
0
 bool IRequestHandler.OnBeforeBrowse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request,
                                     bool isRedirect)
 {
     if (!frame.IsMain || CommonUrls.IsWithSixUrl(request.Url) || IsAuthUrl(new Uri(request.Url)))
     {
         return(false);
     }
     OpenInSystemBrowser(request.Url);
     return(true);
 }
Ejemplo n.º 4
0
        internal string ChooseDungeonDifficulty(string dungeonName, DungeonDifficulty difficulty)
        {
            var dungeonUrl = new CommonUrls().GetDungeonUrl(dungeonName);

            dungeonUrl = difficulty.Equals(DungeonDifficulty.Normal) ? dungeonUrl + "/normal" :
                         difficulty.Equals(DungeonDifficulty.Hard) ? dungeonUrl + "/hard" :
                         difficulty.Equals(DungeonDifficulty.Impossible) ? dungeonUrl + "/impossible" :
                         throw new ArgumentException($"Specified complexity ({difficulty}) " +
                                                     "does not match any of the existing ones: 'normal', 'hard', 'impossible'");
            return(dungeonUrl);
        }
Ejemplo n.º 5
0
 void HandleRequestNavigate(object sender, RequestNavigateEventArgs args)
 {
     if (CommonUrls.IsWithSixUrl(args.Uri))
     {
         BrowserHelper.TryOpenUrlIntegrated(args.Uri);
     }
     else
     {
         Tools.Generic.TryOpenUrl(args.Uri);
     }
 }
Ejemplo n.º 6
0
        CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame,
                                                            IRequest request, IRequestCallback callback)
        {
            if (CommonUrls.IsWithSixUrl(request.Url))
            {
                var headers = request.Headers;
                headers[Common.ClientHeader]  = DomainEvilGlobal.SecretData.UserInfo.ClientId.ToString();
                headers[Common.ClientHeaderV] = Common.App.ProductVersion;
                request.Headers = headers;
            }

            return(CefReturnValue.Continue);

            //Example of how to set Referer
            // Same should work when setting any header
            // For this example only set Referer when using our custom scheme
            var url = new Uri(request.Url);

            if (url.Scheme == "customscheme") // CefSharpSchemeHandlerFactory.SchemeName
            {
                var headers = request.Headers;
                headers["Referer"] = "http://google.com";

                request.Headers = headers;
            }

            //NOTE: If you do not wish to implement this method returning false is the default behaviour
            // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.
            //callback.Dispose();
            //return false;

            //NOTE: When executing the callback in an async fashion need to check to see if it's disposed
            if (!callback.IsDisposed)
            {
                using (callback) {
                    if (request.Method == "POST")
                    {
                        using (var postData = request.PostData) {
                            if (postData != null)
                            {
                                var elements = postData.Elements;

                                var charSet = request.GetCharSet();

                                foreach (var element in elements)
                                {
                                    if (element.Type == PostDataElementType.Bytes)
                                    {
                                        var body = element.GetBody(charSet);
                                    }
                                }
                            }
                        }
                    }

                    //Note to Redirect simply set the request Url
                    //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
                    //{
                    //    request.Url = "https://github.com/";
                    //}

                    //Callback in async fashion
                    //callback.Continue(true);
                    //return CefReturnValue.ContinueAsync;
                }
            }

            return(CefReturnValue.Continue);
        }