Skip to content

Commit

Permalink
Stop autoplay for unset media source with no-large-media-elements
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Apr 27, 2021
1 parent 2a5e67e commit 81fadf8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/js/scriptlets/load-large-media-interactive.js
Expand Up @@ -213,6 +213,19 @@ const onLoadedData = function(ev) {
media.pause();
};

// https://www.reddit.com/r/uBlockOrigin/comments/mxgpmc/
// Support cases where the media source is not yet set.
for ( const media of document.querySelectorAll('audio,video') ) {
const src = media.src;
if (
(typeof src === 'string') &&
(src === '' || src.startsWith('blob:'))
) {
media.autoplay = false;
media.pause();
}
}

document.addEventListener('loadeddata', onLoadedData);

/******************************************************************************/
Expand Down

0 comments on commit 81fadf8

Please sign in to comment.