rework #6329 to remove duplicate code and add prevent tab names for showing in ids for scripts that only exist on one tab