FF bug workaround for tabs.query with moz-extension://

This commit is contained in:
tophf 2017-06-06 10:33:45 +03:00
parent ac5e9b965a
commit 6df2392132

View File

@ -133,8 +133,10 @@ function openURL({url, currentWindow = true}) {
return new Promise(resolve => {
// [some] chromium forks don't handle their fake branded protocols
url = url.replace(/^(opera|vivaldi)/, 'chrome');
// FF doesn't handle moz-extension:// URLs (bug)
// API doesn't handle the hash-fragment part
chrome.tabs.query({url: url.replace(/#.*/, ''), currentWindow}, tabs => {
const urlQuery = url.startsWith('moz-extension') ? undefined : url.replace(/#.*/, '');
chrome.tabs.query({url: urlQuery, currentWindow}, tabs => {
for (const tab of tabs) {
if (tab.url == url) {
activateTab(tab).then(resolve);