Hoe can I extend the TypoLink generation Function that every time a TypoLink is being generated it checks for a certain targetpId and then append the id of the current page as a GEt argument. For example:
When a Link on the page with ID 5 targets the page with the ID 19 then add ?ref=5 to the link
I currently don't know where to start, which Class/Method can I try to Override to include this kind of behaviour.
Extending Classes (XCLASSes)
I dont know about TYPO3 9.5 but we did it in 8.7. Here is a snippet about the extended classes we used:
Its not exactly what you are searching for but a good way to start.