无cookie嵌入式YouTube视频的内容脚本

时间:2018-05-10 04:42:58

标签: google-chrome-extension

我想将内容脚本设置为所有嵌入的YouTube视频,因此我在内容脚本中使用该标记:

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

一切正常,但我看到,有两种类型的嵌入式YouTube视频:youtube.com/embed和youtube-nocookie.com。对于第二个,我的内容脚本不起作用。我该怎么办?

嵌入式代码的第二种情况为:

<video tabindex="-1" class="video-stream html5-main-video" controlslist="nodownload" 
        style="width: 815px; height: 458px; left: 0px; top: 19.2813px;"
     src="blob:https://www.youtube-nocookie.com/85648de5-fa2c-4785-bc8c-1fdce53c8226">
</video>

1 个答案:

答案 0 :(得分:0)

我不确定我是否理解正确的描述,但你试过这个吗?

"content_scripts": [
        {
            "matches": [
                "*://*.youtube.com/*",
                "*://*.youtube-nocookie.com/*" // <- This did not work?
            ],
            "css": [
                "app_player.css"
            ],
            "js": [
                "content.js"
            ],
            "run_at": "document_end",
            "all_frames": true
        }
    ]