mirror of https://github.com/gorhill/uBlock.git
Fix images not properly downloading on click
Related feedback: https://github.com/uBlockOrigin/uBlock-issues/issues/1670#issuecomment-2372048056 The issue affected images supporting `srcset` attribute without the presence of `src` attribute. This commit takes add fallback onto `srcset` attribute when the `src` attribute is not present.
This commit is contained in:
parent
03df1a40d8
commit
aec0bd39e3
|
@ -19,10 +19,6 @@
|
|||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
(( ) => {
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -132,15 +128,12 @@ if ( vAPI.largeMediaElementStyleSheet === undefined ) {
|
|||
|
||||
const loadMedia = async function(elem) {
|
||||
const src = elem.getAttribute('src') || '';
|
||||
if ( src === '' ) { return; }
|
||||
elem.removeAttribute('src');
|
||||
|
||||
await vAPI.messaging.send('scriptlets', {
|
||||
what: 'temporarilyAllowLargeMediaElement',
|
||||
});
|
||||
|
||||
if ( src !== '' ) {
|
||||
elem.setAttribute('src', src);
|
||||
}
|
||||
elem.load();
|
||||
};
|
||||
|
||||
|
@ -148,14 +141,21 @@ const loadMedia = async function(elem) {
|
|||
|
||||
const loadImage = async function(elem) {
|
||||
const src = elem.getAttribute('src') || '';
|
||||
const srcset = src === '' && elem.getAttribute('srcset') || '';
|
||||
if ( src === '' && srcset === '' ) { return; }
|
||||
if ( src !== '' ) {
|
||||
elem.removeAttribute('src');
|
||||
|
||||
}
|
||||
if ( srcset !== '' ) {
|
||||
elem.removeAttribute('srcset');
|
||||
}
|
||||
await vAPI.messaging.send('scriptlets', {
|
||||
what: 'temporarilyAllowLargeMediaElement',
|
||||
});
|
||||
|
||||
if ( src !== '' ) {
|
||||
elem.setAttribute('src', src);
|
||||
} else if ( srcset !== '' ) {
|
||||
elem.setAttribute('srcset', srcset);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue