Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgbink/110d868f471c9dfd2827bce76eaeacd4 to your computer and use it in GitHub Desktop.
Save rgbink/110d868f471c9dfd2827bce76eaeacd4 to your computer and use it in GitHub Desktop.
MyFitnessPal UserScript to AutoFocus on quantity when editing a food entry
// ==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();
}
}
);
}
)();
@rgbink
Copy link
Author

rgbink commented May 17, 2016

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!

ezgif com-video-to-gif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment