Last active
January 5, 2025 00:09
-
-
Save zopieux/52697a654af3f049128cdfe8cdb552ae to your computer and use it in GitHub Desktop.
YouTube Music delete all from local library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function deleteAll() { | |
function firstItemTriggerDropdown() { | |
document.querySelector('ytmusic-responsive-list-item-renderer button path[d="M12,16.5c0.83,0,1.5,0.67,1.5,1.5s-0.67,1.5-1.5,1.5s-1.5-0.67-1.5-1.5S11.17,16.5,12,16.5z M10.5,12 c0,0.83,0.67,1.5,1.5,1.5s1.5-0.67,1.5-1.5s-0.67-1.5-1.5-1.5S10.5,11.17,10.5,12z M10.5,6c0,0.83,0.67,1.5,1.5,1.5 s1.5-0.67,1.5-1.5S12.83,4.5,12,4.5S10.5,5.17,10.5,6z"]') | |
.parentNode.parentNode.parentNode.parentNode.parentNode | |
.click() | |
} | |
function dropdownDelete() { | |
document.querySelector('tp-yt-iron-dropdown #contentWrapper a svg path[d="M11,17H9V8h2V17z M15,8h-2v9h2V8z M19,4v1h-1v16H6V5H5V4h4V3h6v1H19z M17,5H7v15h10V5z"]') | |
.parentNode.parentNode.parentNode.parentNode | |
.click() | |
} | |
function modalConfirm() { | |
// Locale-specific, update! | |
document.evaluate('//span[text()="Delete"]', document, null, XPathResult.ANY_TYPE, null) | |
.iterateNext() | |
.parentNode.parentNode | |
.click() | |
} | |
function wait(d) { | |
return new Promise((resolve,) => setTimeout(() => resolve(), d)) | |
} | |
while (true) { | |
try { | |
firstItemTriggerDropdown() | |
await wait(200) | |
dropdownDelete() | |
await wait(200) | |
modalConfirm() | |
await wait(250) | |
} catch (e) { | |
return | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment