forked from bigethan/pandora-userscript-fluid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpandora-fluid.user.js
103 lines (85 loc) · 3.35 KB
/
pandora-fluid.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* jquery comes along with the page */
//for auto sign in
var pandoraEmail = '[email protected]';
var pandoraPass = 'your-pandora-password';
//a couple styles to make the page layout more compactly
$("#brandingBar .rightcolumn").css('right', '210px !important');
$('#brandingBar .middlecolumn').css('left' ,'-211px !important');
//keep them playing by clicking the interface
//every 30 min
setInterval( function() {
$('.dots .dot').trigger('click');
}, 20*(60*1000));
//on a 1 second interval:
// - set a better page title
// - sometimes pandora gets confused, this clicks
// the reload link in their "we've messed up" message
setInterval( function() {
//page title
var stationName, songName, artistName;
stationName = $('#stationList .selected .stationNameText').text();
songName = $('#trackInfo .info .songTitle').text();
artistName = $('#trackInfo .info .artistSummary').text();
window.document.title = stationName + " :: " + artistName + " :: " + songName;
//reload link
var reloadLink;
reloadLink = $('.toastItemReload');
if(reloadLink.length) {
$('.toastItemReload').trigger('click');
}
//replace ad iframe with lastfm upcoming concernts
//didn't want to hide ads, but some of the ads were
//kinda offensive ("SINGLE LADIES IN YOUR AREA")
//this doesn't hide other ads, just where the bad ones were.
adFrames = $('#advertisement iframe');
if(adFrames[0] && adFrames[0].src.indexOf('last.fm') == -1) {
$('#advertisement).css('background-color', '#eee');
adFrames[0].src = 'http://m.last.fm/home/eventrecs';
}
}, 1000);
//auto sign in
//check to see if there's a login link or a user link
//as soon as there is one, either stop this loop or
//sign in .
loginInterval = setInterval( function() {
var submitted, processed, wasVisible;
processed = false;
wasVisible = false;
//if .anonymousUser is visible
if($("#brandingBar .anonymousUser").is(':visible')) {
//click on the .signInLink child
$('#brandingBar .anonymousUser .signInLink').trigger('click');
//fill and submit the form with pandoraEmail and pandoraPass
$(".signinForm input[name='email']").attr('value', pandoraEmail);
$(".signinForm input[name='password']").attr('value', pandoraPass);
submitted = $(".signinForm input[type='submit']").trigger('click');
if(submitted.length > 0) {
processed = true;
}
}
if(loginInterval && processed) {
clearInterval(loginInterval);
}
}, 500);
//add menu items
window.fluid.addDockMenuItem("Play", function() {
$('#playbackControl .playButton a').trigger('click');
});
window.fluid.addDockMenuItem("Pause", function() {
$('#playbackControl .pauseButton a').trigger('click');
});
window.fluid.addDockMenuItem("Pause for 5 min", function() {
$('#playbackControl .pauseButton a').trigger('click');
setTimeout(function() {
$('#playbackControl .playButton a').trigger('click');
}, (1000*60)*5);
});
window.fluid.addDockMenuItem("Thumbs Down", function() {
$('#playbackControl .thumbDownButton a').trigger('click');
});
window.fluid.addDockMenuItem("Thumbs Up", function() {
$('#playbackControl .thumbUpButton a').trigger('click');
});
window.fluid.addDockMenuItem("Skip Track", function() {
$('#playbackControl .skipButton a').trigger('click');
});