有什么方法可以完全使用脚本来禁用YouTube的“上一个下一个”或自动播放功能,或者为Firefox附加功能吗?请注意,名称“自动播放”令人困惑。我特别指的是在当前视频播放完后将播放“建议”视频的功能。该功能经常陷入无限循环中,重复播放相同的两个视频。此外,当我在视频下方写评论时,它经常播放下一个视频。最近的UI更改破坏了我一直用于完成此任务的添加项。启用cookie对我来说不是一个选择,因为那样的话我必须在这两种不愉快的选择之间进行选择:
我不认为该线程是重复的,因为我不知道在最近的UI更改后(在GitHub,Firefox上about:addons和Google进行了广泛搜索之后),任何现有脚本都会禁用自动播放功能。如果脚本满足两个条件,将非常有帮助。
以下是与更新之前使用的用户脚本相似的用户脚本,但现在已损坏。
(function () {
'use strict';
function removeAPUN() {
var autoplaybar = document.getElementsByClassName('autoplay-bar')[0];
if (autoplaybar) {
autoplaybar.removeAttribute('class');
document.getElementsByClassName('checkbox-on-off')[0].remove();
}
}
window.addEventListener('readystatechange', removeAPUN, true);
window.addEventListener('spfdone', removeAPUN);
}());
提前致谢!
最佳答案
您说完全禁用该功能,所以我不确定以下内容是否满足您的100%需求,但也许有帮助。
下列内容一直在寻找“禁用自动播放”按钮,直到它存在,然后单击它(如果当前设置为 Activity 状态):
setTimeout(disable_autoplay, 1000);
function disable_autoplay(){
// Try to get the toggle button
var toggle_button = document.getElementById("toggle");
if (toggle_button){
if (toggle_button.hasAttribute("checked")){
// If it is checked, click it to disable autoplay
toggle_button.click();
// Retry one more time to make sure it stays disabled
setTimeout(disable_autoplay, 5000);
}
} else {
// Not found, retry
console.log("Retrying in 1s");
setTimeout(disable_autoplay, 1000);
}
}
单击该按钮后,它会重试一次,但我不确定是否需要重试一次,但是当我手动禁用自动播放时,有时会稍后重新打开,因此实际上只是为了确保它保持关闭状态。
关于video - 禁用YouTube的 “up next”/自动播放功能的脚本或插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46385678/