Skip to content

Commit

Permalink
style: take code out function "script"
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-egerton committed Feb 24, 2023
1 parent 49678a4 commit 2081f5f
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions spotify2tabs.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
function script() {
const songPlaying = document.querySelector('[data-testid=context-item-link]').textContent;
const artist = document.querySelector('[data-testid=context-item-info-artist]').textContent;
let searchQuery = artist.concat('%20', songPlaying).replace(/ /g, "%20");
const songPlaying = document.querySelector('[data-testid=context-item-link]').textContent;
const artist = document.querySelector('[data-testid=context-item-info-artist]').textContent;
let searchQuery = artist.concat('%20', songPlaying).replace(/ /g, "%20");

if (searchQuery.includes('(')) {
searchQuery = searchQuery.slice(0, searchQuery.indexOf('('));
}
if (searchQuery.includes('-')) {
searchQuery = searchQuery.slice(0, searchQuery.indexOf('-'));
}
if (searchQuery.includes('&')) {
searchQuery = searchQuery.replace(/&/g, "and");
}
if (searchQuery.includes('(')) {
searchQuery = searchQuery.slice(0, searchQuery.indexOf('('));
}
if (searchQuery.includes('-')) {
searchQuery = searchQuery.slice(0, searchQuery.indexOf('-'));
}
if (searchQuery.includes('&')) {
searchQuery = searchQuery.replace(/&/g, "and");
}

const url = `https://www.ultimate-guitar.com/search.php?search_type=title&value=${searchQuery}`;
const url = `https://www.ultimate-guitar.com/search.php?search_type=title&value=${searchQuery}`;

window.open(url);
}
script();
window.open(url);

0 comments on commit 2081f5f

Please sign in to comment.