-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYT_clear_watch-later_script
More file actions
56 lines (44 loc) · 1.67 KB
/
YT_clear_watch-later_script
File metadata and controls
56 lines (44 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
## Paste in Chrome Console and run
(async () => {
console.log("Starting to scroll through your 'Watch later' playlist...");
// Step 1: Scroll to the bottom in steps, so all videos are loaded.
let previousHeight = 0;
while (true) {
window.scrollTo(0, document.documentElement.scrollHeight);
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait for loading
const currentHeight = document.documentElement.scrollHeight;
if (currentHeight === previousHeight) {
break; // No more videos to load
}
previousHeight = currentHeight;
}
console.log("All videos loaded. Now removing them...");
// Step 2: Gather all "action menu" buttons
const menuButtons = Array.from(
document.querySelectorAll(
'ytd-playlist-video-renderer #button[aria-label="Action menu"]'
)
);
let removedCount = 0;
// Step 3: Click each menu, then click "Remove" if found
for (const [index, button] of menuButtons.entries()) {
// Open the menu
button.click();
await new Promise(resolve => setTimeout(resolve, 700));
// Find "Remove from Watch later" item in the menu
const removeBtn = Array.from(
document.querySelectorAll(
'ytd-popup-container ytd-menu-service-item-renderer[role="menuitem"]'
)
).find(item => /remove from/i.test(item.innerText));
// Click "Remove" if it’s there
if (removeBtn) {
removeBtn.click();
removedCount++;
console.log(`Removed ${removedCount} so far (video #${index + 1}).`);
}
// Short pause after removing
await new Promise(resolve => setTimeout(resolve, 700));
}
console.log(`Done! Removed ${removedCount} video(s) from 'Watch later'.`);
})();