I can think of a few possible solutions that could work cross-browser:
Identify the user event that causes the button to be added to the page, hook that event and AFTER that event runs, find the button and update it's text.
Poll your page with an interval timer to find out when the button is added to the page.
If the button is added after a jQuery ajax operation and you can't modify the actual code that does that ajax work or adds the button, you could hook jQuery operations globally and check the page in a short setTimeout() after the completion of any jQuery ajax operation.
You cannot use jQuery .on()
to find out when an object is added to the page. .on()
works for event handlers for objects that are added to the page in the future by catching propagated events at a parent object (that is not dynamically added to the page), but doesn't actually tell you when the object is added to the page.
FYI, there is a DOMSubtreeModified
and DOMNodeInserted
event in some browsers that sounds like it's ready-made for this sort of thing, but it's only available in some browsers and is deprecated (not recommended for use).
The future direction for this type of notification is Mutation Events, but this is not yet very widely supported.