Thanks, Peter! That mostly worked. The script removes the cross-references and converts the cross-reference to text, but it repeats the text. So for example, this:
See “B.15 Valet Mode” on page 187 for more details.
Becomes:
See “B.15 Valet Mode” on page 187“B.15 Valet Mode” on page 187 for more details.
( I added the bold for emphasis.) Is it possible to tweak so the text only appears once?