mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 08:48:24 +08:00
ad7c7f819d
CVE-2021-32764
34 lines
832 B
JavaScript
34 lines
832 B
JavaScript
import { withPluginApi } from "discourse/lib/plugin-api";
|
|
import initLazyYt from "../lib/lazyYT";
|
|
|
|
export default {
|
|
name: "apply-lazyYT",
|
|
initialize() {
|
|
withPluginApi("0.1", (api) => {
|
|
initLazyYt($);
|
|
api.decorateCooked(
|
|
($elem) => {
|
|
const iframes = $(".lazyYT", $elem);
|
|
if (iframes.length === 0) {
|
|
return;
|
|
}
|
|
|
|
$(".lazyYT", $elem).lazyYT({
|
|
onPlay(e, $el) {
|
|
// don't cloak posts that have playing videos in them
|
|
const postId = parseInt(
|
|
$el.closest("article").data("post-id"),
|
|
10
|
|
);
|
|
if (postId) {
|
|
api.preventCloak(postId);
|
|
}
|
|
},
|
|
});
|
|
},
|
|
{ id: "discourse-lazyyt" }
|
|
);
|
|
});
|
|
},
|
|
};
|