我们对模糊NSFW内容的解决方案

我无法再编辑我的原帖了,但这里是更新后的代码。你愿意分享一下你的“点击”解决方案吗?

<!-- 将当前用户的 NSFW 偏好添加到 body 标签 -->
<script type="text/discourse-plugin" version="0.8.7">

// https://meta.discourse.org/t/css-classes-for-group-membership-for-simplified-ui-mode/60838/2
if (window.jQuery) {
    window.jQuery(function ($) {

        let currentUser = api.getCurrentUser();
        
        if (currentUser) {
            api.container.lookup('store:main').find('user', currentUser.username).then((user) => {

                if (user.user_fields[2]) {
                    $('body').addClass('nsfw-always-show' );
                }
            });
        }
    });
};
</script>
2 个赞