A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/gorhill/uBlock/commit/c3bc2c741d61db3e99b313835c2ae34a4a008359 below:

Add support for `cname` type and `denyallow` option · gorhill/uBlock@c3bc2c7 · GitHub

@@ -151,10 +151,7 @@ NetFilteringResultCache.prototype.shelfLife = 15000;

151 151 152 152

/******************************************************************************/

153 153 154 -

// Frame stores are used solely to associate a URL with a frame id. The

155 -

// name `pageHostname` is used because of historical reasons. A more

156 -

// appropriate name is `frameHostname` -- something to do in a future

157 -

// refactoring.

154 +

// Frame stores are used solely to associate a URL with a frame id.

158 155 159 156

// To mitigate memory churning

160 157

const frameStoreJunkyard = [];

@@ -166,15 +163,19 @@ const FrameStore = class {

166 163

}

167 164 168 165

init(frameURL) {

169 -

const µburi = µb.URI;

170 -

this.pageHostname = µburi.hostnameFromURI(frameURL);

171 -

this.pageDomain =

172 -

µburi.domainFromHostname(this.pageHostname) || this.pageHostname;

166 +

this.exceptCname = undefined;

167 +

this.rawURL = frameURL;

168 +

if ( frameURL !== undefined ) {

169 +

this.hostname = vAPI.hostnameFromURI(frameURL);

170 +

this.domain =

171 +

vAPI.domainFromHostname(this.hostname) || this.hostname;

172 +

}

173 173

return this;

174 174

}

175 175 176 176

dispose() {

177 -

this.pageHostname = this.pageDomain = '';

177 +

this.exceptCname = undefined;

178 +

this.rawURL = this.hostname = this.domain = '';

178 179

if ( frameStoreJunkyard.length < frameStoreJunkyardMax ) {

179 180

frameStoreJunkyard.push(this);

180 181

}

@@ -239,7 +240,6 @@ const PageStore = class {

239 240

this.rawURL = tabContext.rawURL;

240 241

this.hostnameToCountMap = new Map();

241 242

this.contentLastModified = 0;

242 -

this.frames = new Map();

243 243

this.logData = undefined;

244 244

this.perLoadBlockedRequestCount = 0;

245 245

this.perLoadAllowedRequestCount = 0;

@@ -250,6 +250,9 @@ const PageStore = class {

250 250

this.internalRedirectionCount = 0;

251 251

this.extraData.clear();

252 252 253 +

this.frames = new Map();

254 +

this.setFrame(0, tabContext.rawURL);

255 + 253 256

// The current filtering context is cloned because:

254 257

// - We may be called with or without the current context having been

255 258

// initialized.

@@ -303,6 +306,7 @@ const PageStore = class {

303 306

// As part of https://github.com/chrisaljoudi/uBlock/issues/405

304 307

// URL changed, force a re-evaluation of filtering switch

305 308

this.rawURL = tabContext.rawURL;

309 +

this.setFrame(0, this.rawURL);

306 310

return this;

307 311

}

308 312

@@ -541,9 +545,22 @@ const PageStore = class {

541 545 542 546

// Static filtering has lowest precedence.

543 547

if ( result === 0 || result === 3 ) {

544 -

result = µb.staticNetFilteringEngine.matchString(fctxt);

545 -

if ( result !== 0 && µb.logger.enabled ) {

546 -

fctxt.filter = µb.staticNetFilteringEngine.toLogData();

548 +

const snfe = µb.staticNetFilteringEngine;

549 +

result = snfe.matchString(fctxt);

550 +

if ( result !== 0 ) {

551 +

if ( µb.logger.enabled ) {

552 +

fctxt.filter = snfe.toLogData();

553 +

}

554 +

// https://github.com/uBlockOrigin/uBlock-issues/issues/943

555 +

// Blanket-except blocked aliased canonical hostnames?

556 +

if (

557 +

result === 1 &&

558 +

fctxt.aliasURL !== undefined &&

559 +

snfe.isBlockImportant() === false &&

560 +

this.shouldExceptCname(fctxt)

561 +

) {

562 +

return 2;

563 +

}

547 564

}

548 565

}

549 566

@@ -646,6 +663,40 @@ const PageStore = class {

646 663

return 1;

647 664

}

648 665 666 +

shouldExceptCname(fctxt) {

667 +

let exceptCname;

668 +

let frameStore;

669 +

if ( fctxt.docId !== undefined ) {

670 +

frameStore = this.getFrame(fctxt.docId);

671 +

if ( frameStore instanceof Object ) {

672 +

exceptCname = frameStore.exceptCname;

673 +

}

674 +

}

675 +

if ( exceptCname === undefined ) {

676 +

const result = µb.staticNetFilteringEngine.matchStringReverse(

677 +

'cname',

678 +

frameStore instanceof Object

679 +

? frameStore.rawURL

680 +

: fctxt.getDocOrigin()

681 +

);

682 +

if ( result === 2 ) {

683 +

exceptCname = µb.logger.enabled

684 +

? µb.staticNetFilteringEngine.toLogData()

685 +

: true;

686 +

} else {

687 +

exceptCname = false;

688 +

}

689 +

if ( frameStore instanceof Object ) {

690 +

frameStore.exceptCname = exceptCname;

691 +

}

692 +

}

693 +

if ( exceptCname === false ) { return false; }

694 +

if ( exceptCname instanceof Object ) {

695 +

fctxt.setFilter(exceptCname);

696 +

}

697 +

return true;

698 +

}

699 + 649 700

getBlockedResources(request, response) {

650 701

const normalURL = µb.normalizePageURL(this.tabId, request.frameURL);

651 702

const resources = request.resources;


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4