Content Scripts
Last updated
Last updated
By default, runs after page has loaded in an isolated world with seperate variables but accessing same DOM
Use messages to access most chrome APIS, but can accessjj:
runtime:
( , , , , )
document_idle
( default) - Guaranted to run after DOM is loaded so no needed to wait for window.onload
document_start
- after css, but before any DOM or script is run
document_end
- immediately after DOM is complete, but before subresources like images and frames have loaded
There is fancy matching settings and white and black lists
When you refresh/update the background script, the content scripts on past pages will still be there running code. But, they will not have access to localStorage or be able to message
The best way to check if valid is to try to access localStorage, but can also just ensure the content script only runs code on messages or storage changes