How to disable autofocus on input fields in Chrome?

06
2014-04
  • Anton

    Is is possible in general to make Chrome not to focus on any of the fields automatically, for example, after the page has been loaded?

    Extensions that use keys on keyboard don't work well with autofocus and type instead of executing commands.

  • Answers
  • ComFreek

    I've just written script for you:

    // ==UserScript==
    // @name           Disable auto-focussing
    // @author         ComFreek <comfreek at the following domain 'outlook' with the TLD 'com'>
    // @description    Disable auto-focussing
    // @include *
    // @version        1.0
    // ==/UserScript==
    
    var maxTime = 3000;
    var timeoutInterval = 5;
    
    var usedTime = 0;
    var isManualFocus = false;
    function check() {
        if (!isManualFocus && document.activeElement.tagName.toLowerCase() == "input") {
            console.log("BLURRED");
            document.activeElement.blur();
        }
        usedTime += timeoutInterval;
        if (usedTime < maxTime) {
            window.setTimeout(check, timeoutInterval);
        }
    }
    check();
    
    
    document.body.addEventListener("click", function (evt) {
        if (evt.target.tagName == "INPUT") {
            console.log("MANUAL CLICK");
            isManualFocus = true;
        }
    });
    
    document.body.addEventListener("keydown", function (evt) {
        isManualFocus = true;
    });
    

    Warning The script will interfere with the user if he immediately starts typing while the script is still operating. This is fixed.

    Installation (manual method)

    1. Save the script as XX.user.js (XX can be any string, but .user.js is important here!)

    2. Open the extensions page in Chrome (the URI is chrome://extensions/ as of Chrome v31)

    3. Drag the script from the file explorer and drop it over the extensions page.

    4. Confirm the installation

    Installation (TamperMonkey)

    My script should work with TamperMonkey according to OP's comment below. Please consult TamperMonkey's manual for further information on how to install my script.


  • Related Question

    Is there a Google Chrome extension or userscript that will "bottom-justify" form fields?
  • Dennis Williamson

    When using Google Chrome, I would like to have a page scroll up so the bottom of form fields are at or above the bottom of the window when I click in the text input to begin entering something. However, if the form height is larger than the window, the top should not be scrolled off automatically.

    I want to go from:

    Input Form

    to:

    Expanded Input Form

    An bonus essential feature would be for the input box to automatically be resized in height (but not width) to fill the window. This feature ideally would be configurable: enable/disable and margin above and below.

    Another idea would be to add a "maximize/restore" button to the field so it could be done with one click (rather than automatically upon focus).

    There should be no scrolling or resizing for one-line input boxes.

    Is there an extension or userscript that does something like this?


  • Related Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.