Make WordPress Core

Ticket #35707: 35707.1.patch

File 35707.1.patch, 1.0 KB (added by bookdude13, 7 years ago)

Hide password if autocomplete detected

  • src/wp-admin/install.php

     
    429429wp_print_scripts( $scripts_to_print );
    430430?>
    431431<script type="text/javascript">
     432
    432433jQuery( function( $ ) {
    433434        $( '.hide-if-no-js' ).removeClass( 'hide-if-no-js' );
     435
     436        /* Chrome doesn't respect autocomplete=off, so we need to detect it ourselves.
     437        Luckily a change event is sent. */
     438        let password_field_selector = $( 'input#pass1' );
     439        if ( password_field_selector.length ) {
     440                function autofilled_password() {
     441                        setTimeout( function() {
     442                                $( 'button.wp-hide-pw' ).click();
     443                        }, 200 );
     444                }
     445
     446                password_field_selector.on( 'change', autofilled_password );
     447
     448                /* Only detect the changes right away on page load to catch the Chrome event.
     449                All other changes to the field are ignored. */
     450                var change_timeout = setTimeout( function () {
     451                        password_field_selector.off( 'change', autofilled_password );
     452                }, 200 );
     453        }
     454
    434455} );
    435456</script>
    436457</body>