mirror of https://github.com/gorhill/uBlock.git
parent
d706415890
commit
36b1eac88e
|
@ -390,14 +390,15 @@ vAPI.tabs.registerListeners = function() {
|
||||||
|
|
||||||
vAPI.tabs.get = function(tabId, callback) {
|
vAPI.tabs.get = function(tabId, callback) {
|
||||||
if ( tabId === null ) {
|
if ( tabId === null ) {
|
||||||
chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
|
chrome.tabs.query(
|
||||||
|
{ active: true, currentWindow: true },
|
||||||
|
function(tabs) {
|
||||||
if ( chrome.runtime.lastError ) { /* noop */ }
|
if ( chrome.runtime.lastError ) { /* noop */ }
|
||||||
var tab = tabs && tabs[0];
|
callback(
|
||||||
if ( tab ) {
|
Array.isArray(tabs) && tabs.length !== 0 ? tabs[0] : null
|
||||||
tab.id = tab.id.toString();
|
);
|
||||||
}
|
}
|
||||||
callback(tab);
|
);
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1015,7 +1015,7 @@ var µb = µBlock,
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var getLoggerData = function(ownerId, tab, callback) {
|
var getLoggerData = function(ownerId, activeTabId, callback) {
|
||||||
var tabIds = {};
|
var tabIds = {};
|
||||||
for ( var tabId in µb.pageStores ) {
|
for ( var tabId in µb.pageStores ) {
|
||||||
var pageStore = µb.pageStoreFromTabId(tabId);
|
var pageStore = µb.pageStoreFromTabId(tabId);
|
||||||
|
@ -1023,9 +1023,8 @@ var getLoggerData = function(ownerId, tab, callback) {
|
||||||
if ( pageStore.rawURL.startsWith(extensionPageURL) ) { continue; }
|
if ( pageStore.rawURL.startsWith(extensionPageURL) ) { continue; }
|
||||||
tabIds[tabId] = pageStore.title;
|
tabIds[tabId] = pageStore.title;
|
||||||
}
|
}
|
||||||
var activeTabId;
|
if ( activeTabId && tabIds.hasOwnProperty(activeTabId) === false ) {
|
||||||
if ( tabIds.hasOwnProperty(tab.id) ) {
|
activeTabId = undefined;
|
||||||
activeTabId = tab.id;
|
|
||||||
}
|
}
|
||||||
callback({
|
callback({
|
||||||
colorBlind: µb.userSettings.colorBlindFriendly,
|
colorBlind: µb.userSettings.colorBlindFriendly,
|
||||||
|
@ -1083,7 +1082,11 @@ var onMessage = function(request, sender, callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vAPI.tabs.get(null, function(tab) {
|
vAPI.tabs.get(null, function(tab) {
|
||||||
getLoggerData(request.ownerId, tab, callback);
|
getLoggerData(
|
||||||
|
request.ownerId,
|
||||||
|
tab && tab.id.toString(),
|
||||||
|
callback
|
||||||
|
);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue