Sorry, I didn't modify your capx, it's too complex.
Oh I forgot to specify.
I actually wanted one end to be grounded while the other one moves. That was the challenging part.
I imagine it'll take something like 2 loops constantly following the moving chain while the "grounded" end "tugs back" at the same rate when max distance is exceeded.
Speaking of which, I could start there:
RedBox/Greenbox is dragging
Distance Bar greater than or equal to [cumulative lengths of all chain links] | [some code to keep opposite box grounded.]
This was my initial struggle