Skip to content

Commit 01e0094

Browse files
authored
fix: Fix unsafe inline issue in Chrome (#102)
1 parent 938de53 commit 01e0094

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

script.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -546,11 +546,11 @@
546546
responseContainer.id = "responseContainer" + Math.floor(Math.random() * Math.pow(10, 10));
547547
responseContainer.style.display = "none";
548548
document.body.appendChild(responseContainer);
549-
const temp = document.createElement("a");
550-
temp.id = "temp";
551-
temp.style.display = "none";
552-
document.body.appendChild(temp);
553-
temp.href = `javascript:fetch("${url}", ${JSON.stringify(options)})
549+
const temp = document.createElement("button");
550+
temp.setAttribute("type", "button");
551+
temp.setAttribute(
552+
"onclick",
553+
`fetch("${url}", ${JSON.stringify(options)})
554554
.then(r => {
555555
document.querySelector("#${responseContainer.id}").innerText = JSON.stringify({
556556
ok: r.ok,
@@ -560,7 +560,10 @@
560560
});
561561
return r.text();
562562
})
563-
.then(t => document.querySelector("#${outputContainer.id}").innerText = t)`;
563+
.then(t => document.querySelector("#${outputContainer.id}").innerText = t)`
564+
);
565+
temp.style.display = "none";
566+
document.body.appendChild(temp);
564567
temp.click();
565568
// wait for fetch to complete and return a promise
566569
return new Promise((resolve) => {

0 commit comments

Comments
 (0)