3

Reading up on the SDK documentations... I found these:

Option 1: Request

The request API . I get a HTML string as a response. However to parse the HTML and extract the relevant table data that I need, I would have to create a DOM element somewhere. Something like this HTML to DOM.

But the addon-sdk guidelines say to open remote content on a content-script. So, why the request module?

Option 2: Page-worker

The page-worker API allows to load pages permanently in the background. For polling puposes, I can repeatedly create a pageworker and destroy it after extracting the required data after certain periods of time.

So, which is a better option? Request or Page-worker? And why should I prefer one over the other? Page-worker creates a document object every time I poll the website. Isn't it a browser intensive task to do this create-DOM-destroy-DOM task repeatedly?

Also, what about location.reload() in this context?

Community
  • 1
  • 1
themagicalyang
  • 2,493
  • 14
  • 21

1 Answers1

2

I'd recommend page-worker.

You can either create a new page-worker for each "poll" and destroy the old one when it's no longer needed, for refresh a single page-worker using PageWorker(/*...*/).contentURL = "https://google.com";

If you can use the request module though, then that would be better since it is more lightweight.

erikvold
  • 15,988
  • 11
  • 54
  • 98