doesn't work anymore and i deleted my last.fm - maybe someone posted a working version in the comments below!
This script serves to delete duplicate scrobbles (i.e. the same song scrobbled multiple times in a row) from your Last.fm library.
To use it, paste the script into your browser's console (or the address bar, but prefix the script with javascript:
) while logged in and
in the own library.
Your scrobbler might just have decided to scrobble every song hundreds of times and you can't really remove those scrobbles efficiently. Or, if you're like me, you might have accidentally installed multiple scrobbler extensions at the same time - wondering why multiple scrobbles appear for every song played at a time - and you want to clear them after finding the issue.
Using this script still doesn't necessarily make the process quick, since Last.fm only shows a specific number of scrobbles which can be removed on each page in your library.
- Copy the following script URL into your clipboard
javascript:var elements=Array.from(document.querySelectorAll('.js-link-block'));elements.map(function(a){var b=a.querySelector('.chartlist-name');return b&&b.textContent.replace(/\s+/g,' ').trim()}).forEach(function(a,b,c){if(a===c[b+1]){var d=elements[b].querySelector('[data-ajax-form-sets-state="deleted"]');d&&d.click(),location.reload()}});
- Right-click your browser's bookmark bar and click "Add page..."
- Give the bookmark a name, like "Remove duplicates"
- Paste the script you copied in step 1 into the bookmark's URL.
- Save the bookmark
- Open your Last.fm account's library while being logged in (https://www.last.fm/user/_/library).
- Opening your bookmark will trigger the script to execute.
- Repeat clicking the bookmark as long as there are no duplicates left.
- Copy the script
var elements=Array.from(document.querySelectorAll('.js-link-block'));elements.map(function(a){var b=a.querySelector('.chartlist-name');return b&&b.textContent.replace(/\s+/g,' ').trim()}).forEach(function(a,b,c){if(a===c[b+1]){var d=elements[b].querySelector('[data-ajax-form-sets-state="deleted"]');d&&d.click(),location.reload()}});
- Open your Last.fm account's library while being logged in (https://www.last.fm/user/_/library).
- Type
javascript:
into the address bar and paste the script directly after it. Or, open the dev tools and paste the script into the console. - Press enter. This will remove all duplicates on the current page.
- Let the site reload (invoked by the script).
- Repeat pasting the script and pressing enter if more duplicates appear at the bottom.
- If needed, go to the next page of your library repeat the steps as of step 3.
The script will only remove what's visible on the current library page. After entries were deleted, more duplicates may appear at the bottom. This might happen multiple times. Once one page is finally duplicate-free, the process can be repeated for next pages.
This is really helpful. My 2 issues thus far though are:
This doesn't delete scrobbles that aren't consecutively listed in the library. For instance, back when I was using my iPod I had instances of Song A being scrobbled at a certain timestamp and at another timestamp + x minutes later. I believe this occurred when I sync my iPod to my laptop. Since I was also listening to other songs, what's listed in my library would be Song A - timestamp, Song B - timestamp + x. Song A - timestamp + y, etc.
Unfortunately, I accidentally deleted my scrobbles of my all-time played track. I was just testing if this would delete the scrobbles with the same timestamp. But since there were no other listed tracks there (because I visited the scrobbles of a specific track), it deleted everything in that page. =/
Anyway, kudos to you @sk22. I had to create an account here in github to personally acknowledge your efforts, especially that I've been a last.fm user for more than a decade now.