我正在尝试制作一个可以自动设置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;