mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-05 18:32:30 +01:00
parent
e23e0d8283
commit
6de836b21f
@ -417,12 +417,15 @@ FrameStore.factory = function(rootHostname, frameURL) {
|
||||
|
||||
FrameStore.prototype.init = function(rootHostname, frameURL) {
|
||||
var µburi = µb.URI;
|
||||
this.pageURL = frameURL;
|
||||
this.pageHostname = µburi.hostnameFromURI(frameURL);
|
||||
this.pageDomain = µburi.domainFromHostname(this.pageHostname) || this.pageHostname;
|
||||
this.rootHostname = rootHostname;
|
||||
this.rootDomain = µburi.domainFromHostname(rootHostname) || rootHostname;
|
||||
// This is part of the filtering evaluation context
|
||||
this.requestURL = this.requestHostname = this.requestType = '';
|
||||
this.netFiltering = true;
|
||||
this.netFilteringReadTime = 0;
|
||||
|
||||
return this;
|
||||
};
|
||||
@ -440,6 +443,15 @@ FrameStore.prototype.dispose = function() {
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
FrameStore.prototype.getNetFilteringSwitch = function() {
|
||||
if ( this.netFilteringReadTime < µb.netWhitelistModifyTime ) {
|
||||
this.netFiltering = µb.getNetFilteringSwitch(this.pageURL);
|
||||
this.netFilteringReadTime = Date.now();
|
||||
}
|
||||
return this.netFiltering;
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// To mitigate memory churning
|
||||
@ -637,8 +649,15 @@ PageStore.prototype.toggleNetFilteringSwitch = function(url, scope, state) {
|
||||
/******************************************************************************/
|
||||
|
||||
PageStore.prototype.filterRequest = function(context) {
|
||||
|
||||
if ( this.getNetFilteringSwitch() === false ) {
|
||||
if(context.preNavigationHeader) { // sometimes we get inline-script queries before being
|
||||
// informed of navigation
|
||||
if(µb.getNetFilteringSwitch(context.requestURL) === false) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
if(this.getNetFilteringSwitch() === false || // if we're turned off (whitelisted)
|
||||
(typeof context.getNetFilteringSwitch === "function" && // or we're in a frame that's whitelisted
|
||||
context.getNetFilteringSwitch() === false)) {
|
||||
if ( collapsibleRequestTypes.indexOf(context.requestType) !== -1 ) {
|
||||
this.netFilteringCache.add(context, '');
|
||||
}
|
||||
@ -659,7 +678,7 @@ PageStore.prototype.filterRequest = function(context) {
|
||||
// We evaluate dynamic filtering first, and hopefully we can skip
|
||||
// evaluation of static filtering.
|
||||
if ( µb.userSettings.advancedUserEnabled ) {
|
||||
var df = µb.sessionFirewall.evaluateCellZY(context.rootHostname, context.requestHostname, context.requestType);
|
||||
var df = µb.sessionFirewall.evaluateCellZY(context.pageHostname, context.requestHostname, context.requestType);
|
||||
if ( df.mustBlockOrAllow() ) {
|
||||
result = df.toFilterString();
|
||||
}
|
||||
@ -687,8 +706,15 @@ var collapsibleRequestTypes = 'image sub_frame object';
|
||||
/******************************************************************************/
|
||||
|
||||
PageStore.prototype.filterRequestNoCache = function(context) {
|
||||
|
||||
if ( this.getNetFilteringSwitch() === false ) {
|
||||
if(context.preNavigationHeader) { // sometimes we get inline-script queries before being
|
||||
// informed of navigation
|
||||
if(µb.getNetFilteringSwitch(context.requestURL) === false) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
if(this.getNetFilteringSwitch() === false || // if we're turned off (whitelisted)
|
||||
(typeof context.getNetFilteringSwitch === "function" && // or we're in a frame that's whitelisted
|
||||
context.getNetFilteringSwitch() === false)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -700,7 +726,7 @@ PageStore.prototype.filterRequestNoCache = function(context) {
|
||||
// We evaluate dynamic filtering first, and hopefully we can skip
|
||||
// evaluation of static filtering.
|
||||
if ( µb.userSettings.advancedUserEnabled ) {
|
||||
var df = µb.sessionFirewall.evaluateCellZY(context.rootHostname, context.requestHostname, context.requestType);
|
||||
var df = µb.sessionFirewall.evaluateCellZY(context.pageHostname, context.requestHostname, context.requestType);
|
||||
if ( df.mustBlockOrAllow() ) {
|
||||
result = df.toFilterString();
|
||||
}
|
||||
|
@ -392,7 +392,8 @@ var onHeadersReceived = function(details) {
|
||||
rootHostname: requestHostname,
|
||||
rootDomain: contextDomain,
|
||||
pageHostname: requestHostname,
|
||||
pageDomain: contextDomain
|
||||
pageDomain: contextDomain,
|
||||
preNavigationHeader: true
|
||||
};
|
||||
} else {
|
||||
context = pageStore;
|
||||
|
Loading…
Reference in New Issue
Block a user