use*_*369 11 javascript youtube
我目前有三种方法可以禁用youtube视频中的注释:
||youtube.com/annotations_到其过滤器.这与前一点有同样的问题.此外,它完全禁用它们,而我只是希望它们默认关闭(所以我可以选择打开它们).可以使用JavaScript吗?我有一个UserScript已经对YouTube的网站进行了一些修改,所以理想情况下我想扩展它.这真的是我失踪的最后一件事.
我要求答案仅限于使用JS而不是浏览器扩展建议.两者都是因为(如上所述),我已经知道了这些,因为这与学习过程和结果有关.这是更多UserScript的实践.
由于youtube有时会改变玩家的行为,因此我会尝试使代码保持最新并尽可能保持健壮.
var settings_button = document.querySelector(".ytp-settings-button");
settings_button.click(); settings_button.click(); // open and close settings, so annotations label is created
var all_labels = document.getElementsByClassName("ytp-menuitem-label");
for (var i = 0; i < all_labels.length; i++) {
if ((all_labels[i].innerHTML == "Annotations") && (all_labels[i].parentNode.getAttribute("aria-checked") == "true")) { // find the correct label and see if it is active
all_labels[i].click(); // and in that case, click it
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3745 次 |
| 最近记录: |