mirror of
https://github.com/ankitects/anki.git
synced 2026-01-13 05:53:53 -05:00
Added: #qa div for backwards compatibility
This commit is contained in:
parent
d8108c93a7
commit
735d0b0417
1 changed files with 6 additions and 2 deletions
|
|
@ -39,6 +39,10 @@ const urlParams = new URLSearchParams(location.search);
|
|||
const decoder = new TextDecoder();
|
||||
const style = document.createElement("style");
|
||||
document.head.appendChild(style);
|
||||
const qaDiv = document.createElement("div");
|
||||
document.body.appendChild(qaDiv);
|
||||
qaDiv.id = "qa";
|
||||
qaDiv.style.opacity = "1";
|
||||
|
||||
addEventListener("message", async (e: MessageEvent<InnerReviewerRequest>) => {
|
||||
switch (e.data.type) {
|
||||
|
|
@ -48,7 +52,7 @@ addEventListener("message", async (e: MessageEvent<InnerReviewerRequest>) => {
|
|||
break;
|
||||
}
|
||||
case "html": {
|
||||
document.body.innerHTML = e.data.value;
|
||||
qaDiv.innerHTML = e.data.value;
|
||||
if (e.data.css) {
|
||||
style.innerHTML = e.data.css;
|
||||
}
|
||||
|
|
@ -66,7 +70,7 @@ addEventListener("message", async (e: MessageEvent<InnerReviewerRequest>) => {
|
|||
onShownHook.length = 0;
|
||||
|
||||
// "".innerHTML =" does not run scripts
|
||||
for (const script of document.querySelectorAll("script")) {
|
||||
for (const script of qaDiv.querySelectorAll("script")) {
|
||||
// strict mode prevents the use of "eval" here
|
||||
const parent = script.parentElement!;
|
||||
const _script = script.parentElement!.removeChild(script);
|
||||
|
|
|
|||
Loading…
Reference in a new issue