The javascript code in the post just above (Jul 19, 2017) is for a Script Button. You can paste it into the button editor.
See the Script Buttons part of this post for instructions:
What you were doing (putting the script in a .js file and dropping it on the Preferences / Toolbars / Scripts page) would be right for a Script Add-In. But the script above is a more simple thing that lives inside a toolbar button.