From ac6a59914b0c1a20f084f9ae9a3136b28c89493e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 7 Mar 2021 13:22:38 +0300 Subject: nsfw: support API clients --- plugins/nsfw/init.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'plugins/nsfw/init.js') diff --git a/plugins/nsfw/init.js b/plugins/nsfw/init.js index 4bc2443e8..71fe4747b 100644 --- a/plugins/nsfw/init.js +++ b/plugins/nsfw/init.js @@ -2,11 +2,17 @@ Plugins.NSFW = { toggle: function(elem) { - const content = elem.domNode.parentNode.querySelector(".nswf.content"); + elem = elem.domNode || elem; - if (content) { - Element.toggle(content); - } + const content = elem.closest(".nsfw-wrapper").querySelector('.nsfw-content'); + + // we can't use .toggle() here because this script could be invoked by the api client + // so it's back to vanilla js + + if (content.style.display == 'none') + content.style.display = ''; + else + content.style.display = 'none'; } } -- cgit v1.2.3