Created
November 8, 2017 16:39
-
-
Save sgardn/9370b6477b91b6d23831ab1c6f29e78d to your computer and use it in GitHub Desktop.
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
javascript: (function() { | |
console.log("inserting bookmarklet"); | |
function testAdd() { | |
currentSong = scrapeInfo(); | |
if (currentSong) { | |
dest = document.querySelectorAll("#pandora-output-list")[0]; | |
curVal = dest.value; | |
if (curVal.indexOf(currentSong.to_s) == -1) { | |
console.log("inserting new song!"); | |
console.log(currentSong.to_s); | |
dest.value = curVal + currentSong.to_s; | |
} else { | |
console.log("already inserted song...") | |
} | |
} else { | |
console.log("no song to add..."); | |
} | |
} | |
function scrapeInfo() { | |
song = document.querySelectorAll(".Marquee__wrapper__content")[0].innerText; | |
artist = document.querySelectorAll(".nowPlayingTopInfo__current__artistName")[0].innerText; | |
function printSong(artist, song) { | |
return artist + " - " + song + "\n"; | |
} | |
s = { | |
"song": song, | |
"artist": artist, | |
"to_s": printSong(artist, song) | |
}; | |
return s; | |
} | |
if (document.querySelectorAll("#pandora-output-list").length !== 0) { | |
alert("Already inserted the HTML."); | |
} else { | |
alert("Good to go!"); | |
elm = document.createElement("textarea"); | |
elm.id = "pandora-output-list"; | |
elm.style = "position:absolute; z-index:1; width: 450px; height: 400px; top=0; left=0; border: 4px solid #2D2D2D; padding: 10px; border-radius: 3px; margin-top: 10px; margin-left: 10px;"; | |
parentDiv = document.querySelectorAll("div.Nav")[0]; | |
parentDiv.insertBefore(elm, undefined); | |
setInterval(testAdd, 1000); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment