Skip to content

Instantly share code, notes, and snippets.

@nrmitchi
Last active December 14, 2015 05:19
Show Gist options
  • Save nrmitchi/5034413 to your computer and use it in GitHub Desktop.
Save nrmitchi/5034413 to your computer and use it in GitHub Desktop.
Scroll title/artist in tab title for Pandora
// Copy/paste into Console/Firebug
window.PandoraTitleScroller = {}
window.PandoraTitleScroller.index = 0;
window.PandoraTitleScroller.length = 20;
window.PandoraTitleScroller.title = $('.trackData').children().first().children().first().html() + ' by ' + $('.trackData').children().eq(1).children().eq(1).html();
//Kinda buggy but it works for what I wanted
window.setInterval(function () {
var title = $('.trackData').children().first().children().first().html() + ' by ' + $('.trackData').children().eq(1).children().eq(1).html();
//If song has changed
if (title != window.PandoraTitleScroller.title) {
window.PandoraTitleScroller.title = title;
window.PandoraTitleScroller.index = 0;
}
var doubleTitle = title+' - '+title;
var display = doubleTitle.substr(window.PandoraTitleScroller.index, window.PandoraTitleScroller.length);
//Skip spaces on the far left, as they are not displayed anyways and it looks jumpy
while (display.substr(0,1) == ' ') {
window.PandoraTitleScroller.index++;
display = doubleTitle.substr(window.PandoraTitleScroller.index, window.PandoraTitleScroller.length);
}
//If title is longer than display, increment it one next time
if (title.length > window.PandoraTitleScroller.length) {
window.PandoraTitleScroller.index++;
if (window.PandoraTitleScroller.index == (title.length + 4)) {
window.PandoraTitleScroller.index = 1;
}
display = display+'...';
} else {
display = title;
}
window.document.title = display;
}, 350);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment