|
25 | 25 | const SHORTKEY = "KeyP"; // if you want to set a modifier key shortcut, edit the handlePlaylistKey function |
26 | 26 |
|
27 | 27 | // Add your language for the Save menu entry name |
28 | | - // 1. Play a video |
29 | | - // 2. Click the menu button where there is the "save to playlist" menu entry |
30 | | - // 3. In the dev tool > inspector, search for the selector: yt-button-shape > button[aria-label] |
31 | | - // It should be around the 7th match. Copy the [aria-label] value. |
| 28 | + // - Play a video |
| 29 | + |
| 30 | + // First case scenario: the "save to playlist" button is in the "…" sub-menu |
| 31 | + // 1. Click the "…" menu button where there is the "save to playlist" menu entry |
| 32 | + // 2. In the dev tool > inspector, search for the selector: yt-button-shape > button[aria-label] |
| 33 | + // It should be around the 7th match. Copy the [aria-label] value and add it here. |
32 | 34 | const MoreActionsButtonText = [ |
33 | 35 | "More actions", |
34 | 36 | "Autres actions", |
|
37 | 39 | "Altre azioni", |
38 | 40 | "Mais ações", |
39 | 41 | ]; |
40 | | - // 4. search for the selector: #items > ytd-menu-service-item-renderer yt-formatted-string |
| 42 | + // 3. search for the selector: #items > ytd-menu-service-item-renderer yt-formatted-string |
41 | 43 | // copy the text content |
42 | 44 | const SaveButtonText = ["Save", "Enregistrer", "Speichern", "Guardar", "Salva"]; |
43 | 45 |
|
| 46 | + // Second case scenario, the "Save" to playlist button is in direct access |
| 47 | + // 1. In the dev tool > inspector, search for the selector: .ytSpecButtonViewModelHost button[aria-label] |
| 48 | + // until your find the one for the save to playlist. |
| 49 | + // 2. It should be around the 7th match. Copy the [aria-label] value and add it here. |
| 50 | + const DirectSaveButtonText = [ |
| 51 | + "Save to playlist", |
| 52 | + "Enregistrer dans une playlist", |
| 53 | + "Zu Playlist hinzufügen", |
| 54 | + "Añadir a lista de reproducción", |
| 55 | + "Salva in una playlist", |
| 56 | + "Salvar na playlist", |
| 57 | + "Guardar na playlist", |
| 58 | + ]; |
| 59 | + |
44 | 60 | /**========================================================================== |
45 | 61 | * ℹ GLOBAL DEFINITION |
46 | 62 | ===========================================================================*/ |
|
467 | 483 | * @returns {void} |
468 | 484 | */ |
469 | 485 | function openSaveToPlaylistDialog() { |
470 | | - const directSaveButton = document.querySelector('yt-button-shape button[aria-label="Save to playlist"]'); |
| 486 | + let directSaveButton = null; |
| 487 | + for (const text of DirectSaveButtonText) { |
| 488 | + const selector = `.ytSpecButtonViewModelHost button[aria-label="${text}"]`; |
| 489 | + directSaveButton = document.querySelector(selector); |
| 490 | + if (directSaveButton) { |
| 491 | + break; |
| 492 | + } |
| 493 | + } |
| 494 | + |
471 | 495 | if (directSaveButton) { |
| 496 | + console.log("✅ openSaveToPlaylistDialog(), direct save button found. Click it"); |
472 | 497 | directSaveButton.click(); |
473 | 498 | } else { |
| 499 | + console.log( |
| 500 | + "❌ openSaveToPlaylistDialog(), direct save button NOT found. Search for More Actions menu" |
| 501 | + ); |
| 502 | + |
474 | 503 | let moreActionsButton = null; |
475 | 504 | for (const text of MoreActionsButtonText) { |
476 | 505 | const selector = `yt-button-shape > button[aria-label="${text}"]`; |
|
481 | 510 | } |
482 | 511 |
|
483 | 512 | if (moreActionsButton) { |
| 513 | + console.log("✅ openSaveToPlaylistDialog(), More Actions menu found. Click it"); |
484 | 514 | moreActionsButton.click(); |
485 | 515 | setTimeout(() => { |
486 | 516 | const submenuItems = document.querySelectorAll( |
|
0 commit comments