0

I have a Chrome Extension which runs on a dedicated domain and manipulates the DOM. (Everything here is kosher: the user INTENTIONALLY installs this for this specific given site, and even the site owners are aware/support this extension, but they are not able to change its code easily.)

One page loads the content via AJAX, and refreshes a given every minute or so with a polling AJAX call. There is a specific function, UpdatePageComplete() that they call at the end of the AJAX sync. I need that function to then call one of MY Chrome Extension functions, so that I can manipulate the new data (ex: adding <a href='tel:' wrappers to any phone numbers, or background-colors to elements with certain contents).

I can't figure out how to inject my own callback into their native functions though. Is this even possible? If so, where should I be looking?

Bing
  • 3,071
  • 6
  • 42
  • 81

1 Answers1

0

I've done something similar in the past. You can't inject your own callback into their code, but you can:

  1. Create a global function for them to call (inject window.mySpecialFn = () => {...})
  2. Add a custom event listener on the body, and have their code dispatch that custom event.
Julianna
  • 152
  • 6