JavaScript Bookmarklet for Enhanced Macro Goals in MyFitnessPal
This JavaScript bookmarklet will enhance the macro target section of the custom goal editor in MyFitnessPal with some advanced features that allow you to set up a more complex macro strategy.
Features:
- Set percentages in 1% increments
- Set targets in grams rather than percentage
- Set one of the three macros to automatically fill any remaining calories in your daily goal that are not allocated to the other two macros
- Remember your advanced settings as long as you do not overwrite your changes with the default MFP 5% scheme
Example – Specify protein in grams, fat as a percentage, fill remaining calories with carbs
How To Install The Script
The script is available as a userscript for use in browser extensions like Greasemonkey (for FireFox) and Tampermonkey (for Chrome). Running like this, the fix is always there, even after you update, and you never have to manually run anything. You can install the script here:
http://karoshiethos.com/js/MFP_Macro_Fix.user.js
Internet Explorer and Safari users need to add the bookmarklet below to their bookmarks. When you are on the MyFitnessPal custom goal screen, click on the bookmark, and the form will be enhanced with these features. After you save your changes, the form will revert back to the default 5% increments, but your gram counts will be correct. The mobile apps will display your chosen percentages and grams properly. You will need to click the bookmark each time you want to change your macros.
Internet explorer users, right click the link in the blue box below and click “Add to Favorites”. Safari users, drag the link up to your bookmarks bar.
MyFitnessPal Macro Enhancements
How does it work?
The script is a small JavaScript class that adds components and logic, and integrates with the existing logic in the custom goals screen. When you are finished with your changes and submit the form, the grams for each macro are translated into high-resolution percentages (Example: Carb=44.56666666666666%, Protein=30.533333333333335%, Fat=24.9%), which are saved exactly the same way the default 5% increment percentages would be. MyFitnessPal will round the percentages to the nearest 1% when displaying percentages on the website and in the mobile apps, but they appear to use the high resolution percentages for calculating grams. In my testing, the gram counts always come out as specified.
I’m not sure why this functionality is not already available in MyFitnessPal, I think most users who are serious about their diet probably set up their macros by the gram, or in some combination of grams and percentages.
This is a quick fix I put together in my spare time. It may have bugs. If so, I may or may not fix them. I have tested this in Chrome, Firefox, Safari, and IE10 and 11 – it may not work in IE6, IE4 for Mac, NCSA Mosaic, Lynx, etc. in other words, if you are not running an up to date browser, YMMV. If you need help and your questions are not already answered in the comments, you can find me on Twitter at @robruchte or email me at rob.ruchte@gmail.com
Thank you! Unfortunately had to switch to MFP from a better app so that my friends can track my logs. Cannot believe MFP doesn’t have this function. Although I don’t trust their calculations on anything. Many thanks again
It’s not working after the update for MFP. Any suggestions?
They changed something in their system to lock the percentages down to 5% increments. Party’s over.
With their new pay to macro model this script isn’t working. If you update it please let me know! This script was literally the best thing about MFP.
I just downloaded the latest version of the iOS app and it’s working for me again. Weird.
Hi Rob,
Fix still works on firefox for me. Thanks for making this, even in your spare time! Is there a way to sync the changes to the app for iphone, or will I need to login each time with firefox? I did logout and back in for the app but it’s still showing the 5% increments.
Thank you 🙂
Have you been able to edit macro goals since the update? I can still see my previously set goals on the app, but I can’t edit them by gram anymore on the website…
It’s still showing the custom macros I applied last week in the android app. But today since logging into the browser version, “custom” now of course only allows me to set 5% increments. Changing macros in the android app is also locked to 5%. What do you think?
Editing in the mobile apps has always been limited to 5%, there’s nothing we can do about that. Right now, everything is back to normal for me, I can edit in grams on the website and the changes sync to the iOS app as expected.
There were a few days where I couldn’t save my changes on the website but it seems to be working again.
The changes that you make on the website sync to the mobile apps, but you can only edit your macros in 5% increments in the mobile apps.
It stopped working for me this morning. I suspect they have been testing changes the last few days and this script will no longer work as it conflicts with their premium service that charges to track macros by gram. I took a brief look at their changes and it looks like they are actively trying to externalize their scripts to make it difficult to customize.
As of this afternoon I too cant set my macros to grams, it asks me to get a premium acct and only sets by %5 increments. When someone knows a way to turn the % to grams again, please let me know.
MFP is changing over to a model where you have to pay to set your macros in grams. In a way, it’s a good thing because it will be officially supported and hopefully will include features like different macro profiles for different days, etc. I’m not into getting sued, so I’m not going to try to circumvent their pay model. Let’s hope we finally get some decent support for setting nutrient goals in a logical manner.
This still works for me… mostly. The only thing is that it’s not changing my macro goals to the detailed nutrition schedule (in phone app, android). Everywhere else it shows correct grams for macros. Thanks anyway!
Hi, Steven from MyFitnessPal here. I’ve posted an update here http://community.myfitnesspal.com/en/discussion/10147731/mfp-premium that I hope our IIFYM users will find helpful.
Hi Steven, thank you for the update, it’s really cool that MFP is listening to the users and reaching out like this. Honestly I’ve been expecting a cease and desist letter ever since this little hack became popular, so this is a nice surprise.
Any ideas on how to do this now that the site is updated? I have tried on multiple browsers and nothing seems to work.
@Rob Ruchte: So since it seems you’re free to update the script, I hope you plan to do so. Now please close your eyes and imagine my best “Help me, I’m poor!” impression is included here.
I am trying to figure out how to change my grams of micros. I was able to initially do it a week ago but am unable to now. Any suggestions?
thanks
Another vote for a script update. Honestly it’s the only part of the premium package I’d be interested in, but it’s not worth $10 per month. Steven clearly stated that they’re not against further updates, just security might prevent them from working in the future. I fiddled with the code a bit but was unable to get it working.
I’m having some trouble getting this to work…my phone automatically updated MyFitnessPal app and is a little different. It is now saying you have to upgrade to a premium package to be able to change percentages to macros. I’m not sure if anyone else has had this problem or if I’m just doing something wrong. Any help would be appreciated. Thank you
I’m not paying 40/year just to set custom grams. I pay less for that for the music service I use 6-8 hours a day.
Check out JoyApp. It takes a little while to get used to but you can customize grams, different goals each day, custom meals, etc and I have yet to have a miss on the database. You can even do a quick entry with your macros!
http://www.reddit.com/r/leangains/comments/2vo3pr/leangainsfriendly_macro_planner_and_diet_tracker/
I echo Justin above for another vote to update the script. I’m only interested in the ability to input macros using grams to dial in my Nutrition Goals.
Come on! $10 a month? just for incremental changes. If Rob doesn’t update the script (which doesn’t sound like he will) I will have to find another app to use. Although, I can still track my food its such a pleasure to see my actual numbers in the app. Rob help!
I’m too busy to work on it at the moment, but I’ve taken a look and have an idea of how to do it. Stay tuned.
Hey Rob big fan of this script was wondering if you were going to be able to find time soon to update it so we can all set our macros to grams again? appreciate the hard work thanks again.
haha…. they no longer let you do this… I even tried via firebug…. they want you to pay $9 a month!!!
i dont mind paying a one time fee but $9 a month… a bit overkill…. time to find another app
Try foodfastfit.com on Chrome and you can change your macros to grams again.
Well, I can’t seem to get this to work on Chrome or Firefox any longer. I tried that foodfastfit.com too with no luck on Chrome.
Guess I’ll just deal with the crappy 5% increments for the time being.
Man, they ruined such a great app. Definitely not going Premium just for Macros. I don’t care about any of the other content. Rob, thanks for your efforts on this before UA “broke” it.
Hi! I just tried this on Google Chrome (after trying Safari and Firefox) and it works like a charm! Thanks so much!
Please update the script when you can! I’m a broke college student trying to manage her health and 50 dollars per year is just out of reach for me.
@Zai:
Wow…this actually worked for Chrome users. Watched the video, changed my macros exactly as it said, and it sent the data to the Android app. Thank you. Problem solved.
Thanks in advance for looking at it when you get a chance, Rob. 🙂
Really hoping this is updated eventually.
The add-on worked great for me but now I have to change my macros and I’m not given that option. Any advice?
It doesn’t for me either…BUT…if you purchase the PREMIUM addition it is there….SOOOOO SAD 🙁
@Zai:
this works perfectly, thank you so much!
Thank you soooo much for this! It made my LCHF day and life much easier 🙂
Update this please 🙁 MFP ain’t ripping me off every month for something that I can have for FREE.
is this updated and working yet?
Rob, if you can find the time, I’d love to see this work again! Or let me know what you think the fix is and I’ll hire a developer to help!
Amazing!! Thank you for creating this!!! I’ve only just starting tracking my macros as I was not eating much and my belly fat is still hanging in there 🙁 Hopefully, now I’ll be able to make some progress with reverse dieting. Thanks again! 🙂
I’ve been using this for a while with no problems (thank you its awesome) but now when I try to change my macros I am getting the message “Your macros have changed since last time you used the bookmarklet please reset them and save” and the changes I’ve made aren’t saving. Help somebody!
Im in Australia and the hack stopped working for me but even if I wanted to pay a premium (whish I don’t) its not rolled out internationally yet!! Ggggrrrrrr!!!
They must have updated MFP again because the tampermonkey script completely stopped working for me today. I try to change my macros and I get the message “Your macros have changed since last time you used the bookmarklet please reset them and save.” So frustrating.
I actually think it’s ridiculous that MFP is trying to charge us $10/month to change our macros and other little changes that should be basic functions for the program. I would happily pay a one time fee or something, but there’s no way I’m paying $160/year for a few little features that should be standard.
Appears the hack is working again. Tried last week and wasn’t working. 100% just worked for me : )
MFP have updated the macros page, and you’re now charged a fee to customize your macros. Honestly, this is a joke. Why am I limited to 5% jumps in my macros, is it REALLY that hard to just put the jumps as 1%. No way I am paying $10 just to be able to use 1% jumps in my macros. Oh well, it’s not the end of the world, guess I’ll have to use my brain now to calculate whats left towards the end of the day.