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
{{ message }}
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.
but the document says that we can access DOM in content_scripts and the fact is not as expected
I think I need an explaination from the official member
Content scripts can access DOM and they do it in lots of extensions, including the ones I write. Your code is probably incorrect, for example you've declared the script with "run_at": "document_start" so it runs before anything is added to DOM.
I guess the documentation could elaborate on document_start. Currently it says:
Scripts are injected after any files from css, but before any other DOM is constructed or any other script is run
Many people arguably may not know what "DOM" or "DOM is constructed" means so the documentation could say:
Scripts are injected after any files from css, but before any other DOM is constructed or any other script is run. It means that only document.documentElement exists for the root node of the page (it maps to <html> in an HTML document) but there's still no document.head nor document.body. In such cases the typical solution is to use MutationObserver, periodically check DOM inside setInterval, or listen to events.
@dotproto, mentioning you so this is not lost: something to consider when you upgrade this documentation article.
excute
console.log(document.body)
but we can access the
document
🤷excute
console.log(document)
version: ALL NEW
The text was updated successfully, but these errors were encountered: