Skip to content

Commit

Permalink
Do not block large media resources when loaded as top-level document
Browse files Browse the repository at this point in the history
Related issues:
- uBlockOrigin/uBlock-issues#1201
- uBlockOrigin/uBlock-issues#3184

Top-level media resources are not meant to be blocked, see:
#2813 (comment)
  • Loading branch information
gorhill committed Mar 26, 2024
1 parent 616c54f commit 3919a16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
38 changes: 19 additions & 19 deletions src/js/pagestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,27 @@
Home: https://github.com/gorhill/uBlock
*/

'use strict';

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

import contextMenu from './contextmenu.js';
import logger from './logger.js';
import staticNetFilteringEngine from './static-net-filtering.js';
import µb from './background.js';
import webext from './webext.js';
import { orphanizeString } from './text-utils.js';
import { redirectEngine } from './redirect-engine.js';
import {
domainFromHostname,
hostnameFromURI,
isNetworkURI,
} from './uri-utils.js';

import {
sessionFirewall,
sessionSwitches,
sessionURLFiltering,
} from './filtering-engines.js';

import {
domainFromHostname,
hostnameFromURI,
isNetworkURI,
} from './uri-utils.js';
import contextMenu from './contextmenu.js';
import logger from './logger.js';
import { orphanizeString } from './text-utils.js';
import { redirectEngine } from './redirect-engine.js';
import staticNetFilteringEngine from './static-net-filtering.js';
import webext from './webext.js';
import µb from './background.js';

/*******************************************************************************
Expand Down Expand Up @@ -379,11 +377,13 @@ const PageStore = class {

// If we are navigating from-to same site, remember whether large
// media elements were temporarily allowed.
if (
typeof this.allowLargeMediaElementsUntil !== 'number' ||
tabContext.rootHostname !== this.tabHostname
) {
this.allowLargeMediaElementsUntil = Date.now();
const now = Date.now();
if ( typeof this.allowLargeMediaElementsUntil !== 'number' ) {
this.allowLargeMediaElementsUntil = now;
} else if ( tabContext.rootHostname !== this.tabHostname ) {
if ( this.tabHostname.endsWith('about-scheme') === false ) {
this.allowLargeMediaElementsUntil = now;
}
}

this.tabHostname = tabContext.rootHostname;
Expand Down
2 changes: 1 addition & 1 deletion src/js/traffic.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ const onHeadersReceived = function(details) {
}
};

const reMediaContentTypes = /^(?:audio|image|video)\//;
const reMediaContentTypes = /^(?:audio|image|video)\/|(?:\/ogg)$/;

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

Expand Down

0 comments on commit 3919a16

Please sign in to comment.