mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-18 08:52:26 +02:00
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:
parent
2a5e67e3f5
commit
81fadf836f
@ -213,6 +213,19 @@ const onLoadedData = function(ev) {
|
|||||||
media.pause();
|
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);
|
document.addEventListener('loadeddata', onLoadedData);
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user