예제 #1
0
        public async Task <ILoginResponse> LoginAsync(ILoginRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (WebBrowserNavigator.WebBrowser.Address != ChunithmNetUrl.Top)
            {
                await WebBrowserNavigator.LoadAsync(ChunithmNetUrl.Top);
            }

            await WebBrowserNavigator.EvaluatePageMoveScriptAsync($@"
var inputs = document.getElementsByTagName('input');
var inputName = inputs[0];
var inputPassword = inputs[1];
inputName.value = '{request.SegaId}';
inputPassword.value = '{request.Password}';
formSubmit('sega_login');
");

            var   responseAsync = LoginResponse.CreateResponseAsync(WebBrowserNavigator.WebBrowser);
            await responseAsync;
            var   response = responseAsync.Result;

            if (response.Success)
            {
                var aimeListParser = new AimeListParser();
                response.AimeList = aimeListParser.Parse(response.DocumentText);
            }

            return(response);
        }