One small problem though: the script does not distinguish between disabled categories.

When a product is inside a disabled category AND another category which is enabled, the script might choose the disabled category (if it is first). On frontend there will be one breadcrumb missing (because that category is disabled).

Can the script be edited so it skips the disabled category and chooses the first enabled category?