Run script only in certain categories?

I have a script to disable right click on images which currently applies to the entire site, but I have some private categories where I would like it disabled, is there any way to do this with a script? Thanks!

<script type="text/discourse-plugin" version="0.8">
  api.onPageChange((url, title) => {
    $("img").bind("contextmenu",function(e) {
      return false;
    });
  });
</script>
  
<script type="text/discourse-plugin" version="0.8">

const TopicRoute = require("discourse/routes/topic").default;

TopicRoute.reopen({
	activate: function() {
		this._super();
		Em.run.next(function() {
		    $('body').on('contextmenu', '.cooked img, .mfp-img', function(e){ return false; });
		});
	}
});
</script>
1 Like