代码之家  ›  专栏  ›  技术社区  ›  Freelancer

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

  •  0
  • Freelancer  · 技术社区  · 8 年前

    我想将内容脚本设置为所有嵌入的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 回复  |  直到 8 年前
        1
  •  0
  •   Andreas Moldskred    8 年前

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

    "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
            }
        ]