Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

prevent multiple grooveshark tabs from making popup flicker

  • Loading branch information...
commit 0bc260a1a68dd8b53bed18587018760a1a1d0ab2 1 parent 7eadab2
@adammw adammw authored
Showing with 5 additions and 2 deletions.
  1. +1 −1  background.html
  2. +1 −1  manifest.json
  3. +3 −0  sharkzapper_popup.html
View
2  background.html
@@ -61,7 +61,7 @@
console.log('Got popup init, re-checking tabs');
//get_gs_tab(function(sendResponse) { return function(){ console.log('Sending popup init response'); } }(sendResponse));
get_gs_tab(function(){
- chrome.extension.sendRequest({"command":"popupUpdate","enabled":true});
+ chrome.extension.sendRequest({"command":"popupUpdate","enabled":true,"tabId":gsTabs[0]});
chrome.tabs.sendRequest(gsTabs[0], {"command":"updateStatus"});
},respond_callback({"command":"popupUpdate","enabled":false}));
break;
View
2  manifest.json
@@ -1,6 +1,6 @@
{
"name": "sharkzapper",
- "version": "1.1.1",
+ "version": "1.1.2",
"description": "Control Grooveshark HTML5 Player and see what's playing",
"icons": {
View
3  sharkzapper_popup.html
@@ -61,6 +61,7 @@
<script type="text/javascript">
var defaultAlbumArtUrl = 'http://static.a.gs-cdn.net/webincludes/images/default/album_100.png';
var songId = null;
+ var tabId = null;
String.prototype.pad = function(l, s){
return (l -= this.length) > 0
@@ -107,6 +108,7 @@
function(request, sender, sendResponse) {
console.log(request);
if (!request.command) return;
+ if (tabId && sender.tab.id != tabId) return; //stop multiple tabs sending us updates
switch (request.command) {
case 'popupUpdate':
if (request.enabled) {
@@ -118,6 +120,7 @@
$('body').addClass('notPlaying');
$('button').attr('disabled','disabled');
}
+ if (request.tabId) tabId = request.tabId;
break;
case 'statusUpdate':
console.log('statusUpdate!');
Please sign in to comment.
Something went wrong with that request. Please try again.