Effectively polling a website in the background? (Firefox Addon SDK)

Reading the SDK docs ... I found them:

Option 1: request

request API. I am getting HTML string as response. However, in order to parse the HTML and extract the table data I want, I would need to create a DOM element somewhere. Something like this HTML for the DOM .

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

Option 2: worker page

The page-worker API allows you to constantly load pages in the background. For navel polling, I can re-create the page and destroy it after retrieving the required data at regular intervals.

So which is better? Query or Paige worker? And why should I give preference to the other? The page worker creates a document object every time I view the site. Isn't it a browser issue to re-create the create-DOM-destroy-DOM task?

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


source to share

1 answer

I would recommend page-worker


You can create a new one page-worker

for each "poll" and destroy the old one when it is no longer needed, to update one page-worker

withPageWorker(/*...*/).contentURL = "https://google.com";

If you can use the request module, but that would be better as it was lighter.



All Articles