mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04: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:
|
||||
# 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
|
||||
|
|
|
@ -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
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue