diff --git a/brozzler/js-templates/try-login.js.j2 b/brozzler/js-templates/try-login.js.j2 index c07a296..66d987e 100644 --- a/brozzler/js-templates/try-login.js.j2 +++ b/brozzler/js-templates/try-login.js.j2 @@ -1,6 +1,12 @@ var __brzl_tryLoginState = 'trying'; var __brzl_tryLogin = function() { + var login_open = document.querySelectorAll("[class^='login-open']"); + for(var x = 0; x < login_open.length; x++){ + button = login_open[x]; + button.click(); + } + for (var i = 0; i < document.forms.length; i++) { var form = document.forms[i]; if (form.method != 'post') { @@ -48,6 +54,38 @@ var __brzl_tryLogin = function() { return; } } + + if(__brzl_tryLoginState === 'trying'){ + var submit = undefined; + var usernameInput = undefined; + var passwordField = undefined; + var login = document.querySelectorAll("[class^='login']"); + + for (var z = 0; z < login.length; z++){ + var input = login[z]; + + if (input.type === "text" || input.type == "email") { + usernameField = input; + } else if (input.type === "password") { + passwordField = input; + } else if(input.onclick != null) { + submit = input; + } else if (input.type == "textarea") { + usernameField = undefined; + passwordField = undefined; + break; + } + } + + if (submit && usernameField && passwordField){ + usernameField.value = {{username|json}}; + passwordField.value = {{password|json}}; + submit.click(); + __brzl_tryLoginState = 'maybe-submitted-form'; + return; + } + } + __brzl_tryLoginState = 'login-form-not-found'; }; diff --git a/setup.py b/setup.py index cad2897..f5d260a 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ ''' setup.py - brozzler setup script -Copyright (C) 2014-2019 Internet Archive +Copyright (C) 2014-2020 Internet Archive Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ def find_package_data(package): setuptools.setup( name='brozzler', - version='1.5.19', + version='1.5.20', description='Distributed web crawling with browsers', url='https://github.com/internetarchive/brozzler', author='Noah Levitt', diff --git a/tests/htdocs/site11/form2.html b/tests/htdocs/site11/form2.html new file mode 100644 index 0000000..9f63d65 --- /dev/null +++ b/tests/htdocs/site11/form2.html @@ -0,0 +1,25 @@ + +
+