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
Hi Rob, Do you know does this kinda thing take days to be fixed?
hey man why does this not work? I got to mfp go to set custom goals and then i drag that link onto the url area and it just says this webpage is not avaialable? i am using chrome please help. thank you i have also installed tamper monkey.
You have two options. #1, drag the blue box to your bookmarks bar (not the address bar) to add the bookmark to your browser, then on the custom goals screen, click the bookmark. #2 install the userscript version in tampermonkey and it will always work without you having to do anything else. userscripts.org seems to be down again, but you can install the userscript here: http://karoshiethos.com/js/MFP_Macro_Fix.user.js
Rob, server appears to be down still. Do I have any other options??
Thank you
See comment above yours. I recommend using FireFox or Chrome, install greasemonkey or tampermonkey, and install the script from here: http://karoshiethos.com/js/MFP_Macro_Fix.user.js
Rob, Thanks for the help, I am sorry for the nagging! Tampermonkey got the job done! I appreciate your work on making MFP a better tool.
ROCK ON!
@scarlette You’re welcome!
Hi! this would be epic, but when i clicked the userscripts, it says this webpage is not available. I tried refreshing it several times but to no avail…help!!! 🙂
Userscripts.org is down (maybe permanently?), install it from here: install the script from here: http://karoshiethos.com/js/MFP_Macro_Fix.user.js
Hi this is awesome!! However, I cant seem to get it to run? Error says the window is undefined 🙁 and that there is a Microsoft JScript runtime error. What am I doing wrong?
H! The script no longer work?!
I am probably totally ignorant but I downloaded tampermonkey, applied the script (it says it’s enabled and shows the MFP script) but nothings is happening.
@kayla @Bruno @holly MFP changed their code again. If you are using the bookmarklet, just clear your cache and try again. If you are using the userscript, you’ll need to upgrade to the latest version (1.4) from here: http://karoshiethos.com/js/MFP_Macro_Fix.user.js
It worked 🙂 Thank you so much!
Hi Rob,
I get a Windows Script Host error stating that line 9, char 1, Window is undefined error when running the script. Any help would be appreciated. I am running this from the custom goals page.
Thanks,
Ray
thanks! it worked
@Ray I just tested in IE9, 10, and 11 with no problems. I released a new version this morning that works with the latest version of the Goals screen which was updated yesterday. Try clearing your cache to make sure you are loading the latest version.
Does it work for ipad? I made it work on windows but carry more my ipad.
@jorel Yes, it works on iPad. Just add the bookmark to Safari and it should sync across to your iPad. Then you can just activate the bookmark when you are on the custom goals screen.
Hello!
I’ve seen a lot of comments about this wonderful idea, however when i go to MFP’s change of goals, and click on the bookmark, it comes up with the whole script….like the codes and stuff… I can’t add or do anything else… I am using a MacBook on safari…any ideas of what i may be doing wrong?? :/ thank you!
Sol
@sol It sounds like you bookmarked the script itself rather than the bookmarklet. Make sure that you are following the steps in this video: http://youtu.be/SXeCORIgRX0
I swear I have used this before however I am trying to change my macros (on an iMac) and none of the links are working. I have tried in Chrome and Fire Fox.
The enhancements button is taking me to a blank page.
Wish MFP would just upgrade their coding and make life easier for all their users.
@emma, make sure you are following the instructions in this video: http://youtu.be/SXeCORIgRX0
Thanks alot.
Hey Rob, I’m having some issues with dragging the “MyFitnessPal Macros Enhancements” button to my bookmarks bar in both safari and in chrome. I attempt to drag on both browsers and nothing happens on either. Even when I right click on the link in chrome, it gives me no option to save as a bookmark. I’m on a mac and using up to date safari and chrome. Any ideas? I’ve watched the video and i’m doing exactly what you are doing. Any help would be appreciated. thanks.
@william I think that the “Share This” plugin was doing some bad things. I disabled it and the link dragging seems more responsive now. Please refresh and give it a try. You should be able to just drag the link up to your bookmarks bar.
Hey again Rob. thanks for the quick response and it seems to be working just fine after the fix. thanks again.
Hello, It doesnt seem to want to change my percentages, i downloaded the tampermonkey and everything, could you please help?
@marieta If you follow the instructions it will work. Install Tampermonkey, then click this link: http://karoshiethos.com/js/MFP_Macro_Fix.user.js , which will open a Tampermonkey confirmation screen, then click the “Install” button. That’s all there is to it.
Hey Rob ! Thanks heaps it works!
Only question is i have realised when i goto tommorows date the updated macros shows altough it still doesn’t show on my ‘goals’ tab (on my phone Samsung s4)
Hey Rob!
It worked thanks heaps,
Only question is i have realised that when i goto tommorow the new updated macros are shown, but in the ‘goals’ tab it still doesn’t show my exact numbers just the previous set, on my Samsung s4.
@Ro The script only alters the goals page in the desktop browser, the mobile apps still work the same way. If you reset your goals from the app, they will be saved in the 5% increments.
I ackowledge the script alters the goals page, so there isn’t any way to get the 1% increments showing on the mobile app? (i do realise that new changed 1% increments are present within the daily nutrition, just not when i click ‘goals’ on mobile app)
@ro Not on the goals screen. The nutrition screens should show you the correct values. All the script does is allow you to save more precise percentages.
Yep exactly what i needed! Too bad that it doesn’t show up on goals screen but that’s all good.
Thanks man! Subbed to your Youtube channel!
Could you leave your e-mail down for any further changed for a quick contact
Sure, you can find me on Twitter at @robruchte or email me at rob.ruchte@gmail.com
I cannot get the changed goals to update with my mobile app
@stevie Try manually syncing, or shutting the app down and restating.
Thanks, great script.
Was unable to load it with Opera (12)’s userscript stuff at first, but changing the URL to the exact link instead of regexp helped. 🙂
Can you program this to calculate NET carbs for the day – and reflect it in the pie chart? That would be wonderful!
@Celia Sadly no, this is just a hack to accurately set Protein/Fat/Carbs goals.
Thanks for this!!!
Hey ..
I get this error message when I try to change my makros using you script :/
There was a problem with your request
Sorry, but a server error occurred processing your request. Our team has been notified of the issue
@MM89 I’m not seeing that.
Sorry, I figured out…
I needed to change from my own language to English 😛
I just wanted to say thank you so much! that was so easy and the video really helpful. truly appreciated.
This is awesome! Thank you so much!
Thanks a lot for this.
[…] you have a MacBook, or use Chrome or Internet Explorer go to This Link and watch the video (it is about half way down the page) and it will show you how to make it work […]
Hiya, think I’m just being thick, but when I enter my macros and press enter it rounds them up or come with the error ‘your marcros have changed since last time you used the bookmarklet’ I’m using firefox I’m I doing something wrong? x