Skip to content

Commit

Permalink
Fix images not properly downloading on click
Browse files Browse the repository at this point in the history
Related feedback:
uBlockOrigin/uBlock-issues#1670 (comment)

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.
  • Loading branch information
gorhill committed Sep 26, 2024
1 parent 03df1a4 commit aec0bd3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/js/scriptlets/load-large-media-interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
Home: https://github.com/gorhill/uBlock
*/

'use strict';

/******************************************************************************/

(( ) => {

/******************************************************************************/
Expand Down Expand Up @@ -132,30 +128,34 @@ 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.setAttribute('src', src);
elem.load();
};

/******************************************************************************/

const loadImage = async function(elem) {
const src = elem.getAttribute('src') || '';
elem.removeAttribute('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);
}
};

Expand Down

0 comments on commit aec0bd3

Please sign in to comment.