JS: Call a function after another without touching the original function?

Viewed 944

I am trying to extend a third party library on a specific page, but I don't want to change any of the third party code. I know the name of the functions the third party library calls when something happens, so if I want my own custom code to execute after that, how can I do that?

Third Party Library has:

function eventFinished(args){
    //library stuff here
}

Now if it was my own code I'd do something like this:

function eventFinished(args){
    //library stuff here
    MyCustomFunction();
}

However, it's not and I don't want to overwrite stock library code. So is there anyway to do the above, but without touching the original function code? I would have a reference to the function itself, but that's it.

EDIT: I should mention the declared function is available globally.

2 Answers
Related