Good day to everyone, as you can see I’m pretty new at Chrome extensions.
Can you run a script from content_scripts
before and after the the DOM or page fully loads?
Like:
JavaScript
x
8
1
"content_scripts": [ {
2
"matches": ["<all_url>"],
3
"js": ["content.js"],
4
"all_frames": true,
5
"run_at": "document_start",
6
"run_at": "document_end"
7
} ]
8
Or something like:
JavaScript
1
13
13
1
"content_scripts": [ {
2
"matches": ["<all_url>"],
3
"js": ["content1.js"],
4
"all_frames": true,
5
"run_at": "document_start"
6
} ],
7
"content_scripts": [ {
8
"matches": ["<all_url>"],
9
"js": ["content2.js"],
10
"all_frames": true,
11
"run_at": "document_end"
12
} ]
13
Advertisement
Answer
You can have only one content_scripts
entry, so it would be like:
JavaScript
1
12
12
1
"content_scripts": [{
2
"matches": ["<all_urls>"],
3
"js": ["content1.js"],
4
"all_frames": true,
5
"run_at": "document_start"
6
},{
7
"matches": ["<all_urls>"],
8
"js": ["content2.js"],
9
"all_frames": true,
10
"run_at": "document_end"
11
}]
12
With this setting, content1.js
would run at the beginning and content2.js
at the end.