Merge pull request #1331 from hikaru-y/fix-fragment-autoplay

Fix <audio>/<video> with 'autoplay' issue
This commit is contained in:
Damien Elmes 2021-08-18 16:37:14 +10:00 committed by GitHub
commit 273be14fd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -106,6 +106,9 @@ class AnkiWebPage(QWebEnginePage):
if "MathJax localStorage" in buf:
# silence localStorage noise
return
elif "link preload" in buf:
# silence 'link preload' warning on the first card
return
# ensure we don't try to write characters the terminal can't handle
buf = buf.encode(sys.stdout.encoding, "backslashreplace").decode(
sys.stdout.encoding

View file

@ -31,7 +31,9 @@ function clearPreloadLinks(): void {
}
function extractImageSrcs(html: string): string[] {
const fragment = document.createRange().createContextualFragment(html);
const tmpl = document.createElement("template");
tmpl.innerHTML = html;
const fragment = tmpl.content;
const srcs = [...fragment.querySelectorAll("img[src]")].map(
(img) => (img as HTMLImageElement).src
);