Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Commit

Permalink
migrated to manifest_version = 2
Browse files Browse the repository at this point in the history
  • Loading branch information
david-sabata committed Jul 4, 2012
1 parent f088002 commit 54699b4
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 102 deletions.
9 changes: 9 additions & 0 deletions background-ga.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-16968457-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
22 changes: 0 additions & 22 deletions background.html

This file was deleted.

13 changes: 0 additions & 13 deletions dummy.html

This file was deleted.

20 changes: 15 additions & 5 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,24 @@
"128": "icon128.png"
},

"background_page": "background.html",
"manifest_version": 2,
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'",

"web_accessible_resources": [
"icon128.png"
],

"background": {
"scripts": ["background-ga.js", "md5.js", "jquery-1.6.1.min.js", "jquery.dump.js", "scrobbler.js"]
},

"options_page": "options.html",

"permissions": [
"tabs",
"notifications",
"http://ws.audioscrobbler.com/2.0/",
"http://gdata.youtube.com/feeds/api/videos/"
"tabs",
"notifications",
"http://ws.audioscrobbler.com/2.0/",
"http://gdata.youtube.com/feeds/api/videos/"
],

"page_action": {
Expand Down
63 changes: 2 additions & 61 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="jquery.dump.js"></script>
<script type="text/javascript" src="popup.js"></script>
<style>
body {
color: #D51007;
font-family: "Lucida Grande",Arial,Helvetica,Verdana,sans-serif;
}
}
#wrapper {
width: 210px;
}
Expand All @@ -22,66 +23,6 @@
text-align: center;
}
</style>
<script type="text/javascript">
$(function(){
/*
var o = '<pre>';
for (var x in chrome.extension.getBackgroundPage().song) {
o += x + ' : ' + chrome.extension.getBackgroundPage().song[x] + '\n';
}
o += '</pre>';
$(o).appendTo('body');
*/

if (chrome.extension.getBackgroundPage().song.artist != '')
$('#artist').val(chrome.extension.getBackgroundPage().song.artist);

if (chrome.extension.getBackgroundPage().song.track != '')
$('#track').val(chrome.extension.getBackgroundPage().song.track);


$('#submit').click(function(){
$(this).attr('disabled', true);
$(this).siblings().remove();

var artist = $('#artist').val();
var track = $('#track').val();
var res = chrome.extension.getBackgroundPage().validate( artist, track );

if (res == false) {
$(this).attr('disabled', false);
$(this).siblings().remove();
$(this).parent().append('<span class="note">Not valid</span>');
}
else {
// did the content script recognize at least the duration?
if (!chrome.extension.getBackgroundPage().song.duration)
chrome.extension.getBackgroundPage().song.duration = res.duration;

// fill other data
chrome.extension.getBackgroundPage().song.artist = res.artist;
chrome.extension.getBackgroundPage().song.track = res.track;
//chrome.extension.getBackgroundPage().song.album = res.album;

// make the connection to last.fm service to notify
chrome.extension.getBackgroundPage().nowPlaying();

// The minimum time is 240 seconds or half the track's total length
// minus the time that already past
var past = parseInt(new Date().getTime() / 1000.0) - chrome.extension.getBackgroundPage().song.startTime;
var min_time = Math.min(240, chrome.extension.getBackgroundPage().song.duration / 2) - past;

// Set up the timer to scrobble
chrome.extension.getBackgroundPage().scrobbleTimeout = chrome.extension.getBackgroundPage().setTimeout(chrome.extension.getBackgroundPage().submit, min_time * 1000);

$('#form').fadeOut(0);
$('#valid').fadeIn(0);
}

});

});
</script>
</head>
<body>
<div id="wrapper">
Expand Down
58 changes: 58 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
$(function(){
/*
var o = '<pre>';
for (var x in chrome.extension.getBackgroundPage().song) {
o += x + ' : ' + chrome.extension.getBackgroundPage().song[x] + '\n';
}
o += '</pre>';
$(o).appendTo('body');
*/

if (chrome.extension.getBackgroundPage().song.artist != '')
$('#artist').val(chrome.extension.getBackgroundPage().song.artist);

if (chrome.extension.getBackgroundPage().song.track != '')
$('#track').val(chrome.extension.getBackgroundPage().song.track);


$('#submit').click(function(){
$(this).attr('disabled', true);
$(this).siblings().remove();

var artist = $('#artist').val();
var track = $('#track').val();
var res = chrome.extension.getBackgroundPage().validate( artist, track );

if (res == false) {
$(this).attr('disabled', false);
$(this).siblings().remove();
$(this).parent().append('<span class="note">Not valid</span>');
}
else {
// did the content script recognize at least the duration?
if (!chrome.extension.getBackgroundPage().song.duration)
chrome.extension.getBackgroundPage().song.duration = res.duration;

// fill other data
chrome.extension.getBackgroundPage().song.artist = res.artist;
chrome.extension.getBackgroundPage().song.track = res.track;
//chrome.extension.getBackgroundPage().song.album = res.album;

// make the connection to last.fm service to notify
chrome.extension.getBackgroundPage().nowPlaying();

// The minimum time is 240 seconds or half the track's total length
// minus the time that already past
var past = parseInt(new Date().getTime() / 1000.0) - chrome.extension.getBackgroundPage().song.startTime;
var min_time = Math.min(240, chrome.extension.getBackgroundPage().song.duration / 2) - past;

// Set up the timer to scrobble
chrome.extension.getBackgroundPage().scrobbleTimeout = chrome.extension.getBackgroundPage().setTimeout(chrome.extension.getBackgroundPage().submit, min_time * 1000);

$('#form').fadeOut(0);
$('#valid').fadeIn(0);
}

});

});
2 changes: 1 addition & 1 deletion scrobbler.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function setActionIcon(action, tabId) {
case ACTION_REENABLED:
chrome.pageAction.setIcon({tabId: tab, path: ICON_TICK_DISABLED});
chrome.pageAction.setTitle({tabId: tab, title: 'Scrobbling will continue for the next song'});
chrome.pageAction.setPopup({tabId: tab, popup: 'dummy.html'});
chrome.pageAction.setPopup({tabId: tab, popup: ''});
break;
case ACTION_CONN_DISABLED:
chrome.pageAction.setIcon({tabId: tab, path: ICON_CONN_DISABLED});
Expand Down

0 comments on commit 54699b4

Please sign in to comment.