mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-11 17:41:03 +01:00
Assume media elements with no Content-Length header to be of size 0
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/543
This commit is contained in:
parent
72bbcdd93c
commit
fff2bb6290
2 changed files with 15 additions and 12 deletions
|
@ -440,11 +440,11 @@ PageStore.prototype.toggleNetFilteringSwitch = function(url, scope, state) {
|
|||
/******************************************************************************/
|
||||
|
||||
PageStore.prototype.injectLargeMediaElementScriptlet = function() {
|
||||
this.largeMediaTimer = null;
|
||||
µb.scriptlets.injectDeep(
|
||||
this.tabId,
|
||||
'load-large-media-interactive'
|
||||
);
|
||||
vAPI.tabs.injectScript(this.tabId, {
|
||||
file: '/js/scriptlets/load-large-media-interactive.js',
|
||||
allFrames: true,
|
||||
runAt: 'document_idle',
|
||||
});
|
||||
µb.contextMenu.update(this.tabId);
|
||||
};
|
||||
|
||||
|
@ -714,10 +714,10 @@ PageStore.prototype.filterLargeMediaElement = function(fctxt, size) {
|
|||
|
||||
this.largeMediaCount += 1;
|
||||
if ( this.largeMediaTimer === null ) {
|
||||
this.largeMediaTimer = vAPI.setTimeout(
|
||||
this.injectLargeMediaElementScriptlet.bind(this),
|
||||
500
|
||||
);
|
||||
this.largeMediaTimer = vAPI.setTimeout(( ) => {
|
||||
this.largeMediaTimer = null;
|
||||
this.injectLargeMediaElementScriptlet();
|
||||
}, 500);
|
||||
}
|
||||
|
||||
if ( µb.logger.enabled ) {
|
||||
|
|
|
@ -907,10 +907,13 @@ const injectCSP = function(fctxt, pageStore, responseHeaders) {
|
|||
// "Block elements by size"
|
||||
|
||||
const foilLargeMediaElement = function(fctxt, pageStore, responseHeaders) {
|
||||
let size = 0;
|
||||
if ( µBlock.userSettings.largeMediaSize !== 0 ) {
|
||||
const i = headerIndexFromName('content-length', responseHeaders);
|
||||
if ( i === -1 ) { return; }
|
||||
size = parseInt(responseHeaders[i].value, 10) || 0;
|
||||
}
|
||||
|
||||
const size = parseInt(responseHeaders[i].value, 10) || 0;
|
||||
const result = pageStore.filterLargeMediaElement(fctxt, size);
|
||||
if ( result === 0 ) { return; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue