Open tophf opened 6 months ago
Very much in favour of having this be aligned cross browsers! Safari also injects content scripts right after installation.
As for the possible solutions. More in favour of 2-4. As 1; using an array for "run_at" would not be backwards compatible. Mixing the two also seems confusing rather than clarifying.
This is also something I wrote some code for (https://github.com/fregante/webext-inject-on-install) but it requires the tabs
and scripting
permissions.
Related requests:
Here's what they could look like:
{
"content_scripts": [{
"id": "main",
"matches": ["*://*.example.com/*"],
"scripts": ["content.js"],
"run_at": "document_idle",
+ "run_on_active_tab": true,
+ "run_on_extension_enabled": true
}]
}
or
{
"content_scripts": [{
"id": "main",
"matches": ["*://*.example.com/*"],
"scripts": ["content.js"],
"run_at": "document_idle",
+ "run_on": ["active_tab", "extension_enabled"]
}]
}
or combine it with run_at
{
"content_scripts": [{
"id": "main",
"matches": ["*://*.example.com/*"],
"scripts": ["content.js"],
+ "run_at": ["document_idle", "active_tab", "extension_enabled"]
}]
}
In addition to injection. There is also the removal aspect in case content scripts get registered using registerContentScripts as mentioned in https://github.com/w3c/webextensions/issues/653.
So we might want to come up with a different naming which also includes the above mentioned behaviour of removing already injected styles (not applying to scripts as injected scripts can not be reversed).
Benefits/goals:
matches
inhost_permissions
and doesn't supportexclude_matches
yet (#123).Possible solutions:
"run_at": ["document_start", "extension_installed", "extension_enabled"]
i.e. an alternative array syntax forrun_at
"run_at_extension": ["installed", "enabled"]
i.e. an additional key"run_at_installed": true
and"run_at_enabled": true
"run_at_installed_or_enabled": true
Notes:
"extension_invoked"
in 1,"invoked"
in 2,"run_at_invoked"
in 3 and 4.content_scripts
should copy the install note from MDN concepts.content_scripts
.