Skip to content

Instantly share code, notes, and snippets.

@davidlwatsonjr
Created February 14, 2017 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidlwatsonjr/e9650aed31eacc1751b5b20ab5f469e1 to your computer and use it in GitHub Desktop.
Save davidlwatsonjr/e9650aed31eacc1751b5b20ab5f469e1 to your computer and use it in GitHub Desktop.
Google Play Music Deduplicator
var mainPanel = document.querySelector("#mainContainer");
var lastProcessedSong = '';
mainPanel.scrollTop = 0;
function processSong() {
var topSong = document.querySelector('.song-table tr.song-row');
console.log(topSong);
if (topSong.dataset.id !== lastProcessedSong) {
var nextSong = document.querySelector('.song-table tr.song-row:nth-child(3)');
var topSongTitle = topSong.querySelector('[data-col=title] .column-content').textContent;
var nextSongTitle = nextSong.querySelector('[data-col=title] .column-content').textContent;
var topSongArtist = topSong.querySelector('[data-col=artist] .column-content').textContent;
var nextSongArtist = nextSong.querySelector('[data-col=artist] .column-content').textContent;
if ((topSongArtist === nextSongArtist) && topSongTitle.startsWith(nextSongTitle) || nextSongTitle.startsWith(topSong)) {
for (var i = 0; i < columns.length; i++) {
columns[i].style.background = 'yellow';
}
var columns = nextSong.querySelectorAll('td');
for (var i = 0; i < columns.length; i++) {
columns[i].style.background = 'yellow';
}
return;
}
}
lastProcessedSong = topSong.dataset.id;
mainPanel.scrollTop += 41;
if (mainPanel.scrollTop < (mainPanel.scrollHeight - mainPanel.clientHeight)) {
window.setTimeout(processSong, 50);
}
}
processSong();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment