Something like this should work, although it’s a bit of a blunt instrument in that it will fire on every page change. Ideally we would want to find a way to only run it on the homepage (perhaps using the url that’s passed in onPageChange.)
<script type="text/discourse-plugin" version="0.4">
api.onPageChange((url, title) => {
// This is your existing code
$('td.category .ember-view a').each(function() {
if ($(this).hasClass('link-fixed')) {
return;
}
// do it only if there's subcategories
if ($(this).parents('td.category').find('div.subcategories').length) {
var link = $(this).prop('href');
$(this).prop('href', link+'/none');
}
$(this).addClass('link-fixed');
});
});
</script>
Would also be better to put it before </body>
rather than </head>
.