Last active
May 17, 2016 06:10
-
-
Save rgbink/110d868f471c9dfd2827bce76eaeacd4 to your computer and use it in GitHub Desktop.
MyFitnessPal UserScript to AutoFocus on quantity when editing a food entry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name MyFitnessPal Input Focus | |
// @namespace http://www.rgbink.com/ | |
// @version 0.1 | |
// @author Anthony DeCrescenzo | |
// @match http*://www.myfitnesspal.com/food/diary* | |
// @grant none | |
// @description A script to automatically focus on the quantity input field when editing a food entry. So, if you click to edit a food item, when the popup appears the quantity will be highlighted, ready to be replaced/typed over. | |
// ==/UserScript== | |
(function () | |
{ | |
'use strict'; | |
$('.js-show-edit-food').on('click', function () | |
{ | |
window.setTimeout(focusFunction, 600); | |
function focusFunction() | |
{ | |
$('#food_entry_quantity').focus().select(); | |
} | |
} | |
); | |
} | |
)(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See image for simple explanation. In short the fix is simply to autofocus and select the quantity field when editing a food. Sometimes you might want to do something other than this, but for me 99% of the time I want to adjust the quantity. So… autofocus!