YTM Add to playlist shortcut

Adds a shortcut to the P button to add the current song to a playlist

< 脚本 YTM Add to playlist shortcut 的反馈

评价:差评 - 脚本失效或无法使用

§
发布于:2025-08-04

Does not work for me. However, this works for me:

// waitForElm from https://stackoverflow.com/a/61511955/
function waitForElm(selector) {
    return new Promise(resolve => {
        if (document.querySelector(selector)) {
            return resolve(document.querySelector(selector));
        }

        const observer = new MutationObserver(mutations => {
            if (document.querySelector(selector)) {
                observer.disconnect();
                resolve(document.querySelector(selector));
            }
        });

        // If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });
}

(function() {
    'use strict';
    window.addEventListener("keydown",function(event) {

        console.log("keycode? " + event.keyCode);
        if(event.keyCode === 80) {
            console.log("i'm in");
            var popupMenu = document.querySelector(".middle-controls #button-shape .yt-spec-touch-feedback-shape");
            popupMenu.click();
            waitForElm("tp-yt-paper-listbox :nth-child(7) > #navigation-endpoint")
            .then((playlistLink) => {
            console.log("got ", playlistLink);
            playlistLink.click();
            });
        }
    }, false)
})();

发布留言

登录以发布留言。