-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #283 from salcido/quick-search-tracklists
New Feature: Quick Search Tracklists
- Loading branch information
Showing
14 changed files
with
165 additions
and
11 deletions.
There are no files selected for viewing
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* | ||
* Discogs Enhancer | ||
* | ||
* @author: Matthew Salcido | ||
* @website: http://www.msalcido.com | ||
* @github: https://github.com/salcido | ||
* | ||
* -------------------------------------------------------- | ||
* Lets you search for the track on Google in a new tab | ||
* by clicking the release tracklist. | ||
* -------------------------------------------------------- | ||
*/ | ||
rl.ready(() => { | ||
|
||
let variousArtists = document.querySelectorAll('td[class*=artist_] span'), | ||
subtracks = document.querySelectorAll('[class*="subtrack_"]'); | ||
|
||
// Wrap track titles in spans when subtracks are present so that click events are fired correctly | ||
if (subtracks) { | ||
rl.waitForElement('[class*="trackTitle_"]').then(() => { | ||
document.querySelectorAll('[class*="subtrack_"] td[class*="trackTitle_"]').forEach((elem) => { | ||
let text = elem.firstChild.textContent; | ||
elem.firstChild.textContent = ''; | ||
elem.insertAdjacentHTML('afterbegin', `<span class="trackTitle_">${text}</span>`); | ||
}); | ||
}); | ||
} | ||
|
||
// VARIOUS ARTISTS PAGES | ||
if (variousArtists.length) { | ||
// RELEASE PAGES WITH ARTISTS | ||
document.body.addEventListener('click', (event) => { | ||
if ( event?.target?.classList.length | ||
&& event?.target?.classList[0]?.includes('trackTitle_')) { | ||
|
||
let artist = event.target.parentElement.previousElementSibling, | ||
artistText = artist?.textContent?.replace('–', '').replaceAll('*', ''), | ||
trackTitle = event.target.textContent; | ||
// Only fire if track title span is clicked on | ||
if ( artistText && event.target.tagName === 'SPAN' ) { | ||
|
||
let searchString = encodeURIComponent(`${artistText} - ${trackTitle}`); | ||
|
||
window.open('https://www.google.com/search?udm=14&q=' + searchString); | ||
} | ||
} | ||
|
||
// MASTER RELEASE PAGES | ||
if ( event?.target?.classList.length | ||
&& event?.target?.classList[0]?.includes('trackTitleWithArtist_') | ||
|| event?.target.tagName === 'SPAN' | ||
&& event?.target?.parentElement?.classList[0]?.includes('trackTitleWithArtist_')) { | ||
|
||
let artist = event.target.parentElement.previousElementSibling, | ||
artistText = artist?.textContent?.replace('–', '').replaceAll('*', ''), | ||
trackTitle = event.target.textContent; | ||
// Only fire if track title span is clicked on | ||
if ( artistText && event?.target.tagName === 'SPAN' ) { | ||
|
||
let searchString = encodeURIComponent(`${artistText} - ${trackTitle}`); | ||
|
||
window.open('https://www.google.com/search?udm=14&q=' + searchString); | ||
} | ||
} | ||
|
||
}); | ||
// ARTISTS PAGES | ||
} else { | ||
// Tracklists without Artists | ||
document.body.addEventListener('click', (event) => { | ||
// Only fire if track title span is clicked on | ||
if ( event?.target?.classList.length | ||
&& event?.target?.classList[0]?.includes('trackTitle_') | ||
&& event.target.tagName === 'SPAN') { | ||
// Get artist name from document title to avoid including descriminators | ||
let artist = document.title.split(' –')[0], | ||
searchString = encodeURIComponent(`${artist} - ${event.target.textContent}`); | ||
|
||
window.open('https://www.google.com/search?udm=14&q=' + searchString); | ||
} | ||
// MASTER RELEASE PAGES | ||
if ( event?.target.tagName === 'SPAN' | ||
&& event?.target?.parentElement?.classList[0]?.includes('trackTitleNoArtist_')) { | ||
// Get artist name from document title to avoid including descriminators | ||
let artist = document.title.split(' -')[0], | ||
searchString = encodeURIComponent(`${artist} - ${event.target.textContent}`); | ||
|
||
window.open('https://www.google.com/search?udm=14&q=' + searchString); | ||
} | ||
}); | ||
} | ||
|
||
let rules = /*css*/` | ||
span[class*="trackTitle_"]:hover, | ||
td[class*="trackTitleWithArtist_"]:hover, | ||
td[class*="trackTitleNoArtist_"] span:hover { | ||
text-decoration: underline; | ||
cursor: pointer; | ||
} | ||
`; | ||
|
||
rl.attachCss('quick-search-tracks', rules); | ||
}); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,9 @@ module.exports = { | |
current: [ | ||
{ | ||
features: [{ | ||
name: 'Collection Box Location', | ||
description: 'Threw together a quick feature that moves the "In Collection" and "In Wantlist" boxes back to their original locations on the Release Page.', | ||
link: '#collectionBoxFix', | ||
name: 'Quick Search Tracklists', | ||
description: 'Allows you to search Google for the artist + trackname by clicking on the track title on a Master Release or Release page. I tested this against my own collection and it seems to work well but please get in touch if you find any issues with it: [email protected]', | ||
link: '#quick-search-tracklists', | ||
}], | ||
removedFeatures: [], | ||
updates: [ | ||
|
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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