How to use sendResponse?

Can somebody post a working example code to “perform an async task and use sendResponse(err, elements) callback to return matched elements after task completion.”? I can’t get it to work. I’ve used the forum search but did’t find any.

Thank you!

the sendResponse(error, result) javascript function is can be used to computer a monitored value from the page. the arguments are:

  1. error: an error object in case an error should be raised.
  2. result: a list of selected elements that should be monitored for changes.

here an example usage:

// wait for 5s for content to load
setTimeout(() => {
  sendResponse(null, document.querySelector('#quantity'))
}, 5000);

please note that javascript support has removed in the chrome extension because chrome’s stricter csp blocker evaluating these scripts.

what are you trying to use js for?

1 Like

Thank you, I got your example working.

1 Like