The fit-page-boxes-to-selection script fits the document bleed and/or slug area to the the selected item(s) dimensions.
You are working on promotional items customization, creating inserts later printed or sticked on an intended area on a larger support (pen, mug, cap, tee-shirt, calendar, etc.). Your workflow requires you to work with InDesign documents with the page size of the insert but your customers prefer to see a preview of the result on the destination medium. A handy solution is to include in the working document a preview of the destination medium extending beyond the insert, the document page size corresponding to the insert size and the slug area corresponding to the (clearly larger) size of a picture showing a more or less realistic preview of the destination medium, then to generate a pdf with a TrimBox corresponding to the insert and a MediaBox the size of the medium picture, for use in both validation and production.
To help achieve such setup, the "fit-page-boxes-to-selection" script enables you to extend automatically the document bleed and/or slug area to the size of the selected item(s). This area can even extend beyond the 6 in / 152.4 mm limit imposed by the "Document Setup" dialog box.
So for the above example, in an InDesign document with the page size of the promotional insert, you just place in the background a picture of the destination medium in an image frame — thus far larger than the document size, even sometimes extending beyond the pasteboard margins (that you can enlarge within the preferences) — and move this frame so that the intended area of the destination medium matches the document bounds, then use the "fit-page-boxes-to-selection" script to extend the slug area to the bounds of the image frame.