Chrome扩展程序:在加载内容脚本之前,请等待YouTube视频加载

时间:2020-08-03 10:40:18

标签: javascript json google-chrome-extension google-chrome-devtools

我正在尝试制作一个可以自动设置youtube视频音量的脚本。

脚本可以在devtools上使用,但是当我尝试将其作为扩展时不能使用。

这是我想出的。

Manifest.json


{
  "manifest_version": 2,
  "version": "0.1",
  "name": "My Cool Extension",
  
  "content_scripts": [
    {
        "matches": ["https://www.youtube.com/watch?v=*"],
        "js": ["content.js"]
    }
  ]
}

content.js


let ytVolume = document.getElementsByClassName('video-stream html5-main-video')[0];
// 1 = 100%
// 0.1 = 10%
ytVolume.volume = 0.25;

0 个答案:

没有答案