mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-09 14:37:36 +01:00
Harden video_embed.js, store URL in data-src
This commit is contained in:
parent
ae88360e20
commit
8f2a87e5ed
@ -1,5 +1,7 @@
|
|||||||
document.querySelectorAll(".video-embed").forEach(ele => {
|
document.querySelectorAll(".video-embed").forEach(ele => {
|
||||||
const url = new URL(ele.getAttribute("href"));
|
try {
|
||||||
|
const href = ele.getAttribute("href");
|
||||||
|
const url = new URL(href);
|
||||||
|
|
||||||
if (url.host == "www.youtube.com") {
|
if (url.host == "www.youtube.com") {
|
||||||
ele.addEventListener("click", () => {
|
ele.addEventListener("click", () => {
|
||||||
@ -19,6 +21,12 @@ document.querySelectorAll(".video-embed").forEach(ele => {
|
|||||||
const iframe = ele.children[0];
|
const iframe = ele.children[0];
|
||||||
iframe.setAttribute("src", embedURL);
|
iframe.setAttribute("src", embedURL);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ele.setAttribute("data-src", href);
|
||||||
ele.removeAttribute("href");
|
ele.removeAttribute("href");
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user