You can try something like this
<script type="text/discourse-plugin" version="0.8">
api.modifyClass("model:composer", {
applyTopicTemplate() {
this._super(...arguments);
Ember.run.schedule("afterRender", () => {
// do your work here
});
}
});
</script>
This should allow you to add some custom logic when Discourse applies category topic templates.
That said, this type of way of writing stuff is a bit outdated. I would also recommend that you give this a read if you plan to spend a lot time on Discourse themes. It makes life much easier.