Stop autoplay for unset media source with no-large-media-elements

Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/mxgpmc/
This commit is contained in:
Raymond Hill 2021-04-27 08:59:59 -04:00
parent 2a5e67e3f5
commit 81fadf836f
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 13 additions and 0 deletions

View File

@ -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);
/******************************************************************************/