mirror of https://github.com/gorhill/uBlock.git
code review
This commit is contained in:
parent
5ba92ef484
commit
a64bca0fa6
|
@ -211,13 +211,14 @@ var getTargetTabId = function(tab) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( tab.url.lastIndexOf(vAPI.getURL('devtools.html'), 0) !== 0 ) {
|
||||||
|
return tab.id;
|
||||||
|
}
|
||||||
|
|
||||||
// If the URL is that of the network request logger, fill the popup with
|
// If the URL is that of the network request logger, fill the popup with
|
||||||
// the data from the tab being observed by the logger.
|
// the data from the tab being observed by the logger.
|
||||||
// This allows a user to actually modify filtering profile for
|
// This allows a user to actually modify filtering profile for
|
||||||
// behind-the-scene requests.
|
// behind-the-scene requests.
|
||||||
if ( tab.url.indexOf(vAPI.getURL('devtools.html')) !== 0 ) {
|
|
||||||
return tab.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract the target tab id from the URL
|
// Extract the target tab id from the URL
|
||||||
var matches = tab.url.match(/[\?&]tabId=([^&]+)/);
|
var matches = tab.url.match(/[\?&]tabId=([^&]+)/);
|
||||||
|
@ -234,8 +235,7 @@ var onMessage = function(request, sender, callback) {
|
||||||
switch ( request.what ) {
|
switch ( request.what ) {
|
||||||
case 'getPopupData':
|
case 'getPopupData':
|
||||||
vAPI.tabs.get(null, function(tab) {
|
vAPI.tabs.get(null, function(tab) {
|
||||||
var tabId = getTargetTabId(tab);
|
callback(getStats(getTargetTabId(tab)));
|
||||||
callback(getStats(tabId));
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -792,8 +792,14 @@ var getPageDetails = function(callback) {
|
||||||
var out = {};
|
var out = {};
|
||||||
var tabIds = Object.keys(µb.pageStores);
|
var tabIds = Object.keys(µb.pageStores);
|
||||||
|
|
||||||
// Just in case... I expect there will always be a behind-the-scene page
|
// Special case: behind-the-scene virtual tab (does not really exist)
|
||||||
// store, but just to be safe.
|
var pos = tabIds.indexOf(vAPI.noTabId);
|
||||||
|
if ( pos !== -1 ) {
|
||||||
|
tabIds.splice(pos, 1);
|
||||||
|
out[vAPI.noTabId] = vAPI.i18n('logBehindTheScene');
|
||||||
|
}
|
||||||
|
|
||||||
|
// This can happen
|
||||||
if ( tabIds.length === 0 ) {
|
if ( tabIds.length === 0 ) {
|
||||||
callback(out);
|
callback(out);
|
||||||
return;
|
return;
|
||||||
|
@ -807,12 +813,11 @@ var getPageDetails = function(callback) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Let's not populate the page selector with reference itself
|
// Let's not populate the page selector with reference to self
|
||||||
var devtoolsURL = vAPI.getURL('devtools.html');
|
var devtoolsURL = vAPI.getURL('devtools.html');
|
||||||
var devtoolsURLLen = devtoolsURL.length;
|
|
||||||
|
|
||||||
var onTabDetails = function(tab) {
|
var onTabDetails = function(tab) {
|
||||||
if ( tab && tab.url.slice(0, devtoolsURLLen) !== devtoolsURL ) {
|
if ( tab && tab.url.lastIndexOf(devtoolsURL, 0) !== 0 ) {
|
||||||
out[tab.id] = tab.title;
|
out[tab.id] = tab.title;
|
||||||
}
|
}
|
||||||
doCountdown();
|
doCountdown();
|
||||||
|
@ -820,13 +825,7 @@ var getPageDetails = function(callback) {
|
||||||
|
|
||||||
var i = countdown;
|
var i = countdown;
|
||||||
while ( i-- ) {
|
while ( i-- ) {
|
||||||
// Special case: behind-the-scene virtual tab (does not really exist)
|
vAPI.tabs.get(tabIds[i], onTabDetails);
|
||||||
if ( vAPI.isNoTabId(tabIds[i]) ) {
|
|
||||||
out[vAPI.noTabId] = vAPI.i18n('logBehindTheScene');
|
|
||||||
doCountdown();
|
|
||||||
} else {
|
|
||||||
vAPI.tabs.get(tabIds[i], onTabDetails);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue