<script type="text/discourse-plugin" version="0.8">
var u = api.getCurrentUser();
if (u !== null) {
u.findDetails().then(function (u) {
if (u.groups.some(function (g) {
return g.name === 'MyGroupName';
})) {
// User is member of the group
}
});
}
</script>
This will incur in an extra network request for .findDetails but works.