I want to reflect multiple content files on a particular site, but only one of them is reflected.

Asked 2 years ago, Updated 2 years ago, 338 views

"manifest_version": 3,
"content_scripts":[
        {
            "matches": [
                "https://www.test.com/*"
            ],
            "js": [
                "test-1.js"
            ]
        },
        {
            "matches": [
                "https://www.test.com/*"
            ],
            "js": [
                "test-2.js"
            ]
        }
    ],

For example, if you configure the manifest as above, the JS file of test-1 will not be reflected, but only the JS file of test-2.
Is there any way to reflect both?
Thank you for your cooperation.

javascript chrome-extension

2022-09-30 22:03

1 Answers

In the original way of writing, the definition of match is duplicated, so I think only one of them will be reflected.

Please define it as an array in the js part as follows.

"manifest_version": 3,
"content_scripts":[
        {
            "matches": [
                "https://www.test.com/*"
            ],
            "js": [
                "test-1.js", "test-2.js"
            ]
    ],


2022-09-30 22:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.