Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hi david #57

Merged
merged 3 commits into from
May 26, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion manifest.json
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
{ {
"name": "Last.fm Scrobbler", "name": "Last.fm Scrobbler",
"version": "1.8", "version": "1.8.1",


"description": "Scrobble music all around the web!", "description": "Scrobble music all around the web!",
"icons": { "icons": {
Expand Down Expand Up @@ -55,6 +55,10 @@
"matches": ["*://fizy.com/*"], "matches": ["*://fizy.com/*"],
"js": ["jquery-1.6.1.min.js", "jquery.dump.js", "fizy.js"] "js": ["jquery-1.6.1.min.js", "jquery.dump.js", "fizy.js"]
}, },
{
"matches": ["http://www.virginradioturkiye.com/live","http://live.radioeksen.com/live"],
"js": ["jquery-1.6.1.min.js", "jquery.dump.js", "virginradiotr.js"]
},
{ {
"matches": ["http://ghostly.com/discovery/play"], "matches": ["http://ghostly.com/discovery/play"],
"js": ["jquery-1.6.1.min.js", "jquery.dump.js", "ghostly.js"], "js": ["jquery-1.6.1.min.js", "jquery.dump.js", "ghostly.js"],
Expand Down
130 changes: 130 additions & 0 deletions virginradiotr.js
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
*
* Chrome-Last.fm-Scrobbler
* http://www.virginradioturkiye.com/live
* http://live.radioeksen.com/live
*
*
*
* Connector by Salim KAYABAŞI
* http://www.salimkayabasi.com
* to debug change its' status to 'true'
*/

var artist = '';
var track = '';
var isNewSong = true;
var playingSong = '#playingSong';
var debug = false;


$(function(){
process();
$(playingSong).bind('DOMSubtreeModified',function(e){
process();
});
// bind page unload function to discard current "now listening"
$(window).unload(function() {
// reset the background scrobbler song data
chrome.extension.sendRequest({type: 'reset'});
return true;
});
});

function process()
{
if(document.getElementById('playPauseButton').innerText != 'Başlat/Duraklat')
{
if(debug)
{
console.log('not playing');
}
return;
}
else{
if(debug)
{
console.log('playing now');
}
}
if(parseTrack())
{
try{
if(isNewSong)
{
chrome.extension.sendRequest({type: 'validate', artist: artist, track: track}, function(response) {
if (response != false){
chrome.extension.sendRequest({type: 'nowPlaying', artist: artist, track: track, duration: '245'});
if(debug)
{
console.log('--scrobbling--')
}
}
else
{
if(debug)
{
console.log(response);
}
}
});
}
}
catch(e){
if(debug)
{
console.log(e);
}
}
}
};


function parseTrack()
{
var song = document.getElementById('playingSong').innerText.trim();
if(song == '')
{
if(debug)
{
console.log('NotFound: Song');
}
return false;
}
if(song.indexOf('Program / Tanıtım / Reklam') != -1)
{
if(debug)
{
console.log('advertisement will not send to Last.fm');
}
return false;
}
if(song.indexOf('Sonraki Şarkı') != -1)
{
song = song.substring(0,song.indexOf('Sonraki Şarkı'));
}
separation = song.lastIndexOf(' - ');

var TMPtrack = song.substring(0, separation).trim();
var TMPartist = song.substring(separation+3).trim();
if(artist != TMPartist && track != TMPtrack)
{
isNewSong = true;
artist = TMPartist;
track = TMPtrack;
if(debug)
{
console.log('NEW SONG ' +track +' from '+artist);
}
}
else
{
isNewSong = false;
if(debug)
{
console.log('SAME SONG ' +track +' from '+artist);
}
}

return true;
}