HTML in posts with access by groups
Allows users of specific groups (with a list of user exceptions) to use HTML in messages
https://i.imgur.com/fx8VWfO.png

Author: Alex_63
Platform: MyBB

To HTML-top (Admin → Options: 1st form):

<script type="text/javascript">
var HTMLinPost = {};
HTMLinPost.groups = [1,2]; // Groups allowed to using HTML in messages
HTMLinPost.noAccess = ['user','newTst2']; // User exceptions

HTMLinPost.parseTags = function(pst){
   var group = +$(pst).attr('data-group-id'); if(pst.id == 'post-preview')group = GroupID;
   var StrStart = '<div class="html-post-box"><div class="html-inner"><div class="html-content">';
   var StrEnd = '</div></div></div>'; var flg = false;
   if($.inArray(group,HTMLinPost.groups)!=-1 && group!=3 && $.inArray($(pst).find('.pa-author>a').text(),HTMLinPost.noAccess)==-1)flg = true;
   $('.code-box',pst).html(function(){return this.innerHTML.replace(/([\[\]])/g,'<span>$1</span>')});

   var oldF = $(pst).find('.code-box').filter(function(){return $(this).find('pre').text().indexOf('<!--HTML-->')!=-1});
   if(oldF.length) {oldF.replaceWith(function(){return StrStart+(flg?$(this).text().split('<!--HTML-->')[1]:'--')+StrEnd})}

   var cnt = $(pst).find('.post-content').html(),reg = new RegExp('&nbsp;|'+String.fromCharCode(160),'gim');
   cnt = cnt.replace(/\[html\]([\s\S]*?)\[\/html\]/mgi,function(str,Sk){ var s = '--'; if(flg)s = Sk;
      s = s.replace(/<br>/mgi,'\n').replace(reg,' ').replace(/<\/p>[\s\S]*?<p>/mgi,'\n\n');
      s = s.replace(/(?:<a\shref=")([\s\S]*?)(?:"[\s\S]*?>)([\s\S]*?)(?:<\/a>)/mgi,function(str,p1,p2,offset,s){return p2.match(/^http\:\/\//)?p2:p1.replace(/^http\:\/\/(?:.*?)click\.php\?/mgi,'')});
      s = s.replace(/script/mgi,'scr00').replace(/&amp;/gm,'&').replace(/&lt;/mgi,'<').replace(/&gt;/mgi,'>').replace(/&quot;/gm,'"');
      s = StrStart+$('<div>'+s+'</div>').html()+StrEnd; s = s.replace(/scr00/mgi,'script');
      return s;
   });
   $(pst).find('.post-content').html(cnt);
};

HTMLinPost.parseHTMLinPosts = function() {
  HTMLinPost.groups.push(0);
  $(document).pun_mainReady(function(){var btn = '<div onclick="bbcode(\'[html]\',\'[/html]\');"><span>HTML in messages</span></div>';
    $.inArray(GroupID,HTMLinPost.groups)!=-1 && $.inArray(UserLogin,HTMLinPost.noAccess)==-1 && $(btn).appendTo('#addition-area');
    $('.post:contains("[html]"),.post:has(.code-box)').map(function(){HTMLinPost.parseTags(this);});
    $('#post-preview').map(function(){HTMLinPost.parseTags(this)});
  });
}
</script>


Settings:
HTMLinPost.groups - groups allowed to use HTML in posts (separated by commas)
HTMLinPost.noAccess - nicknames of users from these groups who are not allowed to use HTML in posts (every nick in single quotes, separated by comma).
When using the script, it's possible that users from allowed groups (moderators by default) can use the ability to insert HTML for various purposes, including the possible theft of the admin's password, etc.