To use the script you will need to copy the text above into a new blank file by launching the Script Editor app. Don't let the dumb quote marks get smartened because that will cause the script to fail to compile — should be fine if you just copy from your browser to Script Editor. Compile the script by clicking on the hammer icon and it should look like this.

Open your InDesign file and then click the black triangle to run the script.
You should then have the list of colors on your clipboard.
If it does what you want, save the script file and put it in "Macintosh HD:Applications:Adobe InDesign XXXX:Scripts:Scripts Panel" so that you can run it from inside InDesign.
You could add this line to the end of the script to confirm that the list has been created.
display dialog TextOut buttons {"OK"} default button "OK" giving up after 10
This script is very simple (crude) and has no error trapping for, for instance, there being no InDesign file open, but it won't do any harm.
InDesign's scriptability is amazingly powerful by the way!
Hope that helps.