Get colors for each page in InDesign CS5

Here is the problem…

I know how to get all active swatches/colors for a document, but what I need to do is get the active colors for each page in a document. I am also able to get all of the colors for each page using the following script.(And yes I know the return value of the swatch list isn’t “clean” it’s not important here, for my purposes.)

tell document 1 of application “Adobe InDesign CS5”
set SwatchList to {}
set SwatchName to “”
set PageCount to count of every page
repeat with p from 1 to PageCount
set TextFrameCount to count of every page item of page p
repeat with T from 1 to TextFrameCount
tell page item T
try
set SwatchName to name of fill color
end try
copy SwatchName to the end of SwatchList
try
set SwatchName to name of stroke color
end try
copy SwatchName to the end of SwatchList
try
set SwatchName to name of fill color of parent story
end try
copy SwatchName to the end of SwatchList
try
set SwatchName to name of stroke color of parent story
end try
copy SwatchName to the end of SwatchList
end tell
end repeat
set SwatchList to SwatchList as string
display dialog SwatchList
set SwatchList to {}
end repeat
end tell

This is what I need, if I have a linked Illustrator file or Photoshop file I need their color information, whether they are CMYK, spot, etc. This is the end need, I am creating a slug that updates colors for each page, so if there is an easier way to get this information, any help is a appreciated.

This is a script I have in my Scripts palette that copies the list of colors to the clipboard. Using “Inks” instead of swatches or colors seems to work better.

tell application "Adobe InDesign CS4"
	activate
	if (exists document 1) then
		my doIndesignStuff()
	else
		try
			with timeout of 9999 seconds
				display dialog "No document open!" buttons "Cancel" default button "Cancel" giving up after 2
			end timeout
		end try
	end if
end tell

on doIndesignStuff()
	tell application "Adobe InDesign CS4"
		activate
		tell active document
			delete unused swatches
			set theList to (name of every ink whose convert to process is false)
		end tell
		set AppleScript's text item delimiters to return
		set the clipboard to theList as text
		set AppleScript's text item delimiters to ""
		display dialog ("Color list copied to clipboard.") buttons " " giving up after 6
	end tell
end doIndesignStuff

The problem you are going to have is getting inks for each page, instead of the whole document.

How pretty do you need the solution to be? The only thing I can think is to have the script get the number of pages in the document, save it and then repeat through the page numbers opening the document up and deleting all but one page, running the above code, then closing without saving and going on to the next page.

That is admittedly not very convenient or user-friendly.

Hopefully someone else here has a better idea. Anyone?