-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcontent.js
More file actions
25 lines (20 loc) · 871 Bytes
/
content.js
File metadata and controls
25 lines (20 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
setInterval(() => {
document.querySelectorAll(".language-html").forEach(codeSpace => {
const existingIframe = codeSpace.querySelector("iframe");
if (!codeSpace.lastChild.tagName || (codeSpace.lastChild.tagName && codeSpace.lastChild.tagName.toLowerCase() !== "iframe")) {
if (existingIframe) {
existingIframe.remove();
}
}
if(!existingIframe) {
const codeContent = codeSpace.innerText;
const iframe = document.createElement('iframe');
codeSpace.parentElement.style.padding = "0";
iframe.style.width = "100%";
iframe.style.height = "60vh";
iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts');
codeSpace.appendChild(iframe);
iframe.srcdoc = codeContent;
}
});
}, 2000);