I am developing a Chrome Extension that interacts with Twitter and injects a content script when the user visits twitter.com/home. I declared content_scripts in manifest.json and everything works fine on twitter.com/home. However, when I visit twitter.com it redirects to twitter.com/home and the extension does not inject the content script. Adding "twitter.com" to the "matches" list in manifest.json solves the problem but I want the extension to inject the script only when twitter.com/home loads. I am considering using webNavigation API to detect redirects but I wonder if there are more efficient ways to achieve this. Thanks!
manifest.json
"name": "xxx",
"version": "1.0",
"description": "abc",
"permissions": [
"activeTab",
"declarativeContent",
"storage"
],
"content_scripts": [
{
"matches": ["https://twitter.com/home", "https://twitter.com/"],
"run_at": "document_idle",
"js": ["script.js"]
}
],
"background": {
"scripts": ["background.js"],
"persistent": false
},
"manifest_version": 2
}