批量删除 Youtube Watch Later 视频列表的方式
本帖最后由 HelloWorld 于 2025-4-20 19:30 编辑2000+ 的视频,官方没有提供批量删除途径,于是写了个脚本自动删除:
(async function clearWatchLater() {
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
const removeOneVideo = async (button) => {
button.click();
await delay(200);
const removeBtn = document.evaluate(
'//tp-yt-paper-item',
document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null
).singleNodeValue;
if (removeBtn) {
removeBtn.click();
console.log('✅ 视频已移除');
await delay(Math.random() * 1000);
}
};
const buttons = document.querySelectorAll('button');
const total = buttons.length;
console.log(`🚀 找到 ${total} 个视频,开始删除...`);
for (let i = 0; i < total; i++) {
await removeOneVideo(buttons);
// 每删除5个视频后,额外等待几秒,避免限流
if ((i + 1) % 5 === 0) {
console.log(`⏳ 已删除 ${i + 1} 个视频,休息5秒防止触发限流...`);
await delay(5000);
}
}
console.log('🎉 删除完毕!如果页面还有视频,刷新后再次执行此脚本即可。');
})();使用方法:打开:https://www.youtube.com/playlist?list=WL ,在浏览器调试工具 console 里黏贴上述代码
你可以把网页最小化,不影响你做其他事情
代码其实是让 ChatGPT 4.5 帮我生成的,提示词如下:
我想清空 youtube watch later 里的所有视频
<button id="button" class="style-scope yt-icon-button" aria-label="Action menu"> 菜单按钮是这个
<tp-yt-paper-item class="style-scope ytd-menu-service-item-renderer" style-target="host" role="option" tabindex="0" aria-disabled="false"> 移除按钮是这个
根据这个帮我写删除脚本,同时注意频繁操作会触发限流
在补充一个删除点赞视频的脚本:
(async function clearLikedVideos() {
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
const removeOneVideo = async (button) => {
button.click();
await delay(200);
const removeBtn = document.evaluate(
'//ytd-menu-service-item-renderer//tp-yt-paper-item',
document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null
).singleNodeValue;
if (removeBtn) {
removeBtn.click();
console.log('✅ 视频已删除');
await delay(Math.random() * 1500 + 500);
}
};
const buttons = document.querySelectorAll('button');
const total = buttons.length;
console.log(`🚀 找到 ${total} 个点赞的视频,开始删除...`);
for (let i = 0; i < total; i++) {
await removeOneVideo(buttons);
if ((i + 1) % 5 === 0) {
console.log(`⏳ 已删除 ${i + 1} 个视频,休息5秒防止触发限流...`);
await delay(5000);
}
}
console.log('🎉 删除完毕!如果页面还有视频,刷新后再次执行此脚本即可。');
})();
页:
[1]