Last active
February 10, 2018 19:52
-
-
Save schuyberg/12b5ded2bcfa1369934f66b0eb9c4032 to your computer and use it in GitHub Desktop.
Browse Spotify by Label! -- a Tampermonkey script to make copyright statements into hyperlinks in Spotify web player
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
// ==UserScript== | |
// @name Spotify: Linked Labels | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description make Label Copyrights into hyperlinks in Spotify: Browse Music by Label! | |
// @author schuyberg | |
// @match https://open.spotify.com/* | |
// @grant none | |
// @require http://code.jquery.com/jquery-3.2.1.min.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Your code here.. | |
var $ = jQuery; | |
if (!$) { return console.log('no jquery found!'); } | |
window.setInterval(function(){ | |
var copyrights = $('.copyrights p'); | |
if (copyrights.has('a').length > 0) { return; } | |
copyrights.replaceWith(function() { | |
var self = $(this); | |
var txt = self.text(); | |
var label = txt.match(/(\d+\s)(.*$)/)[2]; | |
var url = "https://open.spotify.com/search/results/label%3A%22" + encodeURIComponent(label) + '%22'; | |
var link = $("<a></a>").attr("href",url).append(txt); | |
console.log('replacing label link: ', url); | |
return $("<p></p>").append(link); | |
}); | |
}, 2000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment