I thought at first that this effect would be a marvelous key to take control of anchored object visibility through a character style—and therefore a GREP style rule—but it seems that InDesign has some difficulties in live-updating the state of such ghost items from GREP styles.

Anyway, a ghost item is not actually removed from the layout. It is still valid and available from the scripting space, and many of its properties and methods still work. However its geometric properties and methods become unavailable, and any command that invokes them will cause a runtime error: ghost.geometricBounds, ghost.paths[0].entirePath

So it might be very critical in a script to detect this special state of anchored or inline objects. To identify that a page item is a ghost item without using a try-catch command test, a solution is to check whether the parent character—the anchor—is in an overset zone. This leads to test the existence of a parent text frame:

var isGhost = (myItem.parent instanceof Character) &&

A ridiculously small piece of code, but sometimes useful.