mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-05 18:32:30 +01:00
Improve handling of srcset-based images in element picker
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/517
This commit is contained in:
parent
b73480b4c5
commit
7652808806
@ -342,7 +342,7 @@ const resourceURLFromElement = function(elem) {
|
||||
}
|
||||
if ( typeof elem.srcset === 'string' && elem.srcset !== '' ) {
|
||||
const ss = [];
|
||||
for ( let s of elem.srcset.split(/\s*,\s+/) ) {
|
||||
for ( let s of elem.srcset.split(',') ) {
|
||||
const pos = s.indexOf(' ');
|
||||
if ( pos !== -1 ) { s = s.slice(0, pos); }
|
||||
const parsedURL = new URL(s, document.baseURI);
|
||||
@ -471,10 +471,6 @@ const netFilter1stSources = {
|
||||
'video': 'src'
|
||||
};
|
||||
|
||||
const netFilter2ndSources = {
|
||||
'img': 'srcset'
|
||||
};
|
||||
|
||||
const filterTypes = {
|
||||
'audio': 'media',
|
||||
'embed': 'object',
|
||||
@ -750,8 +746,13 @@ const filterToDOMInterface = (function() {
|
||||
let srcProp = netFilter1stSources[elem.localName];
|
||||
let src = elem[srcProp];
|
||||
if ( typeof src !== 'string' || src.length === 0 ) {
|
||||
srcProp = netFilter2ndSources[elem.localName];
|
||||
src = elem[srcProp];
|
||||
if (
|
||||
typeof elem.srcset === 'string' &&
|
||||
elem.srcset !== '' &&
|
||||
typeof elem.currentSrc === 'string'
|
||||
) {
|
||||
src = elem.currentSrc;
|
||||
}
|
||||
}
|
||||
if ( src && reFilter.test(src) ) {
|
||||
out.push({
|
||||
|
Loading…
Reference in New Issue
Block a user