-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlyrics.user.js
44 lines (34 loc) · 1.54 KB
/
lyrics.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// ==UserScript==
// @name Working lyrics
// @namespace roulyo
// @include https://subsonic.mogmi.fr/*
// @version 1.1
// @grant none
// ==/UserScript==
(function() {
'use strict';
if (window.frameElement && window.frameElement.name !== "right")
{
return;
}
function swapLyricsLink()
{
document.removeEventListener("DOMSubtreeModified", swapLyricsLink, false);
let lyricsLinks = document.getElementsByClassName("now-playing-lyrics");
for (let i = 0; i < lyricsLinks.length; ++i)
{
let lyricsLink = lyricsLinks[i];
let grandParent = lyricsLink.parentElement.parentElement;
let title = encodeURIComponent(grandParent.getElementsByClassName("now-playing-title")[0].innerHTML.replace(/\s+/g, "-"));
let artist = encodeURIComponent(grandParent.getElementsByClassName("now-playing-artist")[0].innerHTML.replace(/\s+/g, "-"));
let newLyricsLink = document.createElement("a");
newLyricsLink.href = "https://genius.com/" + artist + "-" + title + "-lyrics";
newLyricsLink.innerText = "Lyrics";
newLyricsLink.className = "now-playing-lyrics clickable";
newLyricsLink.target = "_blank";
lyricsLink.parentNode.replaceChild(newLyricsLink, lyricsLink);
}
document.addEventListener("DOMSubtreeModified", swapLyricsLink, false);
}
document.addEventListener("DOMSubtreeModified", swapLyricsLink, false);
})();