Need to change a global variable string over IP php js

I need to change a specific string, for example in all similar links:

And I need to change “XXX.XXX” .00.00 within the link for the first 6 numbers of the user’s ip as I do this automatically by php.

Any solution please.