This works as intended
$(document).ready(function() {
$(window).on('action:topics.loaded', function(ev, { topics }) {
topics.forEach(({ tid }) => {
const $topicEl = $(`li[component="category/topic"][data-tid="${tid}"]`);
const $categoryLabel = $topicEl.find('[component="topic/labels"] a[href^="/category/"]');
const bgColor = $categoryLabel.css("background-color");
const color = $categoryLabel.css("color");
// Set a timeout to delay the execution of style changes
setTimeout(() => {
$categoryLabel.attr("style", `border-color: ${bgColor} !important; color: ${bgColor}`);
}, 100); // Change to the desired timeout in milliseconds
});
});
});