mirror of https://github.com/gorhill/uBlock.git
more fixes for #105
This commit is contained in:
parent
fcb65e6002
commit
7b8392ca48
|
@ -308,19 +308,23 @@ var tabsProgressListener = {
|
||||||
|
|
||||||
var tabId = vAPI.tabs.getTabId(browser);
|
var tabId = vAPI.tabs.getTabId(browser);
|
||||||
|
|
||||||
|
// LOCATION_CHANGE_SAME_DOCUMENT = "did not load a new document"
|
||||||
if ( flags & 1 ) {
|
if ( flags & 1 ) {
|
||||||
vAPI.tabs.onUpdated(tabId, {url: location.asciiSpec}, {
|
vAPI.tabs.onUpdated(tabId, {url: location.asciiSpec}, {
|
||||||
frameId: 0,
|
frameId: 0,
|
||||||
tabId: tabId,
|
tabId: tabId,
|
||||||
url: browser.currentURI.asciiSpec
|
url: browser.currentURI.asciiSpec
|
||||||
});
|
});
|
||||||
} else if ( location.schemeIs('http') || location.schemeIs('https') ) {
|
return;
|
||||||
vAPI.tabs.onNavigation({
|
|
||||||
frameId: 0,
|
|
||||||
tabId: tabId,
|
|
||||||
url: location.asciiSpec
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/105
|
||||||
|
// Allow any kind of pages
|
||||||
|
vAPI.tabs.onNavigation({
|
||||||
|
frameId: 0,
|
||||||
|
tabId: tabId,
|
||||||
|
url: location.asciiSpec
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1359,6 +1363,8 @@ vAPI.contextMenu.displayMenuItem = function(e) {
|
||||||
var menuitem = doc.getElementById(vAPI.contextMenu.menuItemId);
|
var menuitem = doc.getElementById(vAPI.contextMenu.menuItemId);
|
||||||
var currentURI = gContextMenu.browser.currentURI;
|
var currentURI = gContextMenu.browser.currentURI;
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/105
|
||||||
|
// TODO: Should the element picker works on any kind of pages?
|
||||||
if ( !currentURI.schemeIs('http') && !currentURI.schemeIs('https') ) {
|
if ( !currentURI.schemeIs('http') && !currentURI.schemeIs('https') ) {
|
||||||
menuitem.hidden = true;
|
menuitem.hidden = true;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -197,6 +197,8 @@ var getStats = function(tabId) {
|
||||||
r.hostnameDict = getHostnameDict(pageStore.hostnameToCountMap);
|
r.hostnameDict = getHostnameDict(pageStore.hostnameToCountMap);
|
||||||
r.contentLastModified = pageStore.contentLastModified;
|
r.contentLastModified = pageStore.contentLastModified;
|
||||||
r.dynamicFilterRules = getDynamicFilterRules(pageStore.pageHostname, r.hostnameDict);
|
r.dynamicFilterRules = getDynamicFilterRules(pageStore.pageHostname, r.hostnameDict);
|
||||||
|
r.canElementPicker = r.pageHostname.indexOf('.') !== -1;
|
||||||
|
r.canRequestLog = canRequestLog;
|
||||||
} else {
|
} else {
|
||||||
r.hostnameDict = {};
|
r.hostnameDict = {};
|
||||||
r.dynamicFilterRules = getDynamicFilterRules();
|
r.dynamicFilterRules = getDynamicFilterRules();
|
||||||
|
@ -204,9 +206,15 @@ var getStats = function(tabId) {
|
||||||
return r;
|
return r;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Not the most elegant approach, but it does keep everything simple:
|
||||||
|
// This will be set by getTargetTabId() and used by getStats().
|
||||||
|
var canRequestLog = true;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var getTargetTabId = function(tab) {
|
var getTargetTabId = function(tab) {
|
||||||
|
canRequestLog = true;
|
||||||
|
|
||||||
if ( !tab ) {
|
if ( !tab ) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -220,11 +228,14 @@ var getTargetTabId = function(tab) {
|
||||||
// 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.
|
||||||
|
|
||||||
|
canRequestLog = false;
|
||||||
|
|
||||||
// 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=([^&]+)/);
|
||||||
if ( matches && matches.length === 2 ) {
|
if ( matches && matches.length === 2 ) {
|
||||||
return matches[1];
|
return matches[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
return tab.id;
|
return tab.id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -298,23 +298,13 @@ var buildAllDynamicFilters = function() {
|
||||||
var renderPopup = function() {
|
var renderPopup = function() {
|
||||||
uDom('#appname').text(popupData.appName);
|
uDom('#appname').text(popupData.appName);
|
||||||
uDom('#version').text(popupData.appVersion);
|
uDom('#version').text(popupData.appVersion);
|
||||||
|
|
||||||
var isHTTP = /^https?:\/\/[0-9a-z]/.test(popupData.pageURL);
|
|
||||||
|
|
||||||
// Condition for dynamic filtering toggler:
|
|
||||||
// - Advanced user
|
|
||||||
uDom('body').toggleClass('advancedUser', popupData.advancedUserEnabled);
|
uDom('body').toggleClass('advancedUser', popupData.advancedUserEnabled);
|
||||||
|
|
||||||
uDom('#switch').toggleClass('off', popupData.pageURL === '' || !popupData.netFilteringSwitch);
|
uDom('#switch').toggleClass('off', popupData.pageURL === '' || !popupData.netFilteringSwitch);
|
||||||
|
|
||||||
// Conditions for request log:
|
// If you think the `=== true` is pointless, you are mistaken
|
||||||
// - `http` or `https` scheme
|
uDom('#gotoLog').toggleClass('enabled', popupData.canRequestLog === true)
|
||||||
uDom('#gotoLog').toggleClass('enabled', isHTTP);
|
.attr('href', 'devtools.html?tabId=' + popupData.tabId);
|
||||||
uDom('#gotoLog').attr('href', 'devtools.html?tabId=' + popupData.tabId);
|
uDom('#gotoPick').toggleClass('enabled', popupData.canElementPicker === true);
|
||||||
|
|
||||||
// Conditions for element picker:
|
|
||||||
// - `http` or `https` scheme
|
|
||||||
uDom('#gotoPick').toggleClass('enabled', isHTTP);
|
|
||||||
|
|
||||||
var or = vAPI.i18n('popupOr');
|
var or = vAPI.i18n('popupOr');
|
||||||
var blocked = popupData.pageBlockedRequestCount;
|
var blocked = popupData.pageBlockedRequestCount;
|
||||||
|
|
Loading…
Reference in New Issue