mirror of
https://github.com/ankitects/anki.git
synced 2025-11-15 00:57:13 -05:00
Merge pull request #1331 from hikaru-y/fix-fragment-autoplay
Fix <audio>/<video> with 'autoplay' issue
This commit is contained in:
commit
273be14fd3
2 changed files with 6 additions and 1 deletions
|
|
@ -106,6 +106,9 @@ class AnkiWebPage(QWebEnginePage):
|
||||||
if "MathJax localStorage" in buf:
|
if "MathJax localStorage" in buf:
|
||||||
# silence localStorage noise
|
# silence localStorage noise
|
||||||
return
|
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
|
# ensure we don't try to write characters the terminal can't handle
|
||||||
buf = buf.encode(sys.stdout.encoding, "backslashreplace").decode(
|
buf = buf.encode(sys.stdout.encoding, "backslashreplace").decode(
|
||||||
sys.stdout.encoding
|
sys.stdout.encoding
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,9 @@ function clearPreloadLinks(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractImageSrcs(html: string): string[] {
|
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(
|
const srcs = [...fragment.querySelectorAll("img[src]")].map(
|
||||||
(img) => (img as HTMLImageElement).src
|
(img) => (img as HTMLImageElement).src
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue