Like every song
in a playlist
Paste this into the console on music.youtube.com. It scrolls a playlist until the songs are loaded, likes each one you have not already liked, and prints progress, speed, and an ETA. It is meant for long playlists, on the order of four thousand songs.
Console · YouTube Music · 49 lines
Run it from the playlist page.
- Openthe playlist on music.youtube.com in a desktop browser.
- Switchto the DevTools console.
- Pastethe script and press Enter.
- Leavethe tab in the foreground until it finishes.
- Rerunany time. Songs already liked are skipped.
It can break.
Unofficial. This is not a YouTube feature, and it may break if YouTube changes the page.
If likes stop sticking, YouTube may be rate limiting. The script warns in the console. Stop and try later.
1(async () => {
2 const sleep = ms => new Promise(r => setTimeout(r, ms));
3 const t0 = Date.now();
4 const fmt = s => `${Math.floor(s / 60)}m ${Math.floor(s % 60)}s`;
5 const total = parseInt((document.querySelector('ytmusic-responsive-header-renderer .second-subtitle, .second-subtitle')?.textContent || '').replace(/[^\d]/g, '')) || null;
6 const done = new WeakSet();
7 let liked = 0, skipped = 0, failed = 0, noBtn = 0, idle = 0, batch = 0;
8 const info = row => {
9 const cols = row.querySelectorAll('yt-formatted-string');
10 return `${cols[0]?.textContent?.trim() || '?'} — ${cols[1]?.textContent?.trim() || '?'}`;
11 };
12 console.log(`%c▶ Start${total ? ` (playlist says ~${total} songs)` : ''}`, 'color:#0af;font-weight:bold');
13 while (idle < 5) {
14 const rows = [...document.querySelectorAll('ytmusic-responsive-list-item-renderer')];
15 const fresh = rows.filter(r => !done.has(r));
16 if (!fresh.length) {
17 idle++;
18 console.log(`%c… no new songs loaded (try ${idle}/5), scrolling again`, 'color:#999');
19 } else {
20 idle = 0; batch++;
21 console.log(`%c— Batch ${batch}: ${fresh.length} new songs (${rows.length} loaded)`, 'color:#fa0;font-weight:bold');
22 for (const row of fresh) {
23 done.add(row);
24 const n = liked + skipped + failed + noBtn + 1;
25 const btn = row.querySelector('ytmusic-like-button-renderer #button-shape-like button');
26 if (!btn) { noBtn++; console.warn(`#${n} ⚠ no like button: ${info(row)}`); continue; }
27 if (btn.getAttribute('aria-pressed') === 'true') { skipped++; console.log(`#${n} ↷ already liked: ${info(row)}`); continue; }
28 btn.click();
29 await sleep(300 + Math.random() * 300);
30 if (btn.getAttribute('aria-pressed') === 'true') {
31 liked++; console.log(`#${n} ♥ liked: ${info(row)}`);
32 } else {
33 failed++; console.warn(`#${n} ✖ like did not stick: ${info(row)}`);
34 if (failed % 10 === 0) console.error(`${failed} failed likes so far, YouTube may be throttling. Consider stopping and retrying later.`);
35 }
36 }
37 const processed = liked + skipped + failed + noBtn;
38 const secs = (Date.now() - t0) / 1000;
39 const rate = processed / secs;
40 const pct = total ? ` | ${((processed / total) * 100).toFixed(1)}%` : '';
41 const eta = total && rate ? ` | ETA ${fmt((total - processed) / rate)}` : '';
42 console.log(`%c📊 ${processed} processed${pct} | ♥ ${liked} liked | ↷ ${skipped} skipped | ✖ ${failed} failed | ⚠ ${noBtn} no button | ${rate.toFixed(1)}/s | elapsed ${fmt(secs)}${eta}`, 'color:#0c6;font-weight:bold');
43 }
44 rows.at(-1)?.scrollIntoView({ block: 'end' });
45 window.scrollBy(0, 2000);
46 await sleep(2500);
47 }
48 console.log(`%c✔ Done in ${fmt((Date.now() - t0) / 1000)}: ♥ ${liked} liked, ↷ ${skipped} already liked, ✖ ${failed} failed, ⚠ ${noBtn} no button`, 'color:#0af;font-weight:bold;font-size:14px');
49})();