mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-23 10:52:43 +01:00
Handle picture > source
elements
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2069
This commit is contained in:
parent
ab6a59daf8
commit
3391435f75
@ -231,13 +231,12 @@ const resourceURLsFromElement = function(elem) {
|
||||
if ( url !== '' ) { urls.push(url); }
|
||||
return urls;
|
||||
}
|
||||
{
|
||||
const s = elem[prop];
|
||||
if ( typeof s === 'string' && /^https?:\/\//.test(s) ) {
|
||||
urls.push(trimFragmentFromURL(s.slice(0, 1024)));
|
||||
}
|
||||
const s = elem[prop];
|
||||
if ( typeof s === 'string' && /^https?:\/\//.test(s) ) {
|
||||
urls.push(trimFragmentFromURL(s.slice(0, 1024)));
|
||||
}
|
||||
resourceURLsFromSrcset(elem, urls);
|
||||
resourceURLsFromPicture(elem, urls);
|
||||
return urls;
|
||||
};
|
||||
|
||||
@ -272,6 +271,20 @@ const resourceURLsFromSrcset = function(elem, out) {
|
||||
}
|
||||
};
|
||||
|
||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/2069#issuecomment-1080600661
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture
|
||||
const resourceURLsFromPicture = function(elem, out) {
|
||||
if ( elem.localName === 'source' ) { return; }
|
||||
const picture = elem.parentElement;
|
||||
if ( picture === null || picture.localName !== 'picture' ) { return; }
|
||||
const sources = picture.querySelectorAll(':scope > source');
|
||||
for ( const source of sources ) {
|
||||
const urls = resourceURLsFromElement(source);
|
||||
if ( urls.length === 0 ) { continue; }
|
||||
out.push(...urls);
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const netFilterFromUnion = function(patternIn, out) {
|
||||
@ -364,6 +377,7 @@ const netFilter1stSources = {
|
||||
'iframe': 'src',
|
||||
'img': 'src',
|
||||
'object': 'data',
|
||||
'source': 'src',
|
||||
'video': 'src'
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user