Last active
October 9, 2024 08:13
-
-
Save krishoang222/a7961bcdb51bb28c6655069b44b892f0 to your computer and use it in GitHub Desktop.
Spotify - Batch remove songs from Your Episodes list
This file contains 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
// Function to remove episodes from the Spotify player | |
async function removeEpisodes() { | |
for (let i = 0; i < 100; i++) { | |
console.log(`Iteration ${i + 1}`); | |
// Select the first "More" button found on the page each time | |
const moreButton = document.querySelector('button[data-testid="more-button"]'); | |
if (moreButton) { | |
// Click the "More" button | |
moreButton.click(); | |
console.log(`Clicked More button for item.`); | |
// Wait for the context menu to appear | |
await new Promise(resolve => setTimeout(resolve, 500)); // Adjust time if needed | |
// Attempt to find the "Remove from Your Episodes" button | |
const removeButton = Array.from(document.querySelectorAll('button')).find( | |
btn => btn.querySelector('span') && btn.querySelector('span').textContent.includes("Remove from Your Episodes") | |
); | |
if (removeButton) { | |
removeButton.click(); // Click the remove button | |
console.log(`Clicked "Remove from Your Episodes" button for item.`); | |
} else { | |
console.log(`Remove button not found for this item.`); | |
} | |
// Wait for 1 seconds before moving to the next item | |
await new Promise(resolve => setTimeout(resolve, 1000)); | |
} else { | |
console.log(`No More button found. Exiting loop.`); | |
break; // Exit loop if no More button is found | |
} | |
} | |
} | |
// Start the removal process | |
removeEpisodes(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment