mythofechelon
mythofechelon

Reputation: 3782

Can't inject content script into YouTube

This question is more for the benefit of others and my own curiosity, as I have synthesized a workaround for now (using "matches": ["http://*/*", "https://*/*"] and if (location.hostname == "www.youtube.com").

Anyway, when I have an issue like this I break the code down into simpler and simpler forms until it starts to work. Then I can figure out what's tripping up the code. But I've hit that point now where it can't get simpler and it still doesn't work. Chrome just won't inject a content script into any of YouTube's pages.

 

Files (link to ZIP of the following)

manifest.json:

{
    "name": "test",
    "version": "0",
    "manifest_version": 2,

    "content_scripts": [ 
        {
            "js": [
                "test.js"
            ],
            "matches": [
                "*://youtube.com/*"
            ],
            "run_at": "document_end",
            "all_frames": true
        }
    ]
}

test.js:

alert("test");

 

Progress

Doesn't work:

Does work:

 

I feel like I'm missing something really obvious here, but it's been days.. ;/

Upvotes: 1

Views: 759

Answers (1)

user1803920
user1803920

Reputation: 116

This works for me if you define the match in the manifest as "http://www.youtube.com/*"

Upvotes: 3

Related Questions