-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
44 lines (34 loc) · 1.08 KB
/
Copy pathscript.js
File metadata and controls
44 lines (34 loc) · 1.08 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
const sleep = ms => new Promise(r => setTimeout(r, ms));
(async function clearWatchLater() {
let removed = 0;
console.log("Cleaning Watch Later...");
while (true) {
const btn = document.querySelector(
'#primary ytd-playlist-video-renderer yt-icon-button.dropdown-trigger'
);
if (!btn) {
console.log(`Done! Removed ${removed} videos.`);
break;
}
btn.click();
await sleep(300);
const items = document.querySelectorAll(
'tp-yt-iron-dropdown [role="menuitem"], ytd-menu-service-item-renderer'
);
let found = false;
for (const item of items) {
if (item.textContent.includes("Remove from")) {
item.click();
removed++;
found = true;
console.log(`Removed: ${removed}`);
break;
}
}
if (!found) {
console.log("Remove option not found, scrolling.");
window.scrollBy(0, 100);
}
await sleep(500);
}
})();