The two solutions offered by @Ciencia are both correct ways to ensure your customisation logic waits until the page has finished loading. This is the standard and only supported way to run such logic, and always has been (since 2011). It has not changed in recent releases.
Given that it does not appear to solve the problem you are experiencing, it is most likely that the problem is not related to parts of the page created by MediaWiki, as those will be ready by then, no exception.
The code pasted at the start of this thread does not appear to make sure of anything MediaWiki-related. It selects elements on the page using plain DOM JavaScript methods, with target IDs that are custom to the local wiki. If these elements don't exist for some reason, it is likely because they are not created by anything on the page. Or maybe you have other customisation code (like a gadget, or something else in your Common.js file) that is creating those links, in which case this is a question of "How do I select an element created by me in JavaScript", for which StackOverflow might be a better place to ask and learn how to do that.
Most likely, your Common.js file is experiencing a "race condition", which means it worked by coincidence in the past and now not any more. (E.g. two asynchronous code paths that are in need for better organising so that they run in the right order).