Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Commit

Permalink
Fix #406, prefer the active tab when a service matches several tabs
Browse files Browse the repository at this point in the history
As an example, with multiple YouTube tabs open, the active tab should be unpaused instead of just the first tab.
  • Loading branch information
ianb committed Oct 14, 2019
1 parent bbb45fc commit d3f99e7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions extension/background/serviceList.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,16 @@ this.serviceList = (function() {
}),
};
}
let best = 0;
for (let i = 0; i < tabs.length; i++) {
if (tabs[i].active) {
best = i;
}
}
if (activate) {
await browser.tabs.update(tabs[0].id, { active: activate });
await browser.tabs.update(tabs[best].id, { active: activate });
}
return { created: false, tab: tabs[0] };
return { created: false, tab: tabs[best] };
}

async getAllTabs(extraQuery) {
Expand Down

0 comments on commit d3f99e7

Please sign in to comment.