1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-08 04:49:12 +02:00

fixed turning off cosmetic filters

This commit is contained in:
gorhill 2014-06-23 19:23:36 -04:00
parent f5dee8230a
commit 5213fecaad
4 changed files with 45 additions and 15 deletions

View File

@ -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 ) {
return;
}
if ( !request.selectors ) {
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 ) {
return;
}
if ( !request.locationURL ) {
return;
}
@ -629,11 +633,13 @@ FilterContainer.prototype.retrieveDomainSelectors = function(request) {
//bucketTestCount = 0;
var hostname = pageHostname = µb.URI.hostnameFromURI(request.locationURL);
var r = {
domain: µb.URI.domainFromHostname(hostname),
hide: [],
donthide: []
};
var bucket;
var hash = makePrefixHash('#', r.domain);
if ( bucket = this.filters[hash] ) {

View File

@ -33,7 +33,7 @@ return {
userSettings: {
showIconBadge: true,
parseAllABPHideFilters: true,
exceptionList: {}
netExceptionList: {}
},
localSettings: {
blockedRequestCount: 0,

View File

@ -104,13 +104,19 @@ var onMessage = function(request, sender, callback) {
// Sync
var response;
var pageStore;
if ( sender && sender.tab ) {
pageStore = µBlock.pageStoreFromTabId(sender.tab.id);
}
var tabHostname = pageStore ? pageStore.pageHostname : '';
switch ( request.what ) {
case 'retrieveDomainCosmeticSelectors':
response = µBlock.abpHideFilters.retrieveDomainSelectors(request);
response = µBlock.abpHideFilters.retrieveDomainSelectors(tabHostname, request);
break;
case 'retrieveGenericCosmeticSelectors':
response = µBlock.abpHideFilters.retrieveGenericSelectors(request);
response = µBlock.abpHideFilters.retrieveGenericSelectors(tabHostname, request);
break;
default:

View File

@ -24,13 +24,13 @@
/******************************************************************************/
µBlock.getNetFilteringSwitch = function(hostname) {
var exceptionList = this.userSettings.exceptionList;
if ( exceptionList[hostname] !== undefined ) {
var netExceptionList = this.userSettings.netExceptionList;
if ( netExceptionList[hostname] !== undefined ) {
return false;
}
var hostnames = this.URI.parentHostnamesFromHostname(hostname);
while ( hostname = hostnames.shift() ) {
if ( exceptionList[hostname] !== undefined ) {
if ( netExceptionList[hostname] !== undefined ) {
return false;
}
}
@ -47,11 +47,11 @@
if ( newState === currentState ) {
return currentState;
}
var exceptionList = this.userSettings.exceptionList;
var netExceptionList = this.userSettings.netExceptionList;
// Add to exception list
if ( !newState ) {
exceptionList[hostname] = true;
netExceptionList[hostname] = true;
this.saveExceptionList();
return true;
}
@ -60,8 +60,8 @@
if ( newState ) {
var hostnames = this.URI.allHostnamesFromHostname(hostname);
while ( hostname = hostnames.shift() ) {
if ( exceptionList[hostname] !== undefined ) {
delete exceptionList[hostname];
if ( netExceptionList[hostname] !== undefined ) {
delete netExceptionList[hostname];
}
}
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() {
chrome.storage.local.set({
'exceptionList': this.userSettings.exceptionList
'netExceptionList': this.userSettings.netExceptionList
});
};