mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-11 09:31:01 +01:00
fix #2813
This commit is contained in:
parent
47dfb1b22c
commit
b429e1c7ba
1 changed files with 19 additions and 5 deletions
|
@ -410,15 +410,24 @@ var onHeadersReceived = function(details) {
|
||||||
return foilLargeMediaElement(pageStore, details);
|
return foilLargeMediaElement(pageStore, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/gorhill/uBO-Extra/issues/19
|
// https://github.com/gorhill/uBlock/issues/2813
|
||||||
// Turns out scripts must also be considered as potential embedded
|
// Disable the blocking of large media elements if the document is itself
|
||||||
// contexts (as workers) and as such we may need to inject content
|
// a media element: the resource was not prevented from loading so no
|
||||||
// security policy directives.
|
// point to further block large media elements for the current document.
|
||||||
if ( requestType === 'main_frame' || requestType === 'sub_frame' ) {
|
if ( requestType === 'main_frame' ) {
|
||||||
|
if ( reMediaContentTypes.test(headerValueFromName('content-type', details.responseHeaders)) ) {
|
||||||
|
pageStore.allowLargeMediaElementsUntil = Date.now() + 86400000;
|
||||||
|
}
|
||||||
|
return injectCSP(pageStore, details);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( requestType === 'sub_frame' ) {
|
||||||
return injectCSP(pageStore, details);
|
return injectCSP(pageStore, details);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var reMediaContentTypes = /^(?:audio|image|video)\//;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var injectCSP = function(pageStore, details) {
|
var injectCSP = function(pageStore, details) {
|
||||||
|
@ -603,6 +612,11 @@ var headerIndexFromName = function(headerName, headers) {
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var headerValueFromName = function(headerName, headers) {
|
||||||
|
var i = headerIndexFromName(headerName, headers);
|
||||||
|
return i !== -1 ? headers[i].value : '';
|
||||||
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
vAPI.net.onBeforeRequest = {
|
vAPI.net.onBeforeRequest = {
|
||||||
|
|
Loading…
Reference in a new issue