tosdr / browser-extensions

Browser extensions for Terms of Service; Didn't Read. “I have read and agree to the Terms” is the biggest lie on the web. We aim to fix that. Get informed instantly about websites' terms & privacy policies, with ratings and summaries from the www.tosdr.org initiative.
http://tosdr.org/downloads
GNU Affero General Public License v3.0
400 stars 45 forks source link

retrieve data at regular intervals, not just when plugin is loaded #23

Closed michielbdejong closed 3 years ago

michielbdejong commented 6 years ago

it seems the background script is not run when closing and reopening the browser. this means getServices is not called often enough. will check for OS restart, but might require some other trigger.

oslego commented 5 years ago

If the background page is lazily loaded, perhaps making use of chrome.runtime.onStartup will help ensure the fetch is done when the browser is restarted.

It really depends on how often the services data changes and should be resynchronised. Some users expect the browser to be very, very long lived: days, weeks, even months. They accumulate tens even hundreds of tabs open, thus making them even less inclined to restart the browser.

An alternative solution to the problem here is to use chrome.alarms a rudimentary form of CRON jobs. They can be set to schedule running operations at some time in the future, though precision is not guaranteed.

Using chrome.alarms requires the request of a new permission in the manifest: "alarms".

This solution may also serve #5 whereby an alarm can be scheduled to run every few minutes until a connection is established to the API, after which the alarm to sync the data can be set to a much less frequent cycle of maybe once per day or less.