mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00: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
1 changed files with 13 additions and 0 deletions
|
|
@ -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 a new issue