1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-08 12:57:57 +02: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:
Raymond Hill 2019-04-14 17:37:48 -04:00
parent b73480b4c5
commit 7652808806
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -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({