[Chromium] Prevent duplicated MSE placeholders (e.g. on Youtube).
This commit is contained in:
parent
a1afd19a0e
commit
1fc69298f5
|
@ -67,16 +67,24 @@ if ("MediaSource" in window) {
|
||||||
|
|
||||||
} else if ("SecurityPolicyViolationEvent" in window) {
|
} else if ("SecurityPolicyViolationEvent" in window) {
|
||||||
// Chromium
|
// Chromium
|
||||||
|
let createPlaceholders = () => {
|
||||||
|
let request = notify(false);
|
||||||
|
for (let me of document.querySelectorAll("video,audio")) {
|
||||||
|
if (!(me.src || me.currentSrc) || me.src.startsWith("blob")) {
|
||||||
|
createPlaceholder(me, request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let processedURIs = new Set();
|
||||||
|
let whenReady = false;
|
||||||
addEventListener("securitypolicyviolation", e => {
|
addEventListener("securitypolicyviolation", e => {
|
||||||
if (!e.isTrusted || ns.allows("media")) return;
|
if (!e.isTrusted || ns.allows("media")) return;
|
||||||
let {blockedURI, violatedDirective} = e;
|
let {blockedURI, violatedDirective} = e;
|
||||||
if (blockedURI.startsWith("blob") && violatedDirective.startsWith("media-src")) {
|
if (blockedURI.startsWith("blob") &&
|
||||||
let request = notify(false);
|
violatedDirective.startsWith("media-src") &&
|
||||||
for (let me of document.querySelectorAll("video,audio")) {
|
!processedURIs.has(blockedURI)) {
|
||||||
if (!(me.src || me.currentSrc) || me.src.startsWith("blob")) {
|
processedURIs.add(blockedURI);
|
||||||
createPlaceholder(me, request);
|
setTimeout(createPlaceholders, 0);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue