You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium Extensions
Hey Guys,
My understanding is that under MV3, content scripts (unlike the background service worker) can run for however long they want. I didn't see any specific changes to them in migrating from mv2 to mv3...
wOxxOm
unread,
Mar 13, 2022, 11:29:04 AM3/13/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium Extensions, sonny...@gmail.com
The "isolated world" where the content scripts run doesn't mean they are separate from the page. Content scripts run in the page as an integral part of the page, just like any other page script, so it's impossible to pause them separately from the page. They run as long as the page itself.
Sonny Chee
unread,
Mar 13, 2022, 2:02:37 PM3/13/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium Extensions, wOxxOm, Sonny Chee
When you say:
"They run as long as the page itself."
Does that mean, they run as long as the tab is open? More concretely, if I have setTimeout( function, 10*60*1000 ), can I be certain that the function will be execute in 10 minutes?
hrg...@gmail.com
unread,
Mar 13, 2022, 6:04:40 PM3/13/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium Extensions, sonny...@gmail.com, wOxxOm
can I be certain that the function will be execute in 10 minutes?
You can't be certain because:
A tab can navigate to another page, causing your content script to be unloaded
A tab can be automatically discarded by the browser if it needs to release RAM
A tab that hasn't been visible for more than 5 minutes will be throttled down and setTimeout will run at most once per minute.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium Extensions, hrg...@gmail.com, sonny...@gmail.com, wOxxOm
The page can also clear your timer intentionally or accidentally because timers aren't isolated, so it's more reliable to use chrome.alarms API in the background script and send a message to the content script when the alarm goes off.