mirror of https://github.com/gorhill/uBlock.git
fixed turning off cosmetic filters
This commit is contained in:
parent
f5dee8230a
commit
5213fecaad
|
@ -554,11 +554,13 @@ FilterContainer.prototype.addFilterEntry = function(hash, f) {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
FilterContainer.prototype.retrieveGenericSelectors = function(request) {
|
FilterContainer.prototype.retrieveGenericSelectors = function(tabHostname, request) {
|
||||||
|
if ( !tabHostname || µb.getCosmeticFilteringSwitch(tabHostname) !== true ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ( µb.userSettings.parseAllABPHideFilters !== true ) {
|
if ( µb.userSettings.parseAllABPHideFilters !== true ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !request.selectors ) {
|
if ( !request.selectors ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -614,11 +616,13 @@ FilterContainer.prototype.retrieveGenericSelectors = function(request) {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
FilterContainer.prototype.retrieveDomainSelectors = function(request) {
|
FilterContainer.prototype.retrieveDomainSelectors = function(tabHostname, request) {
|
||||||
|
if ( !tabHostname || µb.getCosmeticFilteringSwitch(tabHostname) !== true ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ( µb.userSettings.parseAllABPHideFilters !== true ) {
|
if ( µb.userSettings.parseAllABPHideFilters !== true ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !request.locationURL ) {
|
if ( !request.locationURL ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -629,11 +633,13 @@ FilterContainer.prototype.retrieveDomainSelectors = function(request) {
|
||||||
//bucketTestCount = 0;
|
//bucketTestCount = 0;
|
||||||
|
|
||||||
var hostname = pageHostname = µb.URI.hostnameFromURI(request.locationURL);
|
var hostname = pageHostname = µb.URI.hostnameFromURI(request.locationURL);
|
||||||
|
|
||||||
var r = {
|
var r = {
|
||||||
domain: µb.URI.domainFromHostname(hostname),
|
domain: µb.URI.domainFromHostname(hostname),
|
||||||
hide: [],
|
hide: [],
|
||||||
donthide: []
|
donthide: []
|
||||||
};
|
};
|
||||||
|
|
||||||
var bucket;
|
var bucket;
|
||||||
var hash = makePrefixHash('#', r.domain);
|
var hash = makePrefixHash('#', r.domain);
|
||||||
if ( bucket = this.filters[hash] ) {
|
if ( bucket = this.filters[hash] ) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ return {
|
||||||
userSettings: {
|
userSettings: {
|
||||||
showIconBadge: true,
|
showIconBadge: true,
|
||||||
parseAllABPHideFilters: true,
|
parseAllABPHideFilters: true,
|
||||||
exceptionList: {}
|
netExceptionList: {}
|
||||||
},
|
},
|
||||||
localSettings: {
|
localSettings: {
|
||||||
blockedRequestCount: 0,
|
blockedRequestCount: 0,
|
||||||
|
|
|
@ -104,13 +104,19 @@ var onMessage = function(request, sender, callback) {
|
||||||
// Sync
|
// Sync
|
||||||
var response;
|
var response;
|
||||||
|
|
||||||
|
var pageStore;
|
||||||
|
if ( sender && sender.tab ) {
|
||||||
|
pageStore = µBlock.pageStoreFromTabId(sender.tab.id);
|
||||||
|
}
|
||||||
|
var tabHostname = pageStore ? pageStore.pageHostname : '';
|
||||||
|
|
||||||
switch ( request.what ) {
|
switch ( request.what ) {
|
||||||
case 'retrieveDomainCosmeticSelectors':
|
case 'retrieveDomainCosmeticSelectors':
|
||||||
response = µBlock.abpHideFilters.retrieveDomainSelectors(request);
|
response = µBlock.abpHideFilters.retrieveDomainSelectors(tabHostname, request);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'retrieveGenericCosmeticSelectors':
|
case 'retrieveGenericCosmeticSelectors':
|
||||||
response = µBlock.abpHideFilters.retrieveGenericSelectors(request);
|
response = µBlock.abpHideFilters.retrieveGenericSelectors(tabHostname, request);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
34
js/ublock.js
34
js/ublock.js
|
@ -24,13 +24,13 @@
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
µBlock.getNetFilteringSwitch = function(hostname) {
|
µBlock.getNetFilteringSwitch = function(hostname) {
|
||||||
var exceptionList = this.userSettings.exceptionList;
|
var netExceptionList = this.userSettings.netExceptionList;
|
||||||
if ( exceptionList[hostname] !== undefined ) {
|
if ( netExceptionList[hostname] !== undefined ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var hostnames = this.URI.parentHostnamesFromHostname(hostname);
|
var hostnames = this.URI.parentHostnamesFromHostname(hostname);
|
||||||
while ( hostname = hostnames.shift() ) {
|
while ( hostname = hostnames.shift() ) {
|
||||||
if ( exceptionList[hostname] !== undefined ) {
|
if ( netExceptionList[hostname] !== undefined ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,11 +47,11 @@
|
||||||
if ( newState === currentState ) {
|
if ( newState === currentState ) {
|
||||||
return currentState;
|
return currentState;
|
||||||
}
|
}
|
||||||
var exceptionList = this.userSettings.exceptionList;
|
var netExceptionList = this.userSettings.netExceptionList;
|
||||||
|
|
||||||
// Add to exception list
|
// Add to exception list
|
||||||
if ( !newState ) {
|
if ( !newState ) {
|
||||||
exceptionList[hostname] = true;
|
netExceptionList[hostname] = true;
|
||||||
this.saveExceptionList();
|
this.saveExceptionList();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,8 @@
|
||||||
if ( newState ) {
|
if ( newState ) {
|
||||||
var hostnames = this.URI.allHostnamesFromHostname(hostname);
|
var hostnames = this.URI.allHostnamesFromHostname(hostname);
|
||||||
while ( hostname = hostnames.shift() ) {
|
while ( hostname = hostnames.shift() ) {
|
||||||
if ( exceptionList[hostname] !== undefined ) {
|
if ( netExceptionList[hostname] !== undefined ) {
|
||||||
delete exceptionList[hostname];
|
delete netExceptionList[hostname];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.saveExceptionList();
|
this.saveExceptionList();
|
||||||
|
@ -71,9 +71,27 @@
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
// For now we will use the net exception list
|
||||||
|
|
||||||
|
µBlock.getCosmeticFilteringSwitch = function(hostname) {
|
||||||
|
var netExceptionList = this.userSettings.netExceptionList;
|
||||||
|
if ( netExceptionList[hostname] !== undefined ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var hostnames = this.URI.parentHostnamesFromHostname(hostname);
|
||||||
|
while ( hostname = hostnames.shift() ) {
|
||||||
|
if ( netExceptionList[hostname] !== undefined ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
µBlock.saveExceptionList = function() {
|
µBlock.saveExceptionList = function() {
|
||||||
chrome.storage.local.set({
|
chrome.storage.local.set({
|
||||||
'exceptionList': this.userSettings.exceptionList
|
'netExceptionList': this.userSettings.netExceptionList
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue