You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a script with default @run-at (document-idle), that sends about 1-3 requests to an external API per page. API has a strict call limit, so I'm looking for a way to space out the requests. Usually there is a lot of pages opened one by one in background, and no need to pre-load data from requests in the background.
I was wondering, is there a proper way to inject or run the script only when page tab becomes active, only once per page? Should I just wrap my script into something like document.addEventListener("visibilitychange") and check if it's already been run before, or is there some native way to do that?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a script with default @run-at (document-idle), that sends about 1-3 requests to an external API per page. API has a strict call limit, so I'm looking for a way to space out the requests. Usually there is a lot of pages opened one by one in background, and no need to pre-load data from requests in the background.
I was wondering, is there a proper way to inject or run the script only when page tab becomes active, only once per page? Should I just wrap my script into something like
document.addEventListener("visibilitychange")
and check if it's already been run before, or is there some native way to do that?Beta Was this translation helpful? Give feedback.
All reactions