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